#pragma once // MESSAGE FW_FOLLOW PACKING #define MAVLINK_MSG_ID_FW_FOLLOW 145 typedef struct __mavlink_fw_follow_t { uint32_t timestamp; /*< [ms] Timestamp (time since system boot).*/ int32_t lat; /*< [degE7] Latitude (WGS84)*/ int32_t lon; /*< [degE7] Longitude (WGS84)*/ float vel[2]; /*< [m/s] target velocity (0,0) for unknown*/ float attitude[2]; /*< (roll yaw for unknown)*/ uint8_t custom_state; /*< button states or switches of a tracker device*/ } mavlink_fw_follow_t; #define MAVLINK_MSG_ID_FW_FOLLOW_LEN 29 #define MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN 29 #define MAVLINK_MSG_ID_145_LEN 29 #define MAVLINK_MSG_ID_145_MIN_LEN 29 #define MAVLINK_MSG_ID_FW_FOLLOW_CRC 145 #define MAVLINK_MSG_ID_145_CRC 145 #define MAVLINK_MSG_FW_FOLLOW_FIELD_VEL_LEN 2 #define MAVLINK_MSG_FW_FOLLOW_FIELD_ATTITUDE_LEN 2 #if MAVLINK_COMMAND_24BIT #define MAVLINK_MESSAGE_INFO_FW_FOLLOW { \ 145, \ "FW_FOLLOW", \ 6, \ { { "timestamp", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_fw_follow_t, timestamp) }, \ { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_fw_follow_t, lat) }, \ { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_fw_follow_t, lon) }, \ { "vel", NULL, MAVLINK_TYPE_FLOAT, 2, 12, offsetof(mavlink_fw_follow_t, vel) }, \ { "attitude", NULL, MAVLINK_TYPE_FLOAT, 2, 20, offsetof(mavlink_fw_follow_t, attitude) }, \ { "custom_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_fw_follow_t, custom_state) }, \ } \ } #else #define MAVLINK_MESSAGE_INFO_FW_FOLLOW { \ "FW_FOLLOW", \ 6, \ { { "timestamp", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_fw_follow_t, timestamp) }, \ { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_fw_follow_t, lat) }, \ { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_fw_follow_t, lon) }, \ { "vel", NULL, MAVLINK_TYPE_FLOAT, 2, 12, offsetof(mavlink_fw_follow_t, vel) }, \ { "attitude", NULL, MAVLINK_TYPE_FLOAT, 2, 20, offsetof(mavlink_fw_follow_t, attitude) }, \ { "custom_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 28, offsetof(mavlink_fw_follow_t, custom_state) }, \ } \ } #endif /** * @brief Pack a fw_follow 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 timestamp [ms] Timestamp (time since system boot). * @param lat [degE7] Latitude (WGS84) * @param lon [degE7] Longitude (WGS84) * @param vel [m/s] target velocity (0,0) for unknown * @param attitude (roll yaw for unknown) * @param custom_state button states or switches of a tracker device * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_fw_follow_pack(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg, uint32_t timestamp, int32_t lat, int32_t lon, const float *vel, const float *attitude, uint8_t custom_state) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_FW_FOLLOW_LEN]; _mav_put_uint32_t(buf, 0, timestamp); _mav_put_int32_t(buf, 4, lat); _mav_put_int32_t(buf, 8, lon); _mav_put_uint8_t(buf, 28, custom_state); _mav_put_float_array(buf, 12, vel, 2); _mav_put_float_array(buf, 20, attitude, 2); memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FW_FOLLOW_LEN); #else mavlink_fw_follow_t packet; packet.timestamp = timestamp; packet.lat = lat; packet.lon = lon; packet.custom_state = custom_state; mav_array_memcpy(packet.vel, vel, sizeof(float)*2); mav_array_memcpy(packet.attitude, attitude, sizeof(float)*2); memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FW_FOLLOW_LEN); #endif msg->msgid = MAVLINK_MSG_ID_FW_FOLLOW; return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); } /** * @brief Pack a fw_follow message on a channel * @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 will be sent over * @param msg The MAVLink message to compress the data into * @param timestamp [ms] Timestamp (time since system boot). * @param lat [degE7] Latitude (WGS84) * @param lon [degE7] Longitude (WGS84) * @param vel [m/s] target velocity (0,0) for unknown * @param attitude (roll yaw for unknown) * @param custom_state button states or switches of a tracker device * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_fw_follow_pack_chan(uint16_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint32_t timestamp,int32_t lat,int32_t lon,const float *vel,const float *attitude,uint8_t custom_state) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_FW_FOLLOW_LEN]; _mav_put_uint32_t(buf, 0, timestamp); _mav_put_int32_t(buf, 4, lat); _mav_put_int32_t(buf, 8, lon); _mav_put_uint8_t(buf, 28, custom_state); _mav_put_float_array(buf, 12, vel, 2); _mav_put_float_array(buf, 20, attitude, 2); memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FW_FOLLOW_LEN); #else mavlink_fw_follow_t packet; packet.timestamp = timestamp; packet.lat = lat; packet.lon = lon; packet.custom_state = custom_state; mav_array_memcpy(packet.vel, vel, sizeof(float)*2); mav_array_memcpy(packet.attitude, attitude, sizeof(float)*2); memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FW_FOLLOW_LEN); #endif msg->msgid = MAVLINK_MSG_ID_FW_FOLLOW; return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); } /** * @brief Encode a fw_follow struct * * @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 fw_follow C-struct to read the message contents from */ static inline uint16_t mavlink_msg_fw_follow_encode(uint16_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_fw_follow_t* fw_follow) { return mavlink_msg_fw_follow_pack(system_id, component_id, msg, fw_follow->timestamp, fw_follow->lat, fw_follow->lon, fw_follow->vel, fw_follow->attitude, fw_follow->custom_state); } /** * @brief Encode a fw_follow struct on a channel * * @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 will be sent over * @param msg The MAVLink message to compress the data into * @param fw_follow C-struct to read the message contents from */ static inline uint16_t mavlink_msg_fw_follow_encode_chan(uint16_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_fw_follow_t* fw_follow) { return mavlink_msg_fw_follow_pack_chan(system_id, component_id, chan, msg, fw_follow->timestamp, fw_follow->lat, fw_follow->lon, fw_follow->vel, fw_follow->attitude, fw_follow->custom_state); } /** * @brief Send a fw_follow message * @param chan MAVLink channel to send the message * * @param timestamp [ms] Timestamp (time since system boot). * @param lat [degE7] Latitude (WGS84) * @param lon [degE7] Longitude (WGS84) * @param vel [m/s] target velocity (0,0) for unknown * @param attitude (roll yaw for unknown) * @param custom_state button states or switches of a tracker device */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS static inline void mavlink_msg_fw_follow_send(mavlink_channel_t chan, uint32_t timestamp, int32_t lat, int32_t lon, const float *vel, const float *attitude, uint8_t custom_state) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char buf[MAVLINK_MSG_ID_FW_FOLLOW_LEN]; _mav_put_uint32_t(buf, 0, timestamp); _mav_put_int32_t(buf, 4, lat); _mav_put_int32_t(buf, 8, lon); _mav_put_uint8_t(buf, 28, custom_state); _mav_put_float_array(buf, 12, vel, 2); _mav_put_float_array(buf, 20, attitude, 2); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FW_FOLLOW, buf, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); #else mavlink_fw_follow_t packet; packet.timestamp = timestamp; packet.lat = lat; packet.lon = lon; packet.custom_state = custom_state; mav_array_memcpy(packet.vel, vel, sizeof(float)*2); mav_array_memcpy(packet.attitude, attitude, sizeof(float)*2); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FW_FOLLOW, (const char *)&packet, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); #endif } /** * @brief Send a fw_follow message * @param chan MAVLink channel to send the message * @param struct The MAVLink struct to serialize */ static inline void mavlink_msg_fw_follow_send_struct(mavlink_channel_t chan, const mavlink_fw_follow_t* fw_follow) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS mavlink_msg_fw_follow_send(chan, fw_follow->timestamp, fw_follow->lat, fw_follow->lon, fw_follow->vel, fw_follow->attitude, fw_follow->custom_state); #else _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FW_FOLLOW, (const char *)fw_follow, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); #endif } #if MAVLINK_MSG_ID_FW_FOLLOW_LEN <= MAVLINK_MAX_PAYLOAD_LEN /* This varient of _send() can be used to save stack space by re-using memory from the receive buffer. The caller provides a mavlink_message_t which is the size of a full mavlink message. This is usually the receive buffer for the channel, and allows a reply to an incoming message with minimum stack space usage. */ static inline void mavlink_msg_fw_follow_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t timestamp, int32_t lat, int32_t lon, const float *vel, const float *attitude, uint8_t custom_state) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS char *buf = (char *)msgbuf; _mav_put_uint32_t(buf, 0, timestamp); _mav_put_int32_t(buf, 4, lat); _mav_put_int32_t(buf, 8, lon); _mav_put_uint8_t(buf, 28, custom_state); _mav_put_float_array(buf, 12, vel, 2); _mav_put_float_array(buf, 20, attitude, 2); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FW_FOLLOW, buf, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); #else mavlink_fw_follow_t *packet = (mavlink_fw_follow_t *)msgbuf; packet->timestamp = timestamp; packet->lat = lat; packet->lon = lon; packet->custom_state = custom_state; mav_array_memcpy(packet->vel, vel, sizeof(float)*2); mav_array_memcpy(packet->attitude, attitude, sizeof(float)*2); _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FW_FOLLOW, (const char *)packet, MAVLINK_MSG_ID_FW_FOLLOW_MIN_LEN, MAVLINK_MSG_ID_FW_FOLLOW_LEN, MAVLINK_MSG_ID_FW_FOLLOW_CRC); #endif } #endif #endif // MESSAGE FW_FOLLOW UNPACKING /** * @brief Get field timestamp from fw_follow message * * @return [ms] Timestamp (time since system boot). */ static inline uint32_t mavlink_msg_fw_follow_get_timestamp(const mavlink_message_t* msg) { return _MAV_RETURN_uint32_t(msg, 0); } /** * @brief Get field lat from fw_follow message * * @return [degE7] Latitude (WGS84) */ static inline int32_t mavlink_msg_fw_follow_get_lat(const mavlink_message_t* msg) { return _MAV_RETURN_int32_t(msg, 4); } /** * @brief Get field lon from fw_follow message * * @return [degE7] Longitude (WGS84) */ static inline int32_t mavlink_msg_fw_follow_get_lon(const mavlink_message_t* msg) { return _MAV_RETURN_int32_t(msg, 8); } /** * @brief Get field vel from fw_follow message * * @return [m/s] target velocity (0,0) for unknown */ static inline uint16_t mavlink_msg_fw_follow_get_vel(const mavlink_message_t* msg, float *vel) { return _MAV_RETURN_float_array(msg, vel, 2, 12); } /** * @brief Get field attitude from fw_follow message * * @return (roll yaw for unknown) */ static inline uint16_t mavlink_msg_fw_follow_get_attitude(const mavlink_message_t* msg, float *attitude) { return _MAV_RETURN_float_array(msg, attitude, 2, 20); } /** * @brief Get field custom_state from fw_follow message * * @return button states or switches of a tracker device */ static inline uint8_t mavlink_msg_fw_follow_get_custom_state(const mavlink_message_t* msg) { return _MAV_RETURN_uint8_t(msg, 28); } /** * @brief Decode a fw_follow message into a struct * * @param msg The message to decode * @param fw_follow C-struct to decode the message contents into */ static inline void mavlink_msg_fw_follow_decode(const mavlink_message_t* msg, mavlink_fw_follow_t* fw_follow) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS fw_follow->timestamp = mavlink_msg_fw_follow_get_timestamp(msg); fw_follow->lat = mavlink_msg_fw_follow_get_lat(msg); fw_follow->lon = mavlink_msg_fw_follow_get_lon(msg); mavlink_msg_fw_follow_get_vel(msg, fw_follow->vel); mavlink_msg_fw_follow_get_attitude(msg, fw_follow->attitude); fw_follow->custom_state = mavlink_msg_fw_follow_get_custom_state(msg); #else uint8_t len = msg->len < MAVLINK_MSG_ID_FW_FOLLOW_LEN? msg->len : MAVLINK_MSG_ID_FW_FOLLOW_LEN; memset(fw_follow, 0, MAVLINK_MSG_ID_FW_FOLLOW_LEN); memcpy(fw_follow, _MAV_PAYLOAD(msg), len); #endif }