123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_HAL/AP_HAL.h>
- #include "AP_Proximity.h"
- #include <AP_Common/Location.h>
- #define PROXIMITY_SECTORS_MAX 12
- #define PROXIMITY_BOUNDARY_DIST_MIN 0.6f
- #define PROXIMITY_BOUNDARY_DIST_DEFAULT 100
- class AP_Proximity_Backend
- {
- public:
-
- AP_Proximity_Backend(AP_Proximity &_frontend, AP_Proximity::Proximity_State &_state);
-
-
- virtual ~AP_Proximity_Backend(void) {}
-
- virtual void update() = 0;
-
- virtual float distance_max() const = 0;
- virtual float distance_min() const = 0;
-
- virtual bool get_upward_distance(float &distance) const { return false; }
-
- virtual void handle_msg(const mavlink_message_t &msg) {}
-
-
- bool get_horizontal_distance(float angle_deg, float &distance) const;
-
-
- const Vector2f* get_boundary_points(uint16_t& num_points) const;
-
-
- bool get_closest_object(float& angle_deg, float &distance) const;
-
- uint8_t get_object_count() const;
- bool get_object_angle_and_distance(uint8_t object_number, float& angle_deg, float &distance) const;
-
- bool get_horizontal_distances(AP_Proximity::Proximity_Distance_Array &prx_dist_array) const;
- protected:
-
- void set_status(AP_Proximity::Proximity_Status status);
-
- bool convert_angle_to_sector(float angle_degrees, uint8_t §or) const;
-
-
- void init_boundary();
-
-
-
- void update_boundary_for_sector(const uint8_t sector, const bool push_to_OA_DB);
-
- uint8_t get_ignore_area_count() const;
- bool get_ignore_area(uint8_t index, uint16_t &angle_deg, uint8_t &width_deg) const;
- bool get_next_ignore_start_or_end(uint8_t start_or_end, int16_t start_angle, int16_t &ignore_start) const;
-
- bool database_prepare_for_push(Location ¤t_loc, float ¤t_vehicle_bearing);
- void database_push(const float angle, const float distance);
- void database_push(const float angle, const float distance, const uint32_t timestamp_ms, const Location ¤t_loc, const float current_vehicle_bearing);
- AP_Proximity &frontend;
- AP_Proximity::Proximity_State &state;
-
- uint8_t _num_sectors = PROXIMITY_MAX_DIRECTION;
- uint16_t _sector_middle_deg[PROXIMITY_SECTORS_MAX] = {0, 45, 90, 135, 180, 225, 270, 315, 0, 0, 0, 0};
- uint8_t _sector_width_deg[PROXIMITY_SECTORS_MAX] = {45, 45, 45, 45, 45, 45, 45, 45, 0, 0, 0, 0};
-
- float _angle[PROXIMITY_SECTORS_MAX];
- float _distance[PROXIMITY_SECTORS_MAX];
- bool _distance_valid[PROXIMITY_SECTORS_MAX];
-
- Vector2f _sector_edge_vector[PROXIMITY_SECTORS_MAX];
- Vector2f _boundary_point[PROXIMITY_SECTORS_MAX];
- };
|