uavcan.equipment.range_sensor.Measurement.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #include <uavcan.CoarseOrientation.h>
  6. #include <uavcan.Timestamp.h>
  7. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_MAX_SIZE 15
  8. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SIGNATURE (0x68FFFE70FC771952ULL)
  9. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_ID 1050
  10. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SENSOR_TYPE_UNDEFINED 0
  11. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SENSOR_TYPE_SONAR 1
  12. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SENSOR_TYPE_LIDAR 2
  13. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SENSOR_TYPE_RADAR 3
  14. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_READING_TYPE_UNDEFINED 0
  15. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_READING_TYPE_VALID_RANGE 1
  16. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_READING_TYPE_TOO_CLOSE 2
  17. #define UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_READING_TYPE_TOO_FAR 3
  18. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  19. class uavcan_equipment_range_sensor_Measurement_cxx_iface;
  20. #endif
  21. struct uavcan_equipment_range_sensor_Measurement {
  22. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  23. using cxx_iface = uavcan_equipment_range_sensor_Measurement_cxx_iface;
  24. #endif
  25. struct uavcan_Timestamp timestamp;
  26. uint8_t sensor_id;
  27. struct uavcan_CoarseOrientation beam_orientation_in_body_frame;
  28. float field_of_view;
  29. uint8_t sensor_type;
  30. uint8_t reading_type;
  31. float range;
  32. };
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. uint32_t _uavcan_equipment_range_sensor_Measurement_encode(struct uavcan_equipment_range_sensor_Measurement* msg, uint8_t* buffer
  38. #if CANARD_ENABLE_TAO_OPTION
  39. , bool tao
  40. #endif
  41. );
  42. bool _uavcan_equipment_range_sensor_Measurement_decode(const CanardRxTransfer* transfer, struct uavcan_equipment_range_sensor_Measurement* msg);
  43. static inline uint32_t uavcan_equipment_range_sensor_Measurement_encode(struct uavcan_equipment_range_sensor_Measurement* msg, uint8_t* buffer
  44. #if CANARD_ENABLE_TAO_OPTION
  45. , bool tao
  46. #endif
  47. ) {
  48. return _uavcan_equipment_range_sensor_Measurement_encode(msg, buffer
  49. #if CANARD_ENABLE_TAO_OPTION
  50. , tao
  51. #endif
  52. );
  53. }
  54. static inline bool uavcan_equipment_range_sensor_Measurement_decode(const CanardRxTransfer* transfer, struct uavcan_equipment_range_sensor_Measurement* msg) {
  55. return _uavcan_equipment_range_sensor_Measurement_decode(transfer, msg);
  56. }
  57. #if defined(CANARD_DSDLC_INTERNAL)
  58. static inline void __uavcan_equipment_range_sensor_Measurement_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_equipment_range_sensor_Measurement* msg, bool tao);
  59. static inline bool __uavcan_equipment_range_sensor_Measurement_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_equipment_range_sensor_Measurement* msg, bool tao);
  60. void __uavcan_equipment_range_sensor_Measurement_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_equipment_range_sensor_Measurement* msg, bool tao) {
  61. (void)buffer;
  62. (void)bit_ofs;
  63. (void)msg;
  64. (void)tao;
  65. __uavcan_Timestamp_encode(buffer, bit_ofs, &msg->timestamp, false);
  66. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->sensor_id);
  67. *bit_ofs += 8;
  68. __uavcan_CoarseOrientation_encode(buffer, bit_ofs, &msg->beam_orientation_in_body_frame, false);
  69. {
  70. uint16_t float16_val = canardConvertNativeFloatToFloat16(msg->field_of_view);
  71. canardEncodeScalar(buffer, *bit_ofs, 16, &float16_val);
  72. }
  73. *bit_ofs += 16;
  74. canardEncodeScalar(buffer, *bit_ofs, 5, &msg->sensor_type);
  75. *bit_ofs += 5;
  76. canardEncodeScalar(buffer, *bit_ofs, 3, &msg->reading_type);
  77. *bit_ofs += 3;
  78. {
  79. uint16_t float16_val = canardConvertNativeFloatToFloat16(msg->range);
  80. canardEncodeScalar(buffer, *bit_ofs, 16, &float16_val);
  81. }
  82. *bit_ofs += 16;
  83. }
  84. /*
  85. decode uavcan_equipment_range_sensor_Measurement, return true on failure, false on success
  86. */
  87. bool __uavcan_equipment_range_sensor_Measurement_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_equipment_range_sensor_Measurement* msg, bool tao) {
  88. (void)transfer;
  89. (void)bit_ofs;
  90. (void)msg;
  91. (void)tao;
  92. if (__uavcan_Timestamp_decode(transfer, bit_ofs, &msg->timestamp, false)) {return true;}
  93. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->sensor_id);
  94. *bit_ofs += 8;
  95. if (__uavcan_CoarseOrientation_decode(transfer, bit_ofs, &msg->beam_orientation_in_body_frame, false)) {return true;}
  96. {
  97. uint16_t float16_val;
  98. canardDecodeScalar(transfer, *bit_ofs, 16, true, &float16_val);
  99. msg->field_of_view = canardConvertFloat16ToNativeFloat(float16_val);
  100. }
  101. *bit_ofs += 16;
  102. canardDecodeScalar(transfer, *bit_ofs, 5, false, &msg->sensor_type);
  103. *bit_ofs += 5;
  104. canardDecodeScalar(transfer, *bit_ofs, 3, false, &msg->reading_type);
  105. *bit_ofs += 3;
  106. {
  107. uint16_t float16_val;
  108. canardDecodeScalar(transfer, *bit_ofs, 16, true, &float16_val);
  109. msg->range = canardConvertFloat16ToNativeFloat(float16_val);
  110. }
  111. *bit_ofs += 16;
  112. return false; /* success */
  113. }
  114. #endif
  115. #ifdef CANARD_DSDLC_TEST_BUILD
  116. struct uavcan_equipment_range_sensor_Measurement sample_uavcan_equipment_range_sensor_Measurement_msg(void);
  117. #endif
  118. #ifdef __cplusplus
  119. } // extern "C"
  120. #ifdef DRONECAN_CXX_WRAPPERS
  121. #include <canard/cxx_wrappers.h>
  122. BROADCAST_MESSAGE_CXX_IFACE(uavcan_equipment_range_sensor_Measurement, UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_ID, UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_SIGNATURE, UAVCAN_EQUIPMENT_RANGE_SENSOR_MEASUREMENT_MAX_SIZE);
  123. #endif
  124. #endif