2017-02-03 00:36:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#include "AP_Proximity_config.h"
|
|
|
|
|
|
|
|
#if AP_PROXIMITY_TERARANGERTOWER_ENABLED
|
|
|
|
|
2019-12-04 01:02:27 -04:00
|
|
|
#include "AP_Proximity_Backend_Serial.h"
|
2017-02-03 00:36:03 -04:00
|
|
|
|
|
|
|
#define PROXIMITY_TRTOWER_TIMEOUT_MS 300 // requests timeout after 0.3 seconds
|
|
|
|
|
2019-12-04 01:02:27 -04:00
|
|
|
class AP_Proximity_TeraRangerTower : public AP_Proximity_Backend_Serial
|
2017-02-03 00:36:03 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-12-04 01:02:27 -04:00
|
|
|
using AP_Proximity_Backend_Serial::AP_Proximity_Backend_Serial;
|
2017-02-03 00:36:03 -04:00
|
|
|
|
|
|
|
// update state
|
2018-11-07 07:01:30 -04:00
|
|
|
void update(void) override;
|
2017-02-03 00:36:03 -04:00
|
|
|
|
|
|
|
// get maximum and minimum distances (in meters) of sensor
|
2018-11-07 07:01:30 -04:00
|
|
|
float distance_max() const override;
|
|
|
|
float distance_min() const override;
|
2017-02-03 00:36:03 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// check and process replies from sensor
|
|
|
|
bool read_sensor_data();
|
2022-05-10 09:17:20 -03:00
|
|
|
void update_sector_data(int16_t angle_deg, uint16_t distance_mm);
|
2017-02-03 00:36:03 -04:00
|
|
|
|
|
|
|
// reply related variables
|
|
|
|
uint8_t buffer[20]; // buffer where to store data from serial
|
|
|
|
uint8_t buffer_count;
|
|
|
|
|
|
|
|
// request related variables
|
|
|
|
uint32_t _last_distance_received_ms; // system time of last distance measurement received from sensor
|
|
|
|
};
|
2021-03-25 04:32:09 -03:00
|
|
|
|
2023-04-05 09:25:54 -03:00
|
|
|
#endif // AP_PROXIMITY_TERARANGERTOWER_ENABLED
|