AP_RangeFinder_UAVCAN.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "RangeFinder_Backend.h"
  3. #if HAL_WITH_UAVCAN
  4. #include <AP_UAVCAN/AP_UAVCAN.h>
  5. class MeasurementCb;
  6. class AP_RangeFinder_UAVCAN : public AP_RangeFinder_Backend {
  7. public:
  8. AP_RangeFinder_UAVCAN(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
  9. void update() override;
  10. static void subscribe_msgs(AP_UAVCAN* ap_uavcan);
  11. static AP_RangeFinder_UAVCAN* get_uavcan_backend(AP_UAVCAN* ap_uavcan, uint8_t node_id, uint8_t address, bool create_new);
  12. static AP_RangeFinder_Backend* detect(RangeFinder::RangeFinder_State &_state, AP_RangeFinder_Params &_params);
  13. static void handle_measurement(AP_UAVCAN* ap_uavcan, uint8_t node_id, const MeasurementCb &cb);
  14. protected:
  15. virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
  16. return _sensor_type;
  17. }
  18. private:
  19. uint8_t _instance;
  20. RangeFinder::RangeFinder_Status _status;
  21. uint16_t _distance_cm;
  22. uint32_t _last_reading_ms;
  23. AP_UAVCAN* _ap_uavcan;
  24. uint8_t _node_id;
  25. bool new_data;
  26. MAV_DISTANCE_SENSOR _sensor_type;
  27. };
  28. #endif //HAL_WITH_UAVCAN