mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 03:11:35 +08:00
PWMSim: publish disarmed value when not armed
This commit is contained in:
committed by
Lorenz Meier
parent
05e45c2867
commit
36248cb12e
@@ -249,20 +249,19 @@ PWMSim::run()
|
|||||||
/* iterate actuators */
|
/* iterate actuators */
|
||||||
for (unsigned i = 0; i < _actuator_outputs.noutputs; i++) {
|
for (unsigned i = 0; i < _actuator_outputs.noutputs; i++) {
|
||||||
/* last resort: catch NaN, INF and out-of-band errors */
|
/* last resort: catch NaN, INF and out-of-band errors */
|
||||||
if (i < _actuator_outputs.noutputs &&
|
const bool sane_mixer_output = PX4_ISFINITE(_actuator_outputs.output[i]) &&
|
||||||
PX4_ISFINITE(_actuator_outputs.output[i]) &&
|
_actuator_outputs.output[i] >= -1.0f &&
|
||||||
_actuator_outputs.output[i] >= -1.0f &&
|
_actuator_outputs.output[i] <= 1.0f;
|
||||||
_actuator_outputs.output[i] <= 1.0f) {
|
|
||||||
|
if (_armed && sane_mixer_output) {
|
||||||
/* scale for PWM output 1000 - 2000us */
|
/* scale for PWM output 1000 - 2000us */
|
||||||
_actuator_outputs.output[i] = 1500 + (500 * _actuator_outputs.output[i]);
|
_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]);
|
_actuator_outputs.output[i] = math::constrain(_actuator_outputs.output[i], (float)_pwm_min[i], (float)_pwm_max[i]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/* Disarmed or insane value - set disarmed pwm value
|
||||||
* Value is NaN, INF or out of band - set to the minimum value.
|
|
||||||
* This will be clearly visible on the servo status and will limit the risk of accidentally
|
* 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;
|
_actuator_outputs.output[i] = PWM_SIM_DISARMED_MAGIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user