AP_RangeFinder_Benewake.h 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "RangeFinder.h"
  3. #include "RangeFinder_Backend.h"
  4. class AP_RangeFinder_Benewake : public AP_RangeFinder_Backend
  5. {
  6. public:
  7. enum benewake_model_type {
  8. BENEWAKE_TF02 = 0,
  9. BENEWAKE_TFmini = 1
  10. };
  11. // constructor
  12. AP_RangeFinder_Benewake(RangeFinder::RangeFinder_State &_state,
  13. AP_RangeFinder_Params &_params,
  14. uint8_t serial_instance,
  15. benewake_model_type model);
  16. // static detection function
  17. static bool detect(uint8_t serial_instance);
  18. // update state
  19. void update(void) override;
  20. protected:
  21. virtual MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
  22. return MAV_DISTANCE_SENSOR_LASER;
  23. }
  24. private:
  25. // get a reading
  26. // distance returned in reading_cm
  27. bool get_reading(uint16_t &reading_cm);
  28. AP_HAL::UARTDriver *uart = nullptr;
  29. benewake_model_type model_type;
  30. uint8_t linebuf[10];
  31. uint8_t linebuf_len;
  32. };