Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/AntennaTracker/sensors.cpp
9642 views
1
#include "Tracker.h"
2
3
/*
4
update INS and attitude
5
*/
6
void Tracker::update_ahrs()
7
{
8
ahrs.update();
9
}
10
11
/*
12
read and update compass
13
*/
14
void Tracker::update_compass(void)
15
{
16
compass.read();
17
}
18
19
/*
20
read the GPS
21
*/
22
void Tracker::update_GPS(void)
23
{
24
gps.update();
25
26
static uint32_t last_gps_msg_ms;
27
static uint8_t ground_start_count = 5;
28
if (gps.last_message_time_ms() != last_gps_msg_ms &&
29
gps.status() >= AP_GPS::GPS_OK_FIX_3D) {
30
last_gps_msg_ms = gps.last_message_time_ms();
31
32
if (ground_start_count > 1) {
33
ground_start_count--;
34
} else if (ground_start_count == 1) {
35
// We countdown N number of good GPS fixes
36
// so that the altitude is more accurate
37
// -------------------------------------
38
if (current_loc.lat == 0 && current_loc.lng == 0) {
39
ground_start_count = 5;
40
41
} else {
42
// Now have an initial GPS position
43
// use it as the HOME position in future startups
44
current_loc = gps.location();
45
IGNORE_RETURN(set_home(current_loc, false));
46
ground_start_count = 0;
47
}
48
}
49
}
50
}
51
52
void Tracker::handle_battery_failsafe(const char* type_str, const int8_t action)
53
{
54
// NOP
55
// useful failsafes in the future would include actually recalling the vehicle
56
// that is tracked before the tracker loses power to continue tracking it
57
}
58
59