Skip to content

Commit 4bbaff0

Browse files
committed
fix(sensor_airspeed_sim): match SimulatorMavlink rounding
1 parent 1762c2d commit 4bbaff0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ void SensorAirspeedSim::check_failure_injection()
184184
bool handled = false;
185185
bool supported = false;
186186

187-
const int failure_unit = static_cast<int>(vehicle_command.param1 + 0.5f);
188-
const int failure_type = static_cast<int>(vehicle_command.param2 + 0.5f);
187+
const int failure_unit = static_cast<int>(std::lround(vehicle_command.param1));
188+
const int failure_type = static_cast<int>(std::lround(vehicle_command.param2));
189189

190190
if (failure_unit == vehicle_command_s::FAILURE_UNIT_SENSOR_AIRSPEED) {
191191

src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#pragma once
3535

3636
#include <lib/perf/perf_counter.h>
37+
#include <math.h>
3738
#include <mathlib/mathlib.h>
3839
#include <px4_platform_common/defines.h>
3940
#include <px4_platform_common/module.h>

0 commit comments

Comments
 (0)