2017-02-03 00:36:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Proximity.h"
|
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();
|
|
|
|
void update_sector_data(int16_t angle_deg, uint16_t distance_cm);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|