From a1fc44d1f03969614a22019ab61af61848a271d7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 12 Dec 2018 10:41:27 +0100 Subject: [PATCH] simulator: fix noise in airspeed It turns out the noise of the airspeed depends on the least significant bit of time which is now always 0 because time is quite regular with lockstep. Therefore, we need a better source for the randomness. I chose to use the sign of the y-gyro and it seems to work. --- src/modules/simulator/simulator_mavlink.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/simulator/simulator_mavlink.cpp b/src/modules/simulator/simulator_mavlink.cpp index 078d6768f1..c172611757 100644 --- a/src/modules/simulator/simulator_mavlink.cpp +++ b/src/modules/simulator/simulator_mavlink.cpp @@ -253,7 +253,9 @@ void Simulator::update_sensors(mavlink_hil_sensor_t *imu) RawAirspeedData airspeed = {}; airspeed.temperature = imu->temperature; - airspeed.diff_pressure = imu->diff_pressure + 0.001f * (hrt_absolute_time() & 0x01); + // FIXME: diff_pressure needs some noise to pass preflight checks, so we just take the + // noise from the gyro. + airspeed.diff_pressure = imu->diff_pressure + ((imu->ygyro > 0) ? 0.001f : 0.0f); write_airspeed_data(&airspeed); }