Line data Source code
1 : #pragma once 2 : 3 : #include "AP_Proximity_config.h" 4 : 5 : #if AP_PROXIMITY_MAV_ENABLED 6 : 7 : #include "AP_Proximity_Backend.h" 8 : 9 : class AP_Proximity_MAV : public AP_Proximity_Backend 10 : { 11 : 12 : public: 13 : // constructor 14 : using AP_Proximity_Backend::AP_Proximity_Backend; 15 : 16 : // update state 17 : void update(void) override; 18 : 19 : // get maximum and minimum distances (in meters) of sensor 20 14506 : float distance_max_m() const override { return _distance_max; } 21 1426 : float distance_min_m() const override { return _distance_min; }; 22 : 23 : // get distance upwards in meters. returns true on success 24 : bool get_upward_distance(float &distance) const override; 25 : 26 : // handle mavlink messages 27 : void handle_msg(const mavlink_message_t &msg) override; 28 : 29 : private: 30 : 31 : // handle mavlink DISTANCE_SENSOR messages 32 : void handle_distance_sensor_msg(const mavlink_message_t &msg); 33 : // handle mavlink OBSTACLE_DISTANCE messages 34 : void handle_obstacle_distance_msg(const mavlink_message_t &msg); 35 : // handle mavlink OBSTACLE_DISTANCE_3D messages 36 : void handle_obstacle_distance_3d_msg(const mavlink_message_t &msg); 37 : 38 : AP_Proximity_Temp_Boundary temp_boundary; 39 : 40 : // horizontal distance support 41 : uint32_t _last_update_ms; // system time of last mavlink message received 42 : uint32_t _last_msg_update_timestamp_ms; // last stored mavlink message timestamp 43 : float _distance_max; // max range of sensor in meters 44 : float _distance_min; // min range of sensor in meters 45 : 46 : // upward distance support 47 : uint32_t _last_upward_update_ms; // system time of last update of upward distance 48 : float _distance_upward; // upward distance in meters 49 : }; 50 : 51 : #endif // AP_PROXIMITY_MAV_ENABLED