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_Compass/AP_Compass_ExternalAHRS.cpp
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
16
#include <AP_HAL/AP_HAL.h>
17
#include "AP_Compass_ExternalAHRS.h"
18
19
#if AP_COMPASS_EXTERNALAHRS_ENABLED
20
21
AP_Compass_ExternalAHRS::AP_Compass_ExternalAHRS(uint8_t port)
22
{
23
auto devid = AP_HAL::Device::make_bus_id(AP_HAL::Device::BUS_TYPE_SERIAL,port,0,0);
24
register_compass(devid, instance);
25
26
set_dev_id(instance, devid);
27
set_external(instance, true);
28
}
29
30
void AP_Compass_ExternalAHRS::handle_external(const AP_ExternalAHRS::mag_data_message_t &pkt)
31
{
32
Vector3f field = pkt.field;
33
accumulate_sample(field, instance);
34
}
35
36
void AP_Compass_ExternalAHRS::read(void)
37
{
38
drain_accumulated_samples(instance);
39
}
40
41
#endif // AP_COMPASS_EXTERNALAHRS_ENABLED
42
43