uavcan.CoarseOrientation.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define UAVCAN_COARSEORIENTATION_MAX_SIZE 2
  6. #define UAVCAN_COARSEORIENTATION_SIGNATURE (0x271BA10B0DAC9E52ULL)
  7. #define UAVCAN_COARSEORIENTATION_ANGLE_MULTIPLIER 4.7746482927568605
  8. struct uavcan_CoarseOrientation {
  9. int8_t fixed_axis_roll_pitch_yaw[3];
  10. bool orientation_defined;
  11. };
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. uint32_t _uavcan_CoarseOrientation_encode(struct uavcan_CoarseOrientation* msg, uint8_t* buffer
  17. #if CANARD_ENABLE_TAO_OPTION
  18. , bool tao
  19. #endif
  20. );
  21. bool _uavcan_CoarseOrientation_decode(const CanardRxTransfer* transfer, struct uavcan_CoarseOrientation* msg);
  22. static inline uint32_t uavcan_CoarseOrientation_encode(struct uavcan_CoarseOrientation* msg, uint8_t* buffer
  23. #if CANARD_ENABLE_TAO_OPTION
  24. , bool tao
  25. #endif
  26. ) {
  27. return _uavcan_CoarseOrientation_encode(msg, buffer
  28. #if CANARD_ENABLE_TAO_OPTION
  29. , tao
  30. #endif
  31. );
  32. }
  33. static inline bool uavcan_CoarseOrientation_decode(const CanardRxTransfer* transfer, struct uavcan_CoarseOrientation* msg) {
  34. return _uavcan_CoarseOrientation_decode(transfer, msg);
  35. }
  36. #if defined(CANARD_DSDLC_INTERNAL)
  37. static inline void __uavcan_CoarseOrientation_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_CoarseOrientation* msg, bool tao);
  38. static inline bool __uavcan_CoarseOrientation_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_CoarseOrientation* msg, bool tao);
  39. void __uavcan_CoarseOrientation_encode(uint8_t* buffer, uint32_t* bit_ofs, struct uavcan_CoarseOrientation* msg, bool tao) {
  40. (void)buffer;
  41. (void)bit_ofs;
  42. (void)msg;
  43. (void)tao;
  44. for (size_t i=0; i < 3; i++) {
  45. canardEncodeScalar(buffer, *bit_ofs, 5, &msg->fixed_axis_roll_pitch_yaw[i]);
  46. *bit_ofs += 5;
  47. }
  48. canardEncodeScalar(buffer, *bit_ofs, 1, &msg->orientation_defined);
  49. *bit_ofs += 1;
  50. }
  51. /*
  52. decode uavcan_CoarseOrientation, return true on failure, false on success
  53. */
  54. bool __uavcan_CoarseOrientation_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct uavcan_CoarseOrientation* msg, bool tao) {
  55. (void)transfer;
  56. (void)bit_ofs;
  57. (void)msg;
  58. (void)tao;
  59. for (size_t i=0; i < 3; i++) {
  60. canardDecodeScalar(transfer, *bit_ofs, 5, true, &msg->fixed_axis_roll_pitch_yaw[i]);
  61. *bit_ofs += 5;
  62. }
  63. canardDecodeScalar(transfer, *bit_ofs, 1, false, &msg->orientation_defined);
  64. *bit_ofs += 1;
  65. return false; /* success */
  66. }
  67. #endif
  68. #ifdef CANARD_DSDLC_TEST_BUILD
  69. struct uavcan_CoarseOrientation sample_uavcan_CoarseOrientation_msg(void);
  70. #endif
  71. #ifdef __cplusplus
  72. } // extern "C"
  73. #ifdef DRONECAN_CXX_WRAPPERS
  74. #include <canard/cxx_wrappers.h>
  75. #endif
  76. #endif