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.
This commit is contained in:
Julian Oes
2018-12-22 10:32:18 +01:00
parent 2d7299043d
commit a1fc44d1f0
+3 -1
View File
@@ -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);
}