Z_distance commander coordinates logic
Posted: Wed Apr 21, 2021 1:59 pm
Dear all,
I have a small question. I have been using the Z_distance command to set a setpoint (roll,pitch, yaw rate, z_distance). My question is why the yaw rate that I command is inverted to its negative value. This seems inconsistent to the coordinate system found on the bitcraze website.
As positive yaw rate should increase the yaw angle right? But when commanded to do a positive yaw rate, the commander makes it a negative rate see below.
/* zDistanceDecoder
* Set the Crazyflie absolute height and roll/pitch angles
*/
struct zDistancePacket_s {
float roll; // deg
float pitch; // ...
float yawrate; // deg/s
float zDistance; // m in the world frame of reference
} __attribute__((packed));
static void zDistanceDecoder(setpoint_t *setpoint, uint8_t type, const void *data, size_t datalen)
{
const struct zDistancePacket_s *values = data;
ASSERT(datalen == sizeof(struct zDistancePacket_s));
setpoint->mode.z = modeAbs;
setpoint->position.z = values->zDistance;
setpoint->mode.yaw = modeVelocity;
setpoint->attitudeRate.yaw = -values->yawrate;
setpoint->mode.roll = modeAbs;
setpoint->mode.pitch = modeAbs;
setpoint->attitude.roll = values->roll;
setpoint->attitude.pitch = values->pitch;
}
Is this a mistake or what is the reasoning?
I have a small question. I have been using the Z_distance command to set a setpoint (roll,pitch, yaw rate, z_distance). My question is why the yaw rate that I command is inverted to its negative value. This seems inconsistent to the coordinate system found on the bitcraze website.
As positive yaw rate should increase the yaw angle right? But when commanded to do a positive yaw rate, the commander makes it a negative rate see below.
/* zDistanceDecoder
* Set the Crazyflie absolute height and roll/pitch angles
*/
struct zDistancePacket_s {
float roll; // deg
float pitch; // ...
float yawrate; // deg/s
float zDistance; // m in the world frame of reference
} __attribute__((packed));
static void zDistanceDecoder(setpoint_t *setpoint, uint8_t type, const void *data, size_t datalen)
{
const struct zDistancePacket_s *values = data;
ASSERT(datalen == sizeof(struct zDistancePacket_s));
setpoint->mode.z = modeAbs;
setpoint->position.z = values->zDistance;
setpoint->mode.yaw = modeVelocity;
setpoint->attitudeRate.yaw = -values->yawrate;
setpoint->mode.roll = modeAbs;
setpoint->mode.pitch = modeAbs;
setpoint->attitude.roll = values->roll;
setpoint->attitude.pitch = values->pitch;
}
Is this a mistake or what is the reasoning?