/libraries/GCS_MAVLink/include_v1.0/common/mavlink_msg_object_detection_event.h

https://github.com/arktools/ardupilotone · C Header · 270 lines · 153 code · 24 blank · 93 comment · 3 complexity · b3fe3be35204af3f01dbff7570e1d91c MD5 · raw file

  1. // MESSAGE OBJECT_DETECTION_EVENT PACKING
  2. #define MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT 140
  3. typedef struct __mavlink_object_detection_event_t
  4. {
  5. uint32_t time; ///< Timestamp in milliseconds since system boot
  6. float bearing; ///< Angle of the object with respect to the body frame in NED coordinates in radians. 0: front
  7. float distance; ///< Ground distance in meters
  8. uint16_t object_id; ///< Object ID
  9. uint8_t type; ///< Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal
  10. char name[20]; ///< Name of the object as defined by the detector
  11. uint8_t quality; ///< Detection quality / confidence. 0: bad, 255: maximum confidence
  12. } mavlink_object_detection_event_t;
  13. #define MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT_LEN 36
  14. #define MAVLINK_MSG_ID_140_LEN 36
  15. #define MAVLINK_MSG_OBJECT_DETECTION_EVENT_FIELD_NAME_LEN 20
  16. #define MAVLINK_MESSAGE_INFO_OBJECT_DETECTION_EVENT { \
  17. "OBJECT_DETECTION_EVENT", \
  18. 7, \
  19. { { "time", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_object_detection_event_t, time) }, \
  20. { "bearing", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_object_detection_event_t, bearing) }, \
  21. { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_object_detection_event_t, distance) }, \
  22. { "object_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_object_detection_event_t, object_id) }, \
  23. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_object_detection_event_t, type) }, \
  24. { "name", NULL, MAVLINK_TYPE_CHAR, 20, 15, offsetof(mavlink_object_detection_event_t, name) }, \
  25. { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_object_detection_event_t, quality) }, \
  26. } \
  27. }
  28. /**
  29. * @brief Pack a object_detection_event message
  30. * @param system_id ID of this system
  31. * @param component_id ID of this component (e.g. 200 for IMU)
  32. * @param msg The MAVLink message to compress the data into
  33. *
  34. * @param time Timestamp in milliseconds since system boot
  35. * @param object_id Object ID
  36. * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal
  37. * @param name Name of the object as defined by the detector
  38. * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence
  39. * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front
  40. * @param distance Ground distance in meters
  41. * @return length of the message in bytes (excluding serial stream start sign)
  42. */
  43. static inline uint16_t mavlink_msg_object_detection_event_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  44. uint32_t time, uint16_t object_id, uint8_t type, const char *name, uint8_t quality, float bearing, float distance)
  45. {
  46. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  47. char buf[36];
  48. _mav_put_uint32_t(buf, 0, time);
  49. _mav_put_float(buf, 4, bearing);
  50. _mav_put_float(buf, 8, distance);
  51. _mav_put_uint16_t(buf, 12, object_id);
  52. _mav_put_uint8_t(buf, 14, type);
  53. _mav_put_uint8_t(buf, 35, quality);
  54. _mav_put_char_array(buf, 15, name, 20);
  55. memcpy(_MAV_PAYLOAD(msg), buf, 36);
  56. #else
  57. mavlink_object_detection_event_t packet;
  58. packet.time = time;
  59. packet.bearing = bearing;
  60. packet.distance = distance;
  61. packet.object_id = object_id;
  62. packet.type = type;
  63. packet.quality = quality;
  64. mav_array_memcpy(packet.name, name, sizeof(char)*20);
  65. memcpy(_MAV_PAYLOAD(msg), &packet, 36);
  66. #endif
  67. msg->msgid = MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT;
  68. return mavlink_finalize_message(msg, system_id, component_id, 36, 179);
  69. }
  70. /**
  71. * @brief Pack a object_detection_event message on a channel
  72. * @param system_id ID of this system
  73. * @param component_id ID of this component (e.g. 200 for IMU)
  74. * @param chan The MAVLink channel this message was sent over
  75. * @param msg The MAVLink message to compress the data into
  76. * @param time Timestamp in milliseconds since system boot
  77. * @param object_id Object ID
  78. * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal
  79. * @param name Name of the object as defined by the detector
  80. * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence
  81. * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front
  82. * @param distance Ground distance in meters
  83. * @return length of the message in bytes (excluding serial stream start sign)
  84. */
  85. static inline uint16_t mavlink_msg_object_detection_event_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  86. mavlink_message_t* msg,
  87. uint32_t time,uint16_t object_id,uint8_t type,const char *name,uint8_t quality,float bearing,float distance)
  88. {
  89. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  90. char buf[36];
  91. _mav_put_uint32_t(buf, 0, time);
  92. _mav_put_float(buf, 4, bearing);
  93. _mav_put_float(buf, 8, distance);
  94. _mav_put_uint16_t(buf, 12, object_id);
  95. _mav_put_uint8_t(buf, 14, type);
  96. _mav_put_uint8_t(buf, 35, quality);
  97. _mav_put_char_array(buf, 15, name, 20);
  98. memcpy(_MAV_PAYLOAD(msg), buf, 36);
  99. #else
  100. mavlink_object_detection_event_t packet;
  101. packet.time = time;
  102. packet.bearing = bearing;
  103. packet.distance = distance;
  104. packet.object_id = object_id;
  105. packet.type = type;
  106. packet.quality = quality;
  107. mav_array_memcpy(packet.name, name, sizeof(char)*20);
  108. memcpy(_MAV_PAYLOAD(msg), &packet, 36);
  109. #endif
  110. msg->msgid = MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT;
  111. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 36, 179);
  112. }
  113. /**
  114. * @brief Encode a object_detection_event struct into a message
  115. *
  116. * @param system_id ID of this system
  117. * @param component_id ID of this component (e.g. 200 for IMU)
  118. * @param msg The MAVLink message to compress the data into
  119. * @param object_detection_event C-struct to read the message contents from
  120. */
  121. static inline uint16_t mavlink_msg_object_detection_event_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_object_detection_event_t* object_detection_event)
  122. {
  123. return mavlink_msg_object_detection_event_pack(system_id, component_id, msg, object_detection_event->time, object_detection_event->object_id, object_detection_event->type, object_detection_event->name, object_detection_event->quality, object_detection_event->bearing, object_detection_event->distance);
  124. }
  125. /**
  126. * @brief Send a object_detection_event message
  127. * @param chan MAVLink channel to send the message
  128. *
  129. * @param time Timestamp in milliseconds since system boot
  130. * @param object_id Object ID
  131. * @param type Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal
  132. * @param name Name of the object as defined by the detector
  133. * @param quality Detection quality / confidence. 0: bad, 255: maximum confidence
  134. * @param bearing Angle of the object with respect to the body frame in NED coordinates in radians. 0: front
  135. * @param distance Ground distance in meters
  136. */
  137. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  138. static inline void mavlink_msg_object_detection_event_send(mavlink_channel_t chan, uint32_t time, uint16_t object_id, uint8_t type, const char *name, uint8_t quality, float bearing, float distance)
  139. {
  140. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  141. char buf[36];
  142. _mav_put_uint32_t(buf, 0, time);
  143. _mav_put_float(buf, 4, bearing);
  144. _mav_put_float(buf, 8, distance);
  145. _mav_put_uint16_t(buf, 12, object_id);
  146. _mav_put_uint8_t(buf, 14, type);
  147. _mav_put_uint8_t(buf, 35, quality);
  148. _mav_put_char_array(buf, 15, name, 20);
  149. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT, buf, 36, 179);
  150. #else
  151. mavlink_object_detection_event_t packet;
  152. packet.time = time;
  153. packet.bearing = bearing;
  154. packet.distance = distance;
  155. packet.object_id = object_id;
  156. packet.type = type;
  157. packet.quality = quality;
  158. mav_array_memcpy(packet.name, name, sizeof(char)*20);
  159. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OBJECT_DETECTION_EVENT, (const char *)&packet, 36, 179);
  160. #endif
  161. }
  162. #endif
  163. // MESSAGE OBJECT_DETECTION_EVENT UNPACKING
  164. /**
  165. * @brief Get field time from object_detection_event message
  166. *
  167. * @return Timestamp in milliseconds since system boot
  168. */
  169. static inline uint32_t mavlink_msg_object_detection_event_get_time(const mavlink_message_t* msg)
  170. {
  171. return _MAV_RETURN_uint32_t(msg, 0);
  172. }
  173. /**
  174. * @brief Get field object_id from object_detection_event message
  175. *
  176. * @return Object ID
  177. */
  178. static inline uint16_t mavlink_msg_object_detection_event_get_object_id(const mavlink_message_t* msg)
  179. {
  180. return _MAV_RETURN_uint16_t(msg, 12);
  181. }
  182. /**
  183. * @brief Get field type from object_detection_event message
  184. *
  185. * @return Object type: 0: image, 1: letter, 2: ground vehicle, 3: air vehicle, 4: surface vehicle, 5: sub-surface vehicle, 6: human, 7: animal
  186. */
  187. static inline uint8_t mavlink_msg_object_detection_event_get_type(const mavlink_message_t* msg)
  188. {
  189. return _MAV_RETURN_uint8_t(msg, 14);
  190. }
  191. /**
  192. * @brief Get field name from object_detection_event message
  193. *
  194. * @return Name of the object as defined by the detector
  195. */
  196. static inline uint16_t mavlink_msg_object_detection_event_get_name(const mavlink_message_t* msg, char *name)
  197. {
  198. return _MAV_RETURN_char_array(msg, name, 20, 15);
  199. }
  200. /**
  201. * @brief Get field quality from object_detection_event message
  202. *
  203. * @return Detection quality / confidence. 0: bad, 255: maximum confidence
  204. */
  205. static inline uint8_t mavlink_msg_object_detection_event_get_quality(const mavlink_message_t* msg)
  206. {
  207. return _MAV_RETURN_uint8_t(msg, 35);
  208. }
  209. /**
  210. * @brief Get field bearing from object_detection_event message
  211. *
  212. * @return Angle of the object with respect to the body frame in NED coordinates in radians. 0: front
  213. */
  214. static inline float mavlink_msg_object_detection_event_get_bearing(const mavlink_message_t* msg)
  215. {
  216. return _MAV_RETURN_float(msg, 4);
  217. }
  218. /**
  219. * @brief Get field distance from object_detection_event message
  220. *
  221. * @return Ground distance in meters
  222. */
  223. static inline float mavlink_msg_object_detection_event_get_distance(const mavlink_message_t* msg)
  224. {
  225. return _MAV_RETURN_float(msg, 8);
  226. }
  227. /**
  228. * @brief Decode a object_detection_event message into a struct
  229. *
  230. * @param msg The message to decode
  231. * @param object_detection_event C-struct to decode the message contents into
  232. */
  233. static inline void mavlink_msg_object_detection_event_decode(const mavlink_message_t* msg, mavlink_object_detection_event_t* object_detection_event)
  234. {
  235. #if MAVLINK_NEED_BYTE_SWAP
  236. object_detection_event->time = mavlink_msg_object_detection_event_get_time(msg);
  237. object_detection_event->bearing = mavlink_msg_object_detection_event_get_bearing(msg);
  238. object_detection_event->distance = mavlink_msg_object_detection_event_get_distance(msg);
  239. object_detection_event->object_id = mavlink_msg_object_detection_event_get_object_id(msg);
  240. object_detection_event->type = mavlink_msg_object_detection_event_get_type(msg);
  241. mavlink_msg_object_detection_event_get_name(msg, object_detection_event->name);
  242. object_detection_event->quality = mavlink_msg_object_detection_event_get_quality(msg);
  243. #else
  244. memcpy(object_detection_event, _MAV_PAYLOAD(msg), 36);
  245. #endif
  246. }