mavlink_msg_radio_calibration.h 10.8 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2
// MESSAGE RADIO_CALIBRATION PACKING

LM's avatar
LM committed
3
#define MAVLINK_MSG_ID_RADIO_CALIBRATION 221
James Goppert's avatar
James Goppert committed
4

lm's avatar
lm committed
5
typedef struct __mavlink_radio_calibration_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7 8 9 10 11 12
 uint16_t aileron[3]; ///< Aileron setpoints: left, center, right
 uint16_t elevator[3]; ///< Elevator setpoints: nose down, center, nose up
 uint16_t rudder[3]; ///< Rudder setpoints: nose left, center, nose right
 uint16_t gyro[2]; ///< Tail gyro mode/gain setpoints: heading hold, rate mode
 uint16_t pitch[5]; ///< Pitch curve setpoints (every 25%)
 uint16_t throttle[5]; ///< Throttle curve setpoints (every 25%)
James Goppert's avatar
James Goppert committed
13
} mavlink_radio_calibration_t;
lm's avatar
lm committed
14 15 16 17

#define MAVLINK_MSG_ID_RADIO_CALIBRATION_LEN 42
#define MAVLINK_MSG_ID_221_LEN 42

James Goppert's avatar
James Goppert committed
18 19 20 21 22 23 24
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_AILERON_LEN 3
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_ELEVATOR_LEN 3
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_RUDDER_LEN 3
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_GYRO_LEN 2
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_PITCH_LEN 5
#define MAVLINK_MSG_RADIO_CALIBRATION_FIELD_THROTTLE_LEN 5

lm's avatar
lm committed
25 26 27 28 29 30 31 32 33 34 35 36 37
#define MAVLINK_MESSAGE_INFO_RADIO_CALIBRATION { \
	"RADIO_CALIBRATION", \
	6, \
	{  { "aileron", MAVLINK_TYPE_UINT16_T, 3, 0, offsetof(mavlink_radio_calibration_t, aileron) }, \
         { "elevator", MAVLINK_TYPE_UINT16_T, 3, 6, offsetof(mavlink_radio_calibration_t, elevator) }, \
         { "rudder", MAVLINK_TYPE_UINT16_T, 3, 12, offsetof(mavlink_radio_calibration_t, rudder) }, \
         { "gyro", MAVLINK_TYPE_UINT16_T, 2, 18, offsetof(mavlink_radio_calibration_t, gyro) }, \
         { "pitch", MAVLINK_TYPE_UINT16_T, 5, 22, offsetof(mavlink_radio_calibration_t, pitch) }, \
         { "throttle", MAVLINK_TYPE_UINT16_T, 5, 32, offsetof(mavlink_radio_calibration_t, throttle) }, \
         } \
}


James Goppert's avatar
James Goppert committed
38 39 40 41 42 43
/**
 * @brief Pack a radio_calibration message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
LM's avatar
LM committed
44 45 46
 * @param aileron Aileron setpoints: left, center, right
 * @param elevator Elevator setpoints: nose down, center, nose up
 * @param rudder Rudder setpoints: nose left, center, nose right
James Goppert's avatar
James Goppert committed
47 48 49 50 51
 * @param gyro Tail gyro mode/gain setpoints: heading hold, rate mode
 * @param pitch Pitch curve setpoints (every 25%)
 * @param throttle Throttle curve setpoints (every 25%)
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
52 53
static inline uint16_t mavlink_msg_radio_calibration_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       const uint16_t *aileron, const uint16_t *elevator, const uint16_t *rudder, const uint16_t *gyro, const uint16_t *pitch, const uint16_t *throttle)
James Goppert's avatar
James Goppert committed
54 55 56
{
	msg->msgid = MAVLINK_MSG_ID_RADIO_CALIBRATION;

lm's avatar
lm committed
57 58 59 60 61 62
	put_uint16_t_array_by_index(msg, 0, aileron, 3); // Aileron setpoints: left, center, right
	put_uint16_t_array_by_index(msg, 6, elevator, 3); // Elevator setpoints: nose down, center, nose up
	put_uint16_t_array_by_index(msg, 12, rudder, 3); // Rudder setpoints: nose left, center, nose right
	put_uint16_t_array_by_index(msg, 18, gyro, 2); // Tail gyro mode/gain setpoints: heading hold, rate mode
	put_uint16_t_array_by_index(msg, 22, pitch, 5); // Pitch curve setpoints (every 25%)
	put_uint16_t_array_by_index(msg, 32, throttle, 5); // Throttle curve setpoints (every 25%)
James Goppert's avatar
James Goppert committed
63

lm's avatar
lm committed
64
	return mavlink_finalize_message(msg, system_id, component_id, 42, 71);
James Goppert's avatar
James Goppert committed
65 66 67
}

/**
lm's avatar
lm committed
68
 * @brief Pack a radio_calibration message on a channel
James Goppert's avatar
James Goppert committed
69 70 71 72
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
LM's avatar
LM committed
73 74 75
 * @param aileron Aileron setpoints: left, center, right
 * @param elevator Elevator setpoints: nose down, center, nose up
 * @param rudder Rudder setpoints: nose left, center, nose right
James Goppert's avatar
James Goppert committed
76 77 78 79 80
 * @param gyro Tail gyro mode/gain setpoints: heading hold, rate mode
 * @param pitch Pitch curve setpoints (every 25%)
 * @param throttle Throttle curve setpoints (every 25%)
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
81 82 83
static inline uint16_t mavlink_msg_radio_calibration_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           const uint16_t *aileron,const uint16_t *elevator,const uint16_t *rudder,const uint16_t *gyro,const uint16_t *pitch,const uint16_t *throttle)
James Goppert's avatar
James Goppert committed
84 85 86
{
	msg->msgid = MAVLINK_MSG_ID_RADIO_CALIBRATION;

lm's avatar
lm committed
87 88 89 90 91 92
	put_uint16_t_array_by_index(msg, 0, aileron, 3); // Aileron setpoints: left, center, right
	put_uint16_t_array_by_index(msg, 6, elevator, 3); // Elevator setpoints: nose down, center, nose up
	put_uint16_t_array_by_index(msg, 12, rudder, 3); // Rudder setpoints: nose left, center, nose right
	put_uint16_t_array_by_index(msg, 18, gyro, 2); // Tail gyro mode/gain setpoints: heading hold, rate mode
	put_uint16_t_array_by_index(msg, 22, pitch, 5); // Pitch curve setpoints (every 25%)
	put_uint16_t_array_by_index(msg, 32, throttle, 5); // Throttle curve setpoints (every 25%)
James Goppert's avatar
James Goppert committed
93

lm's avatar
lm committed
94
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 42, 71);
James Goppert's avatar
James Goppert committed
95 96
}

lm's avatar
lm committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

/**
 * @brief Pack a radio_calibration message on a channel and send
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param aileron Aileron setpoints: left, center, right
 * @param elevator Elevator setpoints: nose down, center, nose up
 * @param rudder Rudder setpoints: nose left, center, nose right
 * @param gyro Tail gyro mode/gain setpoints: heading hold, rate mode
 * @param pitch Pitch curve setpoints (every 25%)
 * @param throttle Throttle curve setpoints (every 25%)
 */
