Added notes on percent calibration and balance
This commit is contained in:
parent
44dff804d0
commit
16f6ea8ed3
1 changed files with 13 additions and 0 deletions
|
@ -1429,6 +1429,10 @@ logger = getLogger(__name__)
|
|||
step = 25
|
||||
# Duration of each step pulse during the transients
|
||||
step_duration = 0.03
|
||||
# Maximum percentage of change. You can calibrate this
|
||||
# value to achieve less abrupt rotations of the drone
|
||||
# around its axes
|
||||
max_percent = 0.5
|
||||
|
||||
def normalize_thrust(channel: int, percent: float) -> int:
|
||||
"""
|
||||
|
@ -1438,6 +1442,7 @@ def normalize_thrust(channel: int, percent: float) -> int:
|
|||
static thrust value for a given channel.
|
||||
"""
|
||||
pwm = get_plugin('pwm.pca9685')
|
||||
percent *= max_percent
|
||||
static_thrust = static_thrusts[channel]
|
||||
percent = max(-1., min(1., percent))
|
||||
thrust = static_thrust * (1 + percent)
|
||||
|
@ -1495,6 +1500,14 @@ def move(movement: Movement, percent: float):
|
|||
pwm.write(channels=channel_values, step=step, step_duration=step_duration)
|
||||
```
|
||||
|
||||
You'll notice that in this snippet we have managed the percentage of change in a balanced way between the motors.
|
||||
For instance, a +100% pitch change (meaning drone that moves forward at the maximum inclination) is achieved by
|
||||
increasing the power that goes to the two motors on the back by 50% compared to their static thrust values, and the
|
||||
power supplied to the motors on the front is decreased by 50% instead. This makes sure that even when the drone is
|
||||
moving the power supplied to the motors remains more or less constant, because while the speed of a pair of motors
|
||||
increases, the speed of the other pair always decreases. Calibrating the `max_percent` value can also help you achieve
|
||||
less abrupt movements - if the drones rotates too much around a certain axis it may lose balance and start falling.
|
||||
|
||||
Now that we have a function that can easily translate the desired percentage of change along a certain direction into
|
||||
the appropriate PWM values for the motor channels, let's connect them to our joystick controls. With Platypush running
|
||||
and the controller connected, move the analog controls on your joystick and check the lines logged by the application.
|
||||
|
|
Loading…
Reference in a new issue