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_Compass.cpp
Views: 1798
1
#include "AP_DAL_Compass.h"
2
3
#include <AP_Compass/AP_Compass.h>
4
5
#include <AP_Logger/AP_Logger.h>
6
#include "AP_DAL.h"
7
8
AP_DAL_Compass::AP_DAL_Compass()
9
{
10
for (uint8_t i=0; i<ARRAY_SIZE(_RMGI); i++) {
11
_RMGI[i].instance = i;
12
}
13
}
14
15
void AP_DAL_Compass::start_frame()
16
{
17
const auto &compass = AP::compass();
18
19
const log_RMGH old = _RMGH;
20
_RMGH.available = compass.available();
21
_RMGH.count = compass.get_count();
22
_RMGH.auto_declination_enabled = compass.auto_declination_enabled();
23
_RMGH.declination = compass.get_declination();
24
_RMGH.num_enabled = compass.get_num_enabled();
25
_RMGH.consistent = compass.consistent();
26
_RMGH.first_usable = compass.get_first_usable();
27
_RMGH.learn_offsets_enabled = compass.learn_offsets_enabled();
28
29
WRITE_REPLAY_BLOCK_IFCHANGED(RMGH, _RMGH, old);
30
31
for (uint8_t i=0; i<_RMGH.count; i++) {
32
log_RMGI &RMGI = _RMGI[i];
33
const log_RMGI old_RMGI = RMGI;
34
RMGI.use_for_yaw = compass.use_for_yaw(i);
35
RMGI.healthy = compass.healthy(i);
36
RMGI.offsets = compass.get_offsets(i);
37
RMGI.have_scale_factor = compass.have_scale_factor(i);
38
RMGI.last_update_usec = compass.last_update_usec(i);
39
RMGI.field = compass.get_field(i);
40
41
WRITE_REPLAY_BLOCK_IFCHANGED(RMGI, RMGI, old_RMGI);
42
}
43
}
44
45