I defined a new function called send_motor_setpoint within commander.py of the crazyflie python library (https://github.com/bitcraze/crazyflie-lib-python)
Code: Select all
def send_motor_setpoint(self, m1, m2, m3, m4):
"""
Control mode where the individual motor values are set
"""
pk = CRTPPacket()
pk.port = CRTPPort.COMMANDER_GENERIC
# <BHHHH as m1 to m4 are uint16_t, TYPE_MOTOR is set to 8
pk.data = struct.pack('<BHHHH', TYPE_MOTOR, m1, m2, m3, m4)
self._cf.send_packet(pk)
Code: Select all
typedef struct motor_s {
uint16_t m1;
uint16_t m2;
uint16_t m3;
uint16_t m4;
} motor_t
typedef struct setpoint_s {
uint32_t timestamp;
attitude_t attitude; // deg
attitude_t attitudeRate; // deg/s
quaternion_t attitudeQuaternion;
float thrust;
point_t position; // m
velocity_t velocity; // m/s
acc_t acceleration; // m/s^2
bool velocity_body; // true if velocity is given in body frame; false if velocity is given in world frame
motor_t motor;
struct {
stab_mode_t x;
stab_mode_t y;
stab_mode_t z;
stab_mode_t roll;
stab_mode_t pitch;
stab_mode_t yaw;
stab_mode_t quat;
} mode;
} setpoint_t;
Code: Select all
struct motorPacket_s {
uint16_t m1;
uint16_t m2;
uint16_t m3;
uint16_t m4;
} __attribute__((packed));
static void motorDecoder(setpoint_t *setpoint, uint8_t type, const void *data, size_t datalen)
{
const struct motorPacket_s *values = data;
setpoint->motor.m1 = values->m1;
setpoint->motor.m2 = values->m2;
setpoint->motor.m3 = values->m3;
setpoint->motor.m4 = values->m4;
}
- The script cannot even locate send_motor_setpoint (Edit: Solved this problem by reinstalling library from source and making it editable)
- Editing an existing function (example send_position_setpoint) to basically be send_motor_setpoint then allows the script to run but nothing happens
I know that there is a set of functions that will let me set individual motor parameters but the issue with that approach is that the motors can only be set one at a time (with latency inbetween) instead of all at once