Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : #pragma once 16 : 17 : #include "AP_Beacon.h" 18 : 19 : #if AP_BEACON_ENABLED 20 : 21 : #include <AP_Common/AP_Common.h> 22 : #include <AP_Math/AP_Math.h> 23 : #include <AP_HAL/AP_HAL.h> 24 : 25 : class AP_Beacon_Backend 26 : { 27 : public: 28 : // constructor. This incorporates initialisation as well. 29 : AP_Beacon_Backend(AP_Beacon &frontend); 30 : 31 : // return true if sensor is basically healthy (we are receiving data) 32 : virtual bool healthy() = 0; 33 : 34 : // update 35 : virtual void update() = 0; 36 : 37 : // set vehicle position 38 : // pos should be in meters in NED frame from the beacon's local origin 39 : // accuracy_estimate is also in meters 40 : void set_vehicle_position(const Vector3f& pos, float accuracy_estimate); 41 : 42 : // set individual beacon distance from vehicle in meters in NED frame 43 : void set_beacon_distance(uint8_t beacon_instance, float distance); 44 : 45 : // set beacon's position 46 : // pos should be in meters in NED from the beacon's local origin 47 : void set_beacon_position(uint8_t beacon_instance, const Vector3f& pos); 48 : 49 30597 : float get_beacon_origin_lat(void) const { return _frontend.origin_lat; } 50 30597 : float get_beacon_origin_lon(void) const { return _frontend.origin_lon; } 51 30597 : float get_beacon_origin_alt(void) const { return _frontend.origin_alt; } 52 : 53 : protected: 54 : 55 : // references 56 : AP_Beacon &_frontend; 57 : 58 : // yaw correction 59 : int16_t orient_yaw_deg; // cached version of orient_yaw parameter 60 : float orient_cos_yaw = 0.0f; 61 : float orient_sin_yaw = 1.0f; 62 : 63 : // yaw correction methods 64 : Vector3f correct_for_orient_yaw(const Vector3f &vector); 65 : 66 : AP_HAL::UARTDriver *uart; 67 : }; 68 : 69 : #endif // AP_BEACON_ENABLED