static inline void mavlink_msg_radio_calibration_pack_chan_send(mavlink_channel_t chan,
							   mavlink_message_t* msg,
						           const uint16_t *aileron,const uint16_t *elevator,const uint16_t *rudder,const uint16_t *gyro,const uint16_t *pitch,const uint16_t *throttle)
{
	msg->msgid = MAVLINK_MSG_ID_RADIO_CALIBRATION;

	put_uint16_t_array_by_index(msg, 0, aileron, 3); // Aileron setpoints: left, center, right
	put_uint16_t_array_by_index(msg, 6, elevator, 3); // Elevator setpoints: nose down, center, nose up
	put_uint16_t_array_by_index(msg, 12, rudder, 3); // Rudder setpoints: nose left, center, nose right
	put_uint16_t_array_by_index(msg, 18, gyro, 2); // Tail gyro mode/gain setpoints: heading hold, rate mode
	put_uint16_t_array_by_index(msg, 22, pitch, 5); // Pitch curve setpoints (every 25%)
	put_uint16_t_array_by_index(msg, 32, throttle, 5); // Throttle curve setpoints (every 25%)

	mavlink_finalize_message_chan_send(msg, chan, 42, 71);
}
#endif // MAVLINK_USE_CONVENIENCE_FUNCTIONS


James Goppert's avatar
James Goppert committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
/**
 * @brief Encode a radio_calibration struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param radio_calibration C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_radio_calibration_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_radio_calibration_t* radio_calibration)
{
	return mavlink_msg_radio_calibration_pack(system_id, component_id, msg, radio_calibration->aileron, radio_calibration->elevator, radio_calibration->rudder, radio_calibration->gyro, radio_calibration->pitch, radio_calibration->throttle);
}

/**
 * @brief Send a radio_calibration message
 * @param chan MAVLink channel to send the message
 *
LM's avatar
LM committed
145 146 147
 * @param aileron Aileron setpoints: left, center, right
 * @param elevator Elevator setpoints: nose down, center, nose up
 * @param rudder Rudder setpoints: nose left, center, nose right
James Goppert's avatar
James Goppert committed
148 149 150 151
 * @param gyro Tail gyro mode/gain setpoints: heading hold, rate mode
 * @param pitch Pitch curve setpoints (every 25%)
 * @param throttle Throttle curve setpoints (every 25%)
 */
lm's avatar
lm committed
152 153 154
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_radio_calibration_send(mavlink_channel_t chan, const uint16_t *aileron, const uint16_t *elevator, const uint16_t *rudder, const uint16_t *gyro, const uint16_t *pitch, const uint16_t *throttle)
lm's avatar
lm committed
155
{
lm's avatar
lm committed
156 157
	MAVLINK_ALIGNED_MESSAGE(msg, 42);
	mavlink_msg_radio_calibration_pack_chan_send(chan, msg, aileron, elevator, rudder, gyro, pitch, throttle);
James Goppert's avatar
James Goppert committed
158 159 160
}

