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.h
Views: 1798
1
#pragma once
2
3
#include <AP_Logger/LogStructure.h>
4
5
#include <AP_Compass/AP_Compass.h>
6
7
class AP_DAL_Compass {
8
public:
9
10
// Compass-like methods:
11
bool use_for_yaw(uint8_t i) const {
12
return _RMGI[i].use_for_yaw;
13
}
14
15
bool healthy(uint8_t i) const {
16
return _RMGI[i].healthy;
17
}
18
19
const Vector3f &get_offsets(uint8_t i) const {
20
return _RMGI[i].offsets;
21
}
22
23
bool have_scale_factor(uint8_t i) const {
24
return _RMGI[i].have_scale_factor;
25
}
26
27
bool auto_declination_enabled() const {
28
return _RMGH.auto_declination_enabled;
29
}
30
31
uint8_t get_count() const {
32
return _RMGH.count;
33
}
34
35
float get_declination() const {
36
return _RMGH.declination;
37
}
38
39
bool available() const {
40
return _RMGH.available;
41
}
42
43
// return the number of enabled sensors
44
uint8_t get_num_enabled(void) const { return _RMGH.num_enabled; }
45
46
// learn offsets accessor
47
bool learn_offsets_enabled() const { return _RMGH.learn_offsets_enabled; }
48
49
// return last update time in microseconds
50
uint32_t last_update_usec(uint8_t i) const { return _RMGI[i].last_update_usec; }
51
52
/// Return the current field as a Vector3f in milligauss
53
const Vector3f &get_field(uint8_t i) const { return _RMGI[i].field; }
54
55
// check if the compasses are pointing in the same direction
56
bool consistent() const { return _RMGH.consistent; }
57
58
// returns first usable compass
59
uint8_t get_first_usable() const { return _RMGH.first_usable; }
60
61
// AP_DAL methods:
62
AP_DAL_Compass();
63
64
void start_frame();
65
66
void handle_message(const log_RMGH &msg) {
67
_RMGH = msg;
68
}
69
void handle_message(const log_RMGI &msg) {
70
_RMGI[msg.instance] = msg;
71
}
72
73
private:
74
75
struct log_RMGH _RMGH;
76
struct log_RMGI _RMGI[COMPASS_MAX_INSTANCES];
77
};
78
79