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/ArduSub/inertia.cpp
Views: 1798
1
#include "Sub.h"
2
3
// read_inertia - read inertia in from accelerometers
4
void Sub::read_inertia()
5
{
6
// inertial altitude estimates
7
inertial_nav.update();
8
9
// pull position from ahrs
10
Location loc;
11
ahrs.get_location(loc);
12
current_loc.lat = loc.lat;
13
current_loc.lng = loc.lng;
14
15
// exit immediately if we do not have an altitude estimate
16
if (!inertial_nav.get_filter_status().flags.vert_pos) {
17
return;
18
}
19
20
current_loc.alt = inertial_nav.get_position_z_up_cm();
21
22
// get velocity, altitude is always absolute frame, referenced from
23
// water's surface
24
climb_rate = inertial_nav.get_velocity_z_up_cms();
25
}
26
27