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_GPS.cpp
Views: 1798
1
#include "AP_DAL_GPS.h"
2
3
#include <AP_Logger/AP_Logger.h>
4
#include "AP_DAL.h"
5
6
AP_DAL_GPS::AP_DAL_GPS()
7
{
8
for (uint8_t i=0; i<ARRAY_SIZE(_RGPI); i++) {
9
_RGPI[i].instance = i;
10
_RGPJ[i].instance = i;
11
}
12
}
13
14
void AP_DAL_GPS::start_frame()
15
{
16
const auto &gps = AP::gps();
17
18
const log_RGPH old_RGPH = _RGPH;
19
_RGPH.primary_sensor = gps.primary_sensor();
20
_RGPH.num_sensors = gps.num_sensors();
21
22
WRITE_REPLAY_BLOCK_IFCHANGED(RGPH, _RGPH, old_RGPH);
23
24
for (uint8_t i=0; i<ARRAY_SIZE(_RGPI); i++) {
25
log_RGPI &RGPI = _RGPI[i];
26
log_RGPJ &RGPJ = _RGPJ[i];
27
const log_RGPI old_RGPI = RGPI;
28
const log_RGPJ old_RGPJ = RGPJ;
29
30
RGPI.status = (GPS_Status)gps.status(i);
31
RGPI.antenna_offset = gps.get_antenna_offset(i);
32
33
const Location &loc = gps.location(i);
34
RGPJ.last_message_time_ms = gps.last_message_time_ms(i);
35
RGPJ.lat = loc.lat;
36
RGPJ.lng = loc.lng;
37
RGPJ.alt = loc.alt;
38
RGPI.have_vertical_velocity = gps.have_vertical_velocity(i);
39
40
RGPI.horizontal_accuracy_returncode = gps.horizontal_accuracy(i, RGPJ.hacc);
41
RGPI.vertical_accuracy_returncode = gps.vertical_accuracy(i, RGPJ.vacc);
42
RGPJ.hdop = gps.get_hdop(i);
43
RGPI.num_sats = gps.num_sats(i);
44
RGPI.get_lag_returncode = gps.get_lag(i, RGPI.lag_sec);
45
46
RGPJ.velocity = gps.velocity(i);
47
RGPI.speed_accuracy_returncode = gps.speed_accuracy(i, RGPJ.sacc);
48
RGPI.gps_yaw_deg_returncode = gps.gps_yaw_deg(i, RGPJ.yaw_deg, RGPJ.yaw_accuracy_deg, RGPJ.yaw_deg_time_ms);
49
50
WRITE_REPLAY_BLOCK_IFCHANGED(RGPI, RGPI, old_RGPI);
51
WRITE_REPLAY_BLOCK_IFCHANGED(RGPJ, RGPJ, old_RGPJ);
52
53
tmp_location[i].lat = RGPJ.lat;
54
tmp_location[i].lng = RGPJ.lng;
55
tmp_location[i].alt = RGPJ.alt;
56
}
57
}
58
59