|
|
|
@ -249,20 +249,19 @@ PWMSim::run()
@@ -249,20 +249,19 @@ PWMSim::run()
|
|
|
|
|
/* iterate actuators */ |
|
|
|
|
for (unsigned i = 0; i < _actuator_outputs.noutputs; i++) { |
|
|
|
|
/* last resort: catch NaN, INF and out-of-band errors */ |
|
|
|
|
if (i < _actuator_outputs.noutputs && |
|
|
|
|
PX4_ISFINITE(_actuator_outputs.output[i]) && |
|
|
|
|
_actuator_outputs.output[i] >= -1.0f && |
|
|
|
|
_actuator_outputs.output[i] <= 1.0f) { |
|
|
|
|
const bool sane_mixer_output = PX4_ISFINITE(_actuator_outputs.output[i]) && |
|
|
|
|
_actuator_outputs.output[i] >= -1.0f && |
|
|
|
|
_actuator_outputs.output[i] <= 1.0f; |
|
|
|
|
|
|
|
|
|
if (_armed && sane_mixer_output) { |
|
|
|
|
/* scale for PWM output 1000 - 2000us */ |
|
|
|
|
_actuator_outputs.output[i] = 1500 + (500 * _actuator_outputs.output[i]); |
|
|
|
|
_actuator_outputs.output[i] = math::constrain(_actuator_outputs.output[i], (float)_pwm_min[i], (float)_pwm_max[i]); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
/*
|
|
|
|
|
* Value is NaN, INF or out of band - set to the minimum value. |
|
|
|
|
/* Disarmed or insane value - set disarmed pwm value
|
|
|
|
|
* This will be clearly visible on the servo status and will limit the risk of accidentally |
|
|
|
|
* spinning motors. It would be deadly in flight. |
|
|
|
|
*/ |
|
|
|
|
* spinning motors. It would be deadly in flight. */ |
|
|
|
|
_actuator_outputs.output[i] = PWM_SIM_DISARMED_MAGIC; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|