mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 04:43:34 +08:00
added logic to encode NAN as INT16_MAX to transfer to IO from FMU
This commit is contained in:
@@ -1304,8 +1304,15 @@ PX4IO::io_set_control_state(unsigned group)
|
||||
for (unsigned i = 0; i < _max_controls; i++) {
|
||||
/* ensure FLOAT_TO_REG does not produce an integer overflow */
|
||||
const float ctrl = math::constrain(controls.control[i], -1.0f, 1.0f);
|
||||
if(!isfinite(ctrl)){
|
||||
regs[i] = INT16_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
regs[i] = FLOAT_TO_REG(ctrl);
|
||||
}
|
||||
|
||||
|
||||
regs[i] = FLOAT_TO_REG(ctrl);
|
||||
}
|
||||
|
||||
if (!_test_fmu_fail) {
|
||||
|
||||
Reference in New Issue
Block a user