Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Committer:
shimniok
Date:
Wed Jun 20 14:57:48 2012 +0000
Revision:
0:826c6171fc1b
Updated documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:826c6171fc1b 1 // MESSAGE SERVO_OUTPUT_RAW PACKING
shimniok 0:826c6171fc1b 2
shimniok 0:826c6171fc1b 3 #define MAVLINK_MSG_ID_SERVO_OUTPUT_RAW 37
shimniok 0:826c6171fc1b 4
shimniok 0:826c6171fc1b 5 typedef struct __mavlink_servo_output_raw_t
shimniok 0:826c6171fc1b 6 {
shimniok 0:826c6171fc1b 7 uint16_t servo1_raw; ///< Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 8 uint16_t servo2_raw; ///< Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 9 uint16_t servo3_raw; ///< Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 10 uint16_t servo4_raw; ///< Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 11 uint16_t servo5_raw; ///< Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 12 uint16_t servo6_raw; ///< Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 13 uint16_t servo7_raw; ///< Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 14 uint16_t servo8_raw; ///< Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 15
shimniok 0:826c6171fc1b 16 } mavlink_servo_output_raw_t;
shimniok 0:826c6171fc1b 17
shimniok 0:826c6171fc1b 18
shimniok 0:826c6171fc1b 19
shimniok 0:826c6171fc1b 20 /**
shimniok 0:826c6171fc1b 21 * @brief Pack a servo_output_raw message
shimniok 0:826c6171fc1b 22 * @param system_id ID of this system
shimniok 0:826c6171fc1b 23 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 24 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 25 *
shimniok 0:826c6171fc1b 26 * @param servo1_raw Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 27 * @param servo2_raw Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 28 * @param servo3_raw Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 29 * @param servo4_raw Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 30 * @param servo5_raw Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 31 * @param servo6_raw Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 32 * @param servo7_raw Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 33 * @param servo8_raw Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 34 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 35 */
shimniok 0:826c6171fc1b 36 static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
shimniok 0:826c6171fc1b 37 {
shimniok 0:826c6171fc1b 38 uint16_t i = 0;
shimniok 0:826c6171fc1b 39 msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW;
shimniok 0:826c6171fc1b 40
shimniok 0:826c6171fc1b 41 i += put_uint16_t_by_index(servo1_raw, i, msg->payload); // Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 42 i += put_uint16_t_by_index(servo2_raw, i, msg->payload); // Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 43 i += put_uint16_t_by_index(servo3_raw, i, msg->payload); // Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 44 i += put_uint16_t_by_index(servo4_raw, i, msg->payload); // Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 45 i += put_uint16_t_by_index(servo5_raw, i, msg->payload); // Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 46 i += put_uint16_t_by_index(servo6_raw, i, msg->payload); // Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 47 i += put_uint16_t_by_index(servo7_raw, i, msg->payload); // Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 48 i += put_uint16_t_by_index(servo8_raw, i, msg->payload); // Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 49
shimniok 0:826c6171fc1b 50 return mavlink_finalize_message(msg, system_id, component_id, i);
shimniok 0:826c6171fc1b 51 }
shimniok 0:826c6171fc1b 52
shimniok 0:826c6171fc1b 53 /**
shimniok 0:826c6171fc1b 54 * @brief Pack a servo_output_raw message
shimniok 0:826c6171fc1b 55 * @param system_id ID of this system
shimniok 0:826c6171fc1b 56 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 57 * @param chan The MAVLink channel this message was sent over
shimniok 0:826c6171fc1b 58 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 59 * @param servo1_raw Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 60 * @param servo2_raw Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 61 * @param servo3_raw Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 62 * @param servo4_raw Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 63 * @param servo5_raw Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 64 * @param servo6_raw Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 65 * @param servo7_raw Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 66 * @param servo8_raw Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 67 * @return length of the message in bytes (excluding serial stream start sign)
shimniok 0:826c6171fc1b 68 */
shimniok 0:826c6171fc1b 69 static inline uint16_t mavlink_msg_servo_output_raw_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
shimniok 0:826c6171fc1b 70 {
shimniok 0:826c6171fc1b 71 uint16_t i = 0;
shimniok 0:826c6171fc1b 72 msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW;
shimniok 0:826c6171fc1b 73
shimniok 0:826c6171fc1b 74 i += put_uint16_t_by_index(servo1_raw, i, msg->payload); // Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 75 i += put_uint16_t_by_index(servo2_raw, i, msg->payload); // Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 76 i += put_uint16_t_by_index(servo3_raw, i, msg->payload); // Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 77 i += put_uint16_t_by_index(servo4_raw, i, msg->payload); // Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 78 i += put_uint16_t_by_index(servo5_raw, i, msg->payload); // Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 79 i += put_uint16_t_by_index(servo6_raw, i, msg->payload); // Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 80 i += put_uint16_t_by_index(servo7_raw, i, msg->payload); // Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 81 i += put_uint16_t_by_index(servo8_raw, i, msg->payload); // Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 82
shimniok 0:826c6171fc1b 83 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
shimniok 0:826c6171fc1b 84 }
shimniok 0:826c6171fc1b 85
shimniok 0:826c6171fc1b 86 /**
shimniok 0:826c6171fc1b 87 * @brief Encode a servo_output_raw struct into a message
shimniok 0:826c6171fc1b 88 *
shimniok 0:826c6171fc1b 89 * @param system_id ID of this system
shimniok 0:826c6171fc1b 90 * @param component_id ID of this component (e.g. 200 for IMU)
shimniok 0:826c6171fc1b 91 * @param msg The MAVLink message to compress the data into
shimniok 0:826c6171fc1b 92 * @param servo_output_raw C-struct to read the message contents from
shimniok 0:826c6171fc1b 93 */
shimniok 0:826c6171fc1b 94 static inline uint16_t mavlink_msg_servo_output_raw_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_servo_output_raw_t* servo_output_raw)
shimniok 0:826c6171fc1b 95 {
shimniok 0:826c6171fc1b 96 return mavlink_msg_servo_output_raw_pack(system_id, component_id, msg, servo_output_raw->servo1_raw, servo_output_raw->servo2_raw, servo_output_raw->servo3_raw, servo_output_raw->servo4_raw, servo_output_raw->servo5_raw, servo_output_raw->servo6_raw, servo_output_raw->servo7_raw, servo_output_raw->servo8_raw);
shimniok 0:826c6171fc1b 97 }
shimniok 0:826c6171fc1b 98
shimniok 0:826c6171fc1b 99 /**
shimniok 0:826c6171fc1b 100 * @brief Send a servo_output_raw message
shimniok 0:826c6171fc1b 101 * @param chan MAVLink channel to send the message
shimniok 0:826c6171fc1b 102 *
shimniok 0:826c6171fc1b 103 * @param servo1_raw Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 104 * @param servo2_raw Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 105 * @param servo3_raw Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 106 * @param servo4_raw Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 107 * @param servo5_raw Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 108 * @param servo6_raw Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 109 * @param servo7_raw Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 110 * @param servo8_raw Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 111 */
shimniok 0:826c6171fc1b 112 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
shimniok 0:826c6171fc1b 113
shimniok 0:826c6171fc1b 114 static inline void mavlink_msg_servo_output_raw_send(mavlink_channel_t chan, uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, uint16_t servo7_raw, uint16_t servo8_raw)
shimniok 0:826c6171fc1b 115 {
shimniok 0:826c6171fc1b 116 mavlink_message_t msg;
shimniok 0:826c6171fc1b 117 mavlink_msg_servo_output_raw_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, servo1_raw, servo2_raw, servo3_raw, servo4_raw, servo5_raw, servo6_raw, servo7_raw, servo8_raw);
shimniok 0:826c6171fc1b 118 mavlink_send_uart(chan, &msg);
shimniok 0:826c6171fc1b 119 }
shimniok 0:826c6171fc1b 120
shimniok 0:826c6171fc1b 121 #endif
shimniok 0:826c6171fc1b 122 // MESSAGE SERVO_OUTPUT_RAW UNPACKING
shimniok 0:826c6171fc1b 123
shimniok 0:826c6171fc1b 124 /**
shimniok 0:826c6171fc1b 125 * @brief Get field servo1_raw from servo_output_raw message
shimniok 0:826c6171fc1b 126 *
shimniok 0:826c6171fc1b 127 * @return Servo output 1 value, in microseconds
shimniok 0:826c6171fc1b 128 */
shimniok 0:826c6171fc1b 129 static inline uint16_t mavlink_msg_servo_output_raw_get_servo1_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 130 {
shimniok 0:826c6171fc1b 131 generic_16bit r;
shimniok 0:826c6171fc1b 132 r.b[1] = (msg->payload)[0];
shimniok 0:826c6171fc1b 133 r.b[0] = (msg->payload)[1];
shimniok 0:826c6171fc1b 134 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 135 }
shimniok 0:826c6171fc1b 136
shimniok 0:826c6171fc1b 137 /**
shimniok 0:826c6171fc1b 138 * @brief Get field servo2_raw from servo_output_raw message
shimniok 0:826c6171fc1b 139 *
shimniok 0:826c6171fc1b 140 * @return Servo output 2 value, in microseconds
shimniok 0:826c6171fc1b 141 */
shimniok 0:826c6171fc1b 142 static inline uint16_t mavlink_msg_servo_output_raw_get_servo2_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 143 {
shimniok 0:826c6171fc1b 144 generic_16bit r;
shimniok 0:826c6171fc1b 145 r.b[1] = (msg->payload+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 146 r.b[0] = (msg->payload+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 147 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 148 }
shimniok 0:826c6171fc1b 149
shimniok 0:826c6171fc1b 150 /**
shimniok 0:826c6171fc1b 151 * @brief Get field servo3_raw from servo_output_raw message
shimniok 0:826c6171fc1b 152 *
shimniok 0:826c6171fc1b 153 * @return Servo output 3 value, in microseconds
shimniok 0:826c6171fc1b 154 */
shimniok 0:826c6171fc1b 155 static inline uint16_t mavlink_msg_servo_output_raw_get_servo3_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 156 {
shimniok 0:826c6171fc1b 157 generic_16bit r;
shimniok 0:826c6171fc1b 158 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 159 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 160 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 161 }
shimniok 0:826c6171fc1b 162
shimniok 0:826c6171fc1b 163 /**
shimniok 0:826c6171fc1b 164 * @brief Get field servo4_raw from servo_output_raw message
shimniok 0:826c6171fc1b 165 *
shimniok 0:826c6171fc1b 166 * @return Servo output 4 value, in microseconds
shimniok 0:826c6171fc1b 167 */
shimniok 0:826c6171fc1b 168 static inline uint16_t mavlink_msg_servo_output_raw_get_servo4_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 169 {
shimniok 0:826c6171fc1b 170 generic_16bit r;
shimniok 0:826c6171fc1b 171 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 172 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 173 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 174 }
shimniok 0:826c6171fc1b 175
shimniok 0:826c6171fc1b 176 /**
shimniok 0:826c6171fc1b 177 * @brief Get field servo5_raw from servo_output_raw message
shimniok 0:826c6171fc1b 178 *
shimniok 0:826c6171fc1b 179 * @return Servo output 5 value, in microseconds
shimniok 0:826c6171fc1b 180 */
shimniok 0:826c6171fc1b 181 static inline uint16_t mavlink_msg_servo_output_raw_get_servo5_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 182 {
shimniok 0:826c6171fc1b 183 generic_16bit r;
shimniok 0:826c6171fc1b 184 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 185 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 186 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 187 }
shimniok 0:826c6171fc1b 188
shimniok 0:826c6171fc1b 189 /**
shimniok 0:826c6171fc1b 190 * @brief Get field servo6_raw from servo_output_raw message
shimniok 0:826c6171fc1b 191 *
shimniok 0:826c6171fc1b 192 * @return Servo output 6 value, in microseconds
shimniok 0:826c6171fc1b 193 */
shimniok 0:826c6171fc1b 194 static inline uint16_t mavlink_msg_servo_output_raw_get_servo6_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 195 {
shimniok 0:826c6171fc1b 196 generic_16bit r;
shimniok 0:826c6171fc1b 197 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 198 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 199 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 200 }
shimniok 0:826c6171fc1b 201
shimniok 0:826c6171fc1b 202 /**
shimniok 0:826c6171fc1b 203 * @brief Get field servo7_raw from servo_output_raw message
shimniok 0:826c6171fc1b 204 *
shimniok 0:826c6171fc1b 205 * @return Servo output 7 value, in microseconds
shimniok 0:826c6171fc1b 206 */
shimniok 0:826c6171fc1b 207 static inline uint16_t mavlink_msg_servo_output_raw_get_servo7_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 208 {
shimniok 0:826c6171fc1b 209 generic_16bit r;
shimniok 0:826c6171fc1b 210 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 211 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 212 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 213 }
shimniok 0:826c6171fc1b 214
shimniok 0:826c6171fc1b 215 /**
shimniok 0:826c6171fc1b 216 * @brief Get field servo8_raw from servo_output_raw message
shimniok 0:826c6171fc1b 217 *
shimniok 0:826c6171fc1b 218 * @return Servo output 8 value, in microseconds
shimniok 0:826c6171fc1b 219 */
shimniok 0:826c6171fc1b 220 static inline uint16_t mavlink_msg_servo_output_raw_get_servo8_raw(const mavlink_message_t* msg)
shimniok 0:826c6171fc1b 221 {
shimniok 0:826c6171fc1b 222 generic_16bit r;
shimniok 0:826c6171fc1b 223 r.b[1] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[0];
shimniok 0:826c6171fc1b 224 r.b[0] = (msg->payload+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(uint16_t))[1];
shimniok 0:826c6171fc1b 225 return (uint16_t)r.s;
shimniok 0:826c6171fc1b 226 }
shimniok 0:826c6171fc1b 227
shimniok 0:826c6171fc1b 228 /**
shimniok 0:826c6171fc1b 229 * @brief Decode a servo_output_raw message into a struct
shimniok 0:826c6171fc1b 230 *
shimniok 0:826c6171fc1b 231 * @param msg The message to decode
shimniok 0:826c6171fc1b 232 * @param servo_output_raw C-struct to decode the message contents into
shimniok 0:826c6171fc1b 233 */
shimniok 0:826c6171fc1b 234 static inline void mavlink_msg_servo_output_raw_decode(const mavlink_message_t* msg, mavlink_servo_output_raw_t* servo_output_raw)
shimniok 0:826c6171fc1b 235 {
shimniok 0:826c6171fc1b 236 servo_output_raw->servo1_raw = mavlink_msg_servo_output_raw_get_servo1_raw(msg);
shimniok 0:826c6171fc1b 237 servo_output_raw->servo2_raw = mavlink_msg_servo_output_raw_get_servo2_raw(msg);
shimniok 0:826c6171fc1b 238 servo_output_raw->servo3_raw = mavlink_msg_servo_output_raw_get_servo3_raw(msg);
shimniok 0:826c6171fc1b 239 servo_output_raw->servo4_raw = mavlink_msg_servo_output_raw_get_servo4_raw(msg);
shimniok 0:826c6171fc1b 240 servo_output_raw->servo5_raw = mavlink_msg_servo_output_raw_get_servo5_raw(msg);
shimniok 0:826c6171fc1b 241 servo_output_raw->servo6_raw = mavlink_msg_servo_output_raw_get_servo6_raw(msg);
shimniok 0:826c6171fc1b 242 servo_output_raw->servo7_raw = mavlink_msg_servo_output_raw_get_servo7_raw(msg);
shimniok 0:826c6171fc1b 243 servo_output_raw->servo8_raw = mavlink_msg_servo_output_raw_get_servo8_raw(msg);
shimniok 0:826c6171fc1b 244 }