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_Airspeed/AP_Airspeed_SITL.cpp
Views: 1798
1
#include "AP_Airspeed_SITL.h"
2
3
#if AP_AIRSPEED_SITL_ENABLED
4
5
#include <AP_Baro/AP_Baro.h>
6
#include <SITL/SITL.h>
7
8
// return the current differential_pressure in Pascal
9
bool AP_Airspeed_SITL::get_differential_pressure(float &pressure)
10
{
11
const uint8_t _instance = get_instance();
12
13
if (_instance >= AIRSPEED_MAX_SENSORS) {
14
return false;
15
}
16
17
pressure = AP::sitl()->state.airspeed_raw_pressure[_instance];
18
19
return true;
20
}
21
22
// get last temperature
23
bool AP_Airspeed_SITL::get_temperature(float &temperature)
24
{
25
const uint8_t _instance = get_instance();
26
27
if (_instance >= AIRSPEED_MAX_SENSORS) {
28
return false;
29
}
30
31
const auto *sitl = AP::sitl();
32
33
// this was mostly swiped from SIM_Airspeed_DLVR:
34
const float sim_alt = sitl->state.altitude;
35
36
// To Do: Add a sensor board temperature offset parameter
37
temperature = AP_Baro::get_temperatureC_for_alt_amsl(sim_alt);
38
39
return true;
40
}
41
42
#endif // AP_AIRSPEED_SITL_ENABLED
43
44