Line data Source code
1 : #pragma once 2 : 3 : #include "AP_Proximity_Backend.h" 4 : 5 : #if HAL_PROXIMITY_ENABLED && AP_SCRIPTING_ENABLED 6 : 7 : class AP_Proximity_Scripting : public AP_Proximity_Backend 8 : { 9 : 10 : public: 11 : // constructor 12 : using AP_Proximity_Backend::AP_Proximity_Backend; 13 : 14 : // update state 15 : void update(void) override; 16 : 17 : // get maximum and minimum distances (in meters) of sensor 18 0 : float distance_max_m() const override { return _distance_max; } 19 0 : float distance_min_m() const override { return _distance_min; } 20 : 21 : // Set max and min range of the sensor. only needs to be set once 22 : bool set_distance_min_max(float min, float max) override; 23 : 24 : // get distance upwards in meters. returns true on success 25 : bool get_upward_distance(float &distance) const override; 26 : 27 : // handle script messages 28 : bool handle_script_distance_msg(float dist_m, float yaw_deg, float pitch_deg, bool push_to_boundary) override; 29 : bool handle_script_3d_msg(const Vector3f &vec_to_obstacle, bool push_to_boundary) override; 30 : 31 : // update the temporary (buffer) boundary 32 : bool update_virtual_boundary() override; 33 : 34 : private: 35 : 36 : // temp boundary to store and sort distances 37 : AP_Proximity_Temp_Boundary temp_boundary; 38 : 39 : // horizontal distance support 40 : uint32_t _last_update_ms; // system time of last script message received 41 : 42 : // upward distance support 43 : uint32_t _last_upward_update_ms; // system time of last update of upward distance 44 : float _distance_upward; // upward distance in meters 45 : 46 : // min and max distance of sensor 47 : float _distance_min; 48 : float _distance_max; 49 : }; 50 : 51 : #endif // HAL_PROXIMITY_ENABLED && AP_SCRIPTING_ENABLED