Line data Source code
1 : #pragma once 2 : 3 : #include <AP_Beacon/AP_Beacon.h> 4 : 5 : #if AP_BEACON_ENABLED 6 : 7 : #include <AP_Logger/LogStructure.h> 8 : 9 : class AP_DAL_Beacon { 10 : public: 11 : 12 : // Beacon-like methods: 13 67802 : uint8_t count() const { 14 67802 : return _RBCH.count; 15 : } 16 : 17 6 : bool get_origin(Location &loc) const { 18 6 : loc.zero(); 19 6 : loc.lat = _RBCH.origin_lat; 20 6 : loc.lng = _RBCH.origin_lng; 21 6 : loc.alt = _RBCH.origin_alt; 22 6 : return _RBCH.get_origin_returncode; 23 : } 24 : 25 : // return beacon enabled 26 0 : bool enabled(void) const { 27 0 : return _RBCH.enabled; 28 : } 29 : 30 : // return beacon health 31 108603 : bool beacon_healthy(uint8_t i) const { 32 108603 : return _RBCI[i].healthy; 33 : } 34 : 35 : // return last update time from beacon in milliseconds 36 162794 : uint32_t beacon_last_update_ms(uint8_t i) const { 37 162794 : return _RBCI[i].last_update_ms; 38 : } 39 : 40 : // return distance to beacon in meters 41 54191 : float beacon_distance(uint8_t i) const { 42 54191 : return _RBCI[i].distance; 43 : } 44 : 45 : // return NED position of beacon in meters relative to the beacon systems origin 46 54191 : const Vector3f &beacon_position(uint8_t i) const { 47 54191 : return _RBCI[i].position; 48 : } 49 : 50 : // return vehicle position in NED from position estimate system's origin in meters 51 67794 : bool get_vehicle_position_ned(Vector3f& pos, float& accuracy_estimate) const { 52 67794 : pos = _RBCH.vehicle_position_ned; 53 67794 : accuracy_estimate = _RBCH.accuracy_estimate; 54 67794 : return _RBCH.get_vehicle_position_ned_returncode; 55 : } 56 : 57 : // AP_DAL methods: 58 : AP_DAL_Beacon(); 59 : 60 : AP_DAL_Beacon *beacon() { 61 : return this; 62 : } 63 : 64 : void start_frame(); 65 : 66 : void handle_message(const log_RBCH &msg) { 67 : _RBCH = msg; 68 : } 69 : void handle_message(const log_RBCI &msg) { 70 : _RBCI[msg.instance] = msg; 71 : } 72 : 73 : private: 74 : 75 : struct log_RBCH _RBCH; 76 : struct log_RBCI _RBCI[AP_BEACON_MAX_BEACONS]; 77 : }; 78 : 79 : #endif // AP_BEACON_ENABLED