Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Beacon/AP_Beacon.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/14#pragma once1516#include "AP_Beacon_config.h"1718#if AP_BEACON_ENABLED1920#include <AP_Common/AP_Common.h>21#include <AP_Param/AP_Param.h>22#include <AP_Math/AP_Math.h>23#include <AP_Common/Location.h>2425class AP_Beacon_Backend;2627class AP_Beacon28{29public:30friend class AP_Beacon_Backend;3132AP_Beacon();3334// get singleton instance35static AP_Beacon *get_singleton() { return _singleton; }3637// external position backend types (used by _TYPE parameter)38enum class Type : uint8_t {39None = 0,40Pozyx = 1,41Marvelmind = 2,42Nooploop = 3,43#if AP_BEACON_SITL_ENABLED44SITL = 1045#endif46};4748// The AP_BeaconState structure is filled in by the backend driver49struct BeaconState {50uint16_t id; // unique id of beacon51bool healthy; // true if beacon is healthy52float distance; // distance from vehicle to beacon (in meters)53uint32_t distance_update_ms; // system time of last update from this beacon54Vector3f position; // location of beacon as an offset from origin in NED in meters55};5657// initialise any available position estimators58void init(void);5960// return true if beacon feature is enabled61bool enabled(void) const;6263// return true if sensor is basically healthy (we are receiving data)64bool healthy(void) const;6566// update state of all beacons67void update(void);6869// return origin of position estimate system in lat/lon70bool get_origin(Location &origin_loc) const;7172// return vehicle position in NED from position estimate system's origin in meters73bool get_vehicle_position_ned(Vector3f& pos, float& accuracy_estimate) const;7475// return the number of beacons76uint8_t count() const;7778// methods to return beacon specific information7980// return all beacon data81bool get_beacon_data(uint8_t beacon_instance, struct BeaconState& state) const;8283// return individual beacon's id84uint8_t beacon_id(uint8_t beacon_instance) const;8586// return beacon health87bool beacon_healthy(uint8_t beacon_instance) const;8889// return distance to beacon in meters90float beacon_distance(uint8_t beacon_instance) const;9192// return NED position of beacon in meters relative to the beacon systems origin93Vector3f beacon_position(uint8_t beacon_instance) const;9495// return last update time from beacon in milliseconds96uint32_t beacon_last_update_ms(uint8_t beacon_instance) const;9798// update fence boundary array99void update_boundary_points();100101// return fence boundary array102const Vector2f* get_boundary_points(uint16_t& num_points) const;103104static const struct AP_Param::GroupInfo var_info[];105106// a method for vehicles to call to make onboard log messages:107void log();108109private:110111static AP_Beacon *_singleton;112113// check if device is ready114bool device_ready(void) const;115116// find next boundary point from an array of boundary points given the current index into that array117// returns true if a next point can be found118// current_index should be an index into the boundary_pts array119// start_angle is an angle (in radians), the search will sweep clockwise from this angle120// the index of the next point is returned in the next_index argument121// the angle to the next point is returned in the next_angle argument122static 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);123124// parameters125AP_Enum<Type> _type;126AP_Float origin_lat;127AP_Float origin_lon;128AP_Float origin_alt;129AP_Int16 orient_yaw;130131// external references132AP_Beacon_Backend *_driver;133134// last known position135Vector3f veh_pos_ned;136float veh_pos_accuracy;137uint32_t veh_pos_update_ms;138139// individual beacon data140uint8_t num_beacons = 0;141BeaconState beacon_state[AP_BEACON_MAX_BEACONS];142143// fence boundary144Vector2f boundary[AP_BEACON_MAX_BEACONS+1]; // array of boundary points (used for fence)145uint8_t boundary_num_points; // number of points in boundary146uint8_t boundary_num_beacons; // total number of beacon points consumed while building boundary147};148149namespace AP {150AP_Beacon *beacon();151};152153#endif // AP_BEACON_ENABLED154155156