AP_Proximity_TeraRangerTower.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "AP_Proximity.h"
  3. #include "AP_Proximity_Backend.h"
  4. #define PROXIMITY_TRTOWER_TIMEOUT_MS 300 // requests timeout after 0.3 seconds
  5. class AP_Proximity_TeraRangerTower : public AP_Proximity_Backend
  6. {
  7. public:
  8. // constructor
  9. AP_Proximity_TeraRangerTower(AP_Proximity &_frontend, AP_Proximity::Proximity_State &_state, AP_SerialManager &serial_manager);
  10. // static detection function
  11. static bool detect(AP_SerialManager &serial_manager);
  12. // update state
  13. void update(void) override;
  14. // get maximum and minimum distances (in meters) of sensor
  15. float distance_max() const override;
  16. float distance_min() const override;
  17. private:
  18. // check and process replies from sensor
  19. bool read_sensor_data();
  20. void update_sector_data(int16_t angle_deg, uint16_t distance_cm);
  21. // reply related variables
  22. AP_HAL::UARTDriver *uart = nullptr;
  23. uint8_t buffer[20]; // buffer where to store data from serial
  24. uint8_t buffer_count;
  25. // request related variables
  26. uint32_t _last_distance_received_ms; // system time of last distance measurement received from sensor
  27. };