Motor mapping
The motor mapping is defined in the power_distribution_flapper.c file of the crazyflie firmware:
| Actuator # | RevD and newer | RevB (model 2022) | Safe idle value |
|---|---|---|---|
| pitch servo | m1 | m2 | 33000 |
| yaw servo | m3 | m3 | 33000 |
| left motor | m2 | m1 | 0 |
| right motor | m4 | m4 | 0 |
In cfclient or using the python libraries, it is possible to set the motor values directly (and override the power distribution), e.g. via the MotorPowerSet parameter group.
When setting the motor command directly, please note that the servos might not be able to reach the set position due to physical constraints, in which case they will stall and overheat. Please use this functionality carefully and always start with the safe idle values in the table above.
Make sure to set all the servo commands before setting motorPowerSet.enable to 1. It is not advisable to set the enable parameter to 2 or 3, as the servos typically require different commands than the motors.
The (servo)motor command values range from 0 to 65535 (uint16), which linearly converts to a PWM signal with a pulse width between 1 and 2 milliseconds. The PWM signals are then fed to the motor ESCs and the servomotors.
For servo motors on the Nimble+, the conversion to angles is approximately 112.5 degrees per millisecond, i.e. 1.7166e-3 degrees per motor command unit.
The following tables show how the motor commands convert to the motor ESC throttle (the values vary linearly in between):
| Command | Command cfclient [%] | PWM [ms] | Throttle [%] |
|---|---|---|---|
| 0 | 0.0 | 1.000 | 0 |
| 9699 | 14.8 | 1.148 | 0 |
| 31981 | 48.8 | 1.488 | 50 |
| 54525 | 83.2 | 1.832 | 100 |
| 65535 | 100.0 | 2.000 | 100 |