123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_HAL/AP_HAL.h>
- #include <AP_Param/AP_Param.h>
- #include <AP_Math/AP_Math.h>
- #include <AP_SerialManager/AP_SerialManager.h>
- #include <AP_Common/Location.h>
- class AP_Beacon_Backend;
- #define AP_BEACON_MAX_BEACONS 4
- #define AP_BEACON_TIMEOUT_MS 300
- #define AP_BEACON_MINIMUM_FENCE_BEACONS 3
- class AP_Beacon
- {
- public:
- friend class AP_Beacon_Backend;
- AP_Beacon(AP_SerialManager &_serial_manager);
-
- static AP_Beacon *get_singleton() { return _singleton; }
-
- enum AP_BeaconType {
- AP_BeaconType_None = 0,
- AP_BeaconType_Pozyx = 1,
- AP_BeaconType_Marvelmind = 2,
- AP_BeaconType_SITL = 10
- };
-
- struct BeaconState {
- uint16_t id;
- bool healthy;
- float distance;
- uint32_t distance_update_ms;
- Vector3f position;
- };
-
- void init(void);
-
- bool enabled(void);
-
- bool healthy(void);
-
- void update(void);
-
- bool get_origin(Location &origin_loc) const;
-
- bool get_vehicle_position_ned(Vector3f& pos, float& accuracy_estimate) const;
-
- uint8_t count() const;
-
-
- bool get_beacon_data(uint8_t beacon_instance, struct BeaconState& state) const;
-
- uint8_t beacon_id(uint8_t beacon_instance) const;
-
- bool beacon_healthy(uint8_t beacon_instance) const;
-
- float beacon_distance(uint8_t beacon_instance) const;
-
- Vector3f beacon_position(uint8_t beacon_instance) const;
-
- uint32_t beacon_last_update_ms(uint8_t beacon_instance) const;
-
- void update_boundary_points();
-
- const Vector2f* get_boundary_points(uint16_t& num_points) const;
- static const struct AP_Param::GroupInfo var_info[];
- private:
- static AP_Beacon *_singleton;
-
- bool device_ready(void) const;
-
-
-
-
-
-
- static bool get_next_boundary_point(const Vector2f* boundary, uint8_t num_points, uint8_t current_index, float start_angle, uint8_t& next_index, float& next_angle);
-
- AP_Int8 _type;
- AP_Float origin_lat;
- AP_Float origin_lon;
- AP_Float origin_alt;
- AP_Int16 orient_yaw;
-
- AP_Beacon_Backend *_driver;
- AP_SerialManager &serial_manager;
-
- Vector3f veh_pos_ned;
- float veh_pos_accuracy;
- uint32_t veh_pos_update_ms;
-
- uint8_t num_beacons = 0;
- BeaconState beacon_state[AP_BEACON_MAX_BEACONS];
-
- Vector2f boundary[AP_BEACON_MAX_BEACONS+1];
- uint8_t boundary_num_points;
- uint8_t boundary_num_beacons;
- };
- namespace AP {
- AP_Beacon *beacon();
- };
|