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.cpp
Views: 1798
1
#include "AP_DAL_Beacon.h"
2
3
#if AP_BEACON_ENABLED
4
5
#include <AP_Logger/AP_Logger.h>
6
#include "AP_DAL.h"
7
#include <AP_Vehicle/AP_Vehicle_Type.h>
8
9
AP_DAL_Beacon::AP_DAL_Beacon()
10
{
11
#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone) && !APM_BUILD_TYPE(APM_BUILD_Replay)
12
const auto *bcon = AP::beacon();
13
_RBCH.count = bcon->count();
14
for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {
15
_RBCI[i].instance = i;
16
}
17
#endif
18
}
19
20
void AP_DAL_Beacon::start_frame()
21
{
22
const auto *bcon = AP::beacon();
23
24
const log_RBCH old = _RBCH;
25
if (bcon != nullptr) {
26
_RBCH.get_vehicle_position_ned_returncode = bcon->get_vehicle_position_ned(_RBCH.vehicle_position_ned, _RBCH.accuracy_estimate);
27
Location loc;
28
_RBCH.get_origin_returncode = bcon->get_origin(loc);
29
_RBCH.enabled = bcon->enabled();
30
_RBCH.origin_lat = loc.lat;
31
_RBCH.origin_lng = loc.lng;
32
_RBCH.origin_alt = loc.alt;
33
}
34
WRITE_REPLAY_BLOCK_IFCHANGED(RBCH, _RBCH, old);
35
if (bcon == nullptr) {
36
return;
37
}
38
39
for (uint8_t i=0; i<ARRAY_SIZE(_RBCI); i++) {
40
log_RBCI &RBCI = _RBCI[i];
41
const log_RBCI old_RBCI = RBCI;
42
RBCI.last_update_ms = bcon->beacon_last_update_ms(i);
43
RBCI.position = bcon->beacon_position(i);
44
RBCI.distance = bcon->beacon_distance(i);
45
RBCI.healthy = bcon->beacon_healthy(i);
46
47
WRITE_REPLAY_BLOCK_IFCHANGED(RBCI, RBCI, old_RBCI);
48
}
49
}
50
51
#endif
52
53