#endif
lm's avatar
lm committed
161

James Goppert's avatar
James Goppert committed
162 163
// MESSAGE RADIO_CALIBRATION UNPACKING

lm's avatar
lm committed
164

James Goppert's avatar
James Goppert committed
165 166 167
/**
 * @brief Get field aileron from radio_calibration message
 *
LM's avatar
LM committed
168
 * @return Aileron setpoints: left, center, right
James Goppert's avatar
James Goppert committed
169
 */
lm's avatar
lm committed
170
static inline uint16_t mavlink_msg_radio_calibration_get_aileron(const mavlink_message_t* msg, uint16_t *aileron)
James Goppert's avatar
James Goppert committed
171
{
lm's avatar
lm committed
172
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, aileron, 3,  0);
James Goppert's avatar
James Goppert committed
173 174 175 176 177
}

/**
 * @brief Get field elevator from radio_calibration message
 *
LM's avatar
LM committed
178
 * @return Elevator setpoints: nose down, center, nose up
James Goppert's avatar
James Goppert committed
179
 */
lm's avatar
lm committed
180
static inline uint16_t mavlink_msg_radio_calibration_get_elevator(const mavlink_message_t* msg, uint16_t *elevator)
James Goppert's avatar
James Goppert committed
181
{
lm's avatar
lm committed
182
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, elevator, 3,  6);
James Goppert's avatar
James Goppert committed
183 184 185 186 187
}

/**
 * @brief Get field rudder from radio_calibration message
 *
LM's avatar
LM committed
188
 * @return Rudder setpoints: nose left, center, nose right
James Goppert's avatar
James Goppert committed
189
 */
lm's avatar
lm committed
190
static inline uint16_t mavlink_msg_radio_calibration_get_rudder(const mavlink_message_t* msg, uint16_t *rudder)
James Goppert's avatar
James Goppert committed
191
{
lm's avatar
lm committed
192
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, rudder, 3,  12);
James Goppert's avatar
James Goppert committed
193 194 195 196 197 198 199
}

/**
 * @brief Get field gyro from radio_calibration message
 *
 * @return Tail gyro mode/gain setpoints: heading hold, rate mode
 */
lm's avatar
lm committed
200
static inline uint16_t mavlink_msg_radio_calibration_get_gyro(const mavlink_message_t* msg, uint16_t *gyro)
James Goppert's avatar
James Goppert committed
201
{
lm's avatar
lm committed
202
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, gyro, 2,  18);
James Goppert's avatar
James Goppert committed
203 204 205 206 207 208 209
}

/**
 * @brief Get field pitch from radio_calibration message
 *
 * @return Pitch curve setpoints (every 25%)
 */
lm's avatar
lm committed
210
static inline uint16_t mavlink_msg_radio_calibration_get_pitch(const mavlink_message_t* msg, uint16_t *pitch)
James Goppert's avatar
James Goppert committed
211
{
lm's avatar
lm committed
212
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, pitch, 5,  22);
James Goppert's avatar
James Goppert committed
213 214 215 216 217 218 219
}

/**
 * @brief Get field throttle from radio_calibration message
 *
 * @return Throttle curve setpoints (every 25%)
 */
lm's avatar
lm committed
220
static inline uint16_t mavlink_msg_radio_calibration_get_throttle(const mavlink_message_t* msg, uint16_t *throttle)
James Goppert's avatar
James Goppert committed
221
{
lm's avatar
lm committed
222
	return MAVLINK_MSG_RETURN_uint16_t_array(msg, throttle, 5,  32);
James Goppert's avatar
James Goppert committed
223 224 225 226 227 228 229 230 231 232
}

/**
 * @brief Decode a radio_calibration message into a struct
 *
 * @param msg The message to decode
 * @param radio_calibration C-struct to decode the message contents into
 */
static inline void mavlink_msg_radio_calibration_decode(const mavlink_message_t* msg, mavlink_radio_calibration_t* radio_calibration)
{
lm's avatar
lm committed
233 234 235 236 237 238 239 240 241 242
#if MAVLINK_NEED_BYTE_SWAP
	mavlink_msg_radio_calibration_get_aileron(msg, radio_calibration->aileron);
	mavlink_msg_radio_calibration_get_elevator(msg, radio_calibration->elevator);
	mavlink_msg_radio_calibration_get_rudder(msg, radio_calibration->rudder);
	mavlink_msg_radio_calibration_get_gyro(msg, radio_calibration->gyro);
	mavlink_msg_radio_calibration_get_pitch(msg, radio_calibration->pitch);
	mavlink_msg_radio_calibration_get_throttle(msg, radio_calibration->throttle);
#else
	memcpy(radio_calibration, MAVLINK_PAYLOAD(msg), 42);
#endif
James Goppert's avatar
James Goppert committed
243
}