mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 15:08:53 +08:00
tap_esc: fixed offset to really keep the range 1200-1900
even if the input to the driver is too low or too high. This prevents motor stalling. NaN or Inf still stop the motor.
This commit is contained in:
committed by
Lorenz Meier
parent
91416fc49a
commit
41ff46b557
@@ -40,6 +40,7 @@
|
||||
#include <termios.h>
|
||||
#include <cmath> // NAN
|
||||
|
||||
#include <lib/mathlib/mathlib.h>
|
||||
#include <systemlib/px4_macros.h>
|
||||
#include <drivers/device/device.h>
|
||||
#include <uORB/uORB.h>
|
||||
@@ -664,15 +665,14 @@ TAP_ESC::cycle()
|
||||
for (unsigned i = 0; i < num_outputs; i++) {
|
||||
/* last resort: catch NaN, INF and out-of-band errors */
|
||||
if (i < _outputs.noutputs &&
|
||||
PX4_ISFINITE(_outputs.output[i]) &&
|
||||
_outputs.output[i] >= -1.0f &&
|
||||
_outputs.output[i] <= 1.0f) {
|
||||
/* scale for PWM output 1000 - 2000us */
|
||||
_outputs.output[i] = 1600 + (350 * _outputs.output[i]);
|
||||
PX4_ISFINITE(_outputs.output[i])) {
|
||||
/* scale for PWM output 1200 - 1900us */
|
||||
_outputs.output[i] = (RPMMAX + RPMMIN) / 2 + ((RPMMAX - RPMMIN) / 2) * _outputs.output[i]);
|
||||
math::constrain(_outputs.output[i], (float)RPMMIN, (float)RPMMAX);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Value is NaN, INF or out of band - set to the minimum value.
|
||||
* Value is NaN, INF - stop the motor.
|
||||
* This will be clearly visible on the servo status and will limit the risk of accidentally
|
||||
* spinning motors. It would be deadly in flight.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user