2016-12-23 02:03:21 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Proximity_Backend.h"
|
|
|
|
|
2021-03-25 04:32:09 -03:00
|
|
|
#if HAL_PROXIMITY_ENABLED
|
|
|
|
|
2016-12-23 02:03:21 -04:00
|
|
|
class AP_Proximity_MAV : public AP_Proximity_Backend
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor
|
2019-09-27 06:33:18 -03:00
|
|
|
using AP_Proximity_Backend::AP_Proximity_Backend;
|
2016-12-23 02:03:21 -04:00
|
|
|
|
|
|
|
// update state
|
2018-11-07 07:01:30 -04:00
|
|
|
void update(void) override;
|
2016-12-23 02:03:21 -04:00
|
|
|
|
|
|
|
// get maximum and minimum distances (in meters) of sensor
|
2018-11-07 07:01:30 -04:00
|
|
|
float distance_max() const override { return _distance_max; }
|
|
|
|
float distance_min() const override { return _distance_min; };
|
2016-12-23 02:03:21 -04:00
|
|
|
|
2017-01-16 02:58:14 -04:00
|
|
|
// get distance upwards in meters. returns true on success
|
2018-11-07 07:01:30 -04:00
|
|
|
bool get_upward_distance(float &distance) const override;
|
2017-01-16 02:58:14 -04:00
|
|
|
|
2020-12-06 08:24:40 -04:00
|
|
|
// handle mavlink messages
|
2019-04-30 07:22:49 -03:00
|
|
|
void handle_msg(const mavlink_message_t &msg) override;
|
2016-12-23 02:03:21 -04:00
|
|
|
|
|
|
|
private:
|
2021-01-10 14:14:24 -04:00
|
|
|
|
|
|
|
// handle mavlink DISTANCE_SENSOR messages
|
|
|
|
void handle_distance_sensor_msg(const mavlink_message_t &msg);
|
|
|
|
// handle mavlink OBSTACLE_DISTANCE messages
|
|
|
|
void handle_obstacle_distance_msg(const mavlink_message_t &msg);
|
|
|
|
// handle mavlink OBSTACLE_DISTANCE_3D messages
|
|
|
|
void handle_obstacle_distance_3d_msg(const mavlink_message_t &msg);
|
|
|
|
|
2021-03-08 13:21:45 -04:00
|
|
|
AP_Proximity_Temp_Boundary temp_boundary;
|
|
|
|
|
2017-01-16 02:58:14 -04:00
|
|
|
// horizontal distance support
|
2020-12-06 08:24:40 -04:00
|
|
|
uint32_t _last_update_ms; // system time of last mavlink message received
|
2021-03-08 13:21:45 -04:00
|
|
|
uint32_t _last_msg_update_timestamp_ms; // last stored mavlink message timestamp
|
2016-12-23 02:03:21 -04:00
|
|
|
float _distance_max; // max range of sensor in meters
|
|
|
|
float _distance_min; // min range of sensor in meters
|
2017-01-16 02:58:14 -04:00
|
|
|
|
|
|
|
// upward distance support
|
2020-12-06 08:24:40 -04:00
|
|
|
uint32_t _last_upward_update_ms; // system time of last update of upward distance
|
2017-01-16 02:58:14 -04:00
|
|
|
float _distance_upward; // upward distance in meters
|
2016-12-23 02:03:21 -04:00
|
|
|
};
|
2021-03-25 04:32:09 -03:00
|
|
|
|
|
|
|
#endif // HAL_PROXIMITY_ENABLED
|