CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_DAL/AP_DAL_Beacon.h
Views: 1798
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
uint8_t count() const {
14
return _RBCH.count;
15
}
16
17
bool get_origin(Location &loc) const {
18
loc.zero();
19
loc.lat = _RBCH.origin_lat;
20
loc.lng = _RBCH.origin_lng;
21
loc.alt = _RBCH.origin_alt;
22
return _RBCH.get_origin_returncode;
23
}
24
25
// return beacon enabled
26
bool enabled(void) const {
27
return _RBCH.enabled;
28
}
29
30
// return beacon health
31
bool beacon_healthy(uint8_t i) const {
32
return _RBCI[i].healthy;
33
}
34
35
// return last update time from beacon in milliseconds
36
uint32_t beacon_last_update_ms(uint8_t i) const {
37
return _RBCI[i].last_update_ms;
38
}
39
40
// return distance to beacon in meters
41
float beacon_distance(uint8_t i) const {
42
return _RBCI[i].distance;
43
}
44
45
// return NED position of beacon in meters relative to the beacon systems origin
46
const Vector3f &beacon_position(uint8_t i) const {
47
return _RBCI[i].position;
48
}
49
50
// return vehicle position in NED from position estimate system's origin in meters
51
bool get_vehicle_position_ned(Vector3f& pos, float& accuracy_estimate) const {
52
pos = _RBCH.vehicle_position_ned;
53
accuracy_estimate = _RBCH.accuracy_estimate;
54
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
80
81