Skip to content
Snippets Groups Projects
Commit 853900f2 authored by Colton Glick's avatar Colton Glick
Browse files

Added custom mixed attitude setpoint packet

roll and pitch are absolute angles and yaw is an angle rate.
parent 14b2c998
No related branches found
No related tags found
3 merge requests!76lots of gui updates,!75Lost of gui updates,!74lots of gui updates among others
......@@ -73,6 +73,7 @@ enum packet_type {
positionType = 7,
attitudeRateType = 8,
attitudeType = 9,
mixedAttitudeType = 10,
};
/* ---===== 2 - Decoding functions =====--- */
......@@ -431,6 +432,39 @@ static void attitudeDecoder(setpoint_t *setpoint, uint8_t type, const void *data
setpoint->thrust = values->thrust;
}
/*
* Custom mixed Attitude decoder, bypasses the normal attitude control path,
* packet contains the roll and pitch as attitude angles and the
* yaw as an attitude rate in addition to the thrust value
*/
struct mixedAttitudePacket_s{
float rollAngle; // deg
float pitchAngle; // deg
float yawAngleRate; // deg/s
float thrust; // thrust percentage 0 - 60,000
} __attribute__((packed));
static void mixedAttitudeDecoder(setpoint_t *setpoint, uint8_t type, const void *data, size_t datalen){
const struct mixedAttitudePacket_s *values = data;
ASSERT(datalen == sizeof(struct mixedAttitudePacket_s));
setpoint->mode.x = modeDisable;
setpoint->mode.y = modeDisable;
setpoint->mode.z = modeDisable;
setpoint->mode.roll = modeAbs;
setpoint->mode.pitch = modeAbs;
setpoint->mode.yaw = modeVelocity;
setpoint->attitude.roll = values->rollAngle;
setpoint->attitude.pitch = values->pitchAngle;
setpoint->attitudeRate.yaw = values->yawAngleRate;
setpoint->thrust = values->thrust;
}
/* ---===== 3 - packetDecoders array =====--- */
const static packetDecoder_t packetDecoders[] = {
[stopType] = stopDecoder,
......@@ -443,6 +477,7 @@ const static packetDecoder_t packetDecoders[] = {
[positionType] = positionDecoder,
[attitudeRateType] = attitudeRateDecoder,
[attitudeType] = attitudeDecoder,
[mixedAttitudeType] = mixedAttitudeDecoder,
};
/* Decoder switch */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment