Line data Source code
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 4393 : bool AP_Airspeed_SITL::get_differential_pressure(float &pressure) 10 : { 11 4393 : const uint8_t _instance = get_instance(); 12 : 13 4393 : if (_instance >= AIRSPEED_MAX_SENSORS) { 14 0 : return false; 15 : } 16 : 17 4393 : pressure = AP::sitl()->state.airspeed_raw_pressure[_instance]; 18 : 19 4393 : return true; 20 : } 21 : 22 : // get last temperature 23 11002 : bool AP_Airspeed_SITL::get_temperature(float &temperature) 24 : { 25 11002 : const uint8_t _instance = get_instance(); 26 : 27 11002 : if (_instance >= AIRSPEED_MAX_SENSORS) { 28 0 : return false; 29 : } 30 : 31 11002 : const auto *sitl = AP::sitl(); 32 : 33 : // this was mostly swiped from SIM_Airspeed_DLVR: 34 11002 : const float sim_alt = sitl->state.altitude; 35 : 36 : // To Do: Add a sensor board temperature offset parameter 37 11002 : temperature = AP_Baro::get_temperatureC_for_alt_amsl(sim_alt); 38 : 39 11002 : return true; 40 : } 41 : 42 : #endif // AP_AIRSPEED_SITL_ENABLED