2020-11-05 19:22:38 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_Logger/LogStructure.h>
|
|
|
|
|
|
|
|
#include <AP_Beacon/AP_Beacon.h>
|
|
|
|
|
|
|
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
|
|
|
|
|
|
|
class AP_DAL_Beacon {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Beacon-like methods:
|
2020-11-06 21:01:09 -04:00
|
|
|
uint8_t count() const {
|
2020-11-05 19:22:38 -04:00
|
|
|
return _RBCH.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get_origin(Location &loc) const {
|
2020-11-06 20:46:04 -04:00
|
|
|
loc.zero();
|
|
|
|
loc.lat = _RBCH.origin_lat;
|
|
|
|
loc.lng = _RBCH.origin_lng;
|
|
|
|
loc.alt = _RBCH.origin_alt;
|
2020-11-05 19:22:38 -04:00
|
|
|
return _RBCH.get_origin_returncode;
|
|
|
|
}
|
|
|
|
|
2020-11-08 21:28:58 -04:00
|
|
|
// return beacon enabled
|
|
|
|
bool enabled(void) const {
|
|
|
|
return _RBCH.enabled;
|
|
|
|
}
|
|
|
|
|
2020-11-05 19:22:38 -04:00
|
|
|
// return beacon health
|
|
|
|
bool beacon_healthy(uint8_t i) const {
|
|
|
|
return _RBCI[i].healthy;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return last update time from beacon in milliseconds
|
|
|
|
uint32_t beacon_last_update_ms(uint8_t i) const {
|
|
|
|
return _RBCI[i].last_update_ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return distance to beacon in meters
|
|
|
|
float beacon_distance(uint8_t i) const {
|
|
|
|
return _RBCI[i].distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return NED position of beacon in meters relative to the beacon systems origin
|
|
|
|
const Vector3f &beacon_position(uint8_t i) const {
|
|
|
|
return _RBCI[i].position;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return vehicle position in NED from position estimate system's origin in meters
|
|
|
|
bool get_vehicle_position_ned(Vector3f& pos, float& accuracy_estimate) const {
|
|
|
|
pos = _RBCH.vehicle_position_ned;
|
|
|
|
accuracy_estimate = _RBCH.accuracy_estimate;
|
|
|
|
return _RBCH.get_vehicle_position_ned_returncode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// AP_DAL methods:
|
|
|
|
AP_DAL_Beacon();
|
|
|
|
|
|
|
|
AP_DAL_Beacon *beacon() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void start_frame();
|
|
|
|
|
|
|
|
void handle_message(const log_RBCH &msg) {
|
|
|
|
_RBCH = msg;
|
2020-11-07 18:31:09 -04:00
|
|
|
}
|
2020-11-05 19:22:38 -04:00
|
|
|
void handle_message(const log_RBCI &msg) {
|
|
|
|
_RBCI[msg.instance] = msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct log_RBCH _RBCH;
|
|
|
|
struct log_RBCI _RBCI[AP_BEACON_MAX_BEACONS];
|
|
|
|
};
|