Skip to content
Snippets Groups Projects
Commit cc1aeca4 authored by C-Glick's avatar C-Glick
Browse files

Added attitude rate setpoint format and decoder

parent 6145da6d
No related branches found
No related tags found
1 merge request!73Attitude rate control
...@@ -71,6 +71,7 @@ enum packet_type { ...@@ -71,6 +71,7 @@ enum packet_type {
hoverType = 5, hoverType = 5,
fullStateType = 6, fullStateType = 6,
positionType = 7, positionType = 7,
attitudeRateType = 8,
}; };
/* ---===== 2 - Decoding functions =====--- */ /* ---===== 2 - Decoding functions =====--- */
...@@ -367,6 +368,37 @@ static void positionDecoder(setpoint_t *setpoint, uint8_t type, const void *data ...@@ -367,6 +368,37 @@ static void positionDecoder(setpoint_t *setpoint, uint8_t type, const void *data
setpoint->attitude.yaw = values->yaw; setpoint->attitude.yaw = values->yaw;
} }
/*
* Attitude rate decoder,
* packet contains the desired attitude rate in addition to the thrust value
*/
struct attitudeRatePacket_s{
float rollRate; // deg/s
float pitchRate; // deg/s
float yawRate; // deg/s
float thrust; // thrust percentage 0 - 60,000
} __attribute__((packed));
static void attitudeRateDecoder(setpoint_t *setpoint, uint8_t type, const void *data, size_t datalen){
const struct attitudeRatePacket_s *values = data;
ASSERT(datalen == sizeof(struct attitudeRatePacket_s));
setpoint->mode.x = modeDisable;
setpoint->mode.y = modeDisable;
setpoint->mode.z = modeDisable;
setpoint->mode.roll = modeVelocity;
setpoint->mode.pitch = modeVelocity;
setpoint->mode.yaw = modeVelocity;
setpoint->attitudeRate.roll = values->rollRate;
setpoint->attitudeRate.pitch = values->pitchRate;
setpoint->attitudeRate.yaw = values->yawRate;
setpoint->thrust = values->thrust;
}
/* ---===== 3 - packetDecoders array =====--- */ /* ---===== 3 - packetDecoders array =====--- */
const static packetDecoder_t packetDecoders[] = { const static packetDecoder_t packetDecoders[] = {
[stopType] = stopDecoder, [stopType] = stopDecoder,
...@@ -377,6 +409,7 @@ const static packetDecoder_t packetDecoders[] = { ...@@ -377,6 +409,7 @@ const static packetDecoder_t packetDecoders[] = {
[hoverType] = hoverDecoder, [hoverType] = hoverDecoder,
[fullStateType] = fullStateDecoder, [fullStateType] = fullStateDecoder,
[positionType] = positionDecoder, [positionType] = positionDecoder,
[attitudeRateType] = attitudeRateDecoder,
}; };
/* Decoder switch */ /* 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