aboutsummaryrefslogtreecommitdiff
path: root/src/modules/uavcan/actuators/esc.cpp
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2014-11-20 16:58:16 +1100
committerAndrew Tridgell <tridge@samba.org>2014-11-26 08:32:47 +1100
commitead0458e97d6e19cc0b188124063e90962820e3a (patch)
treeab52432a73f66d50a260e949cb2725dd1d673af7 /src/modules/uavcan/actuators/esc.cpp
parentecc7a3cbb42f6490b43f21b3849738184934a2a0 (diff)
downloadpx4-firmware-ead0458e97d6e19cc0b188124063e90962820e3a.tar.gz
px4-firmware-ead0458e97d6e19cc0b188124063e90962820e3a.tar.bz2
px4-firmware-ead0458e97d6e19cc0b188124063e90962820e3a.zip
uavcan: don't force motors to keep spinning at zero throttle
Forcing motors to keep spinning when armed should be a policy decision up at the vehicle type level, not hard coded down in the ESC driver. It isn't appropriate for fixed wing or ground vehicles for example. We could add an ioctl to enable "spin when armed" if just setting a small value in the vehicle code is inconvenient
Diffstat (limited to 'src/modules/uavcan/actuators/esc.cpp')
-rw-r--r--src/modules/uavcan/actuators/esc.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/modules/uavcan/actuators/esc.cpp b/src/modules/uavcan/actuators/esc.cpp
index 1d23099f3..7efd50511 100644
--- a/src/modules/uavcan/actuators/esc.cpp
+++ b/src/modules/uavcan/actuators/esc.cpp
@@ -101,10 +101,15 @@ void UavcanEscController::update_outputs(float *outputs, unsigned num_outputs)
for (unsigned i = 0; i < num_outputs; i++) {
if (_armed_mask & MOTOR_BIT(i)) {
float scaled = (outputs[i] + 1.0F) * 0.5F * cmd_max;
- if (scaled < 1.0F) {
- scaled = 1.0F; // Since we're armed, we don't want to stop it completely
- }
-
+ // trim negative values back to 0. Previously
+ // we set this to 0.1, which meant motors kept
+ // spinning when armed, but that should be a
+ // policy decision for a specific vehicle
+ // type, as it is not appropriate for all
+ // types of vehicles (eg. fixed wing).
+ if (scaled < 0.0F) {
+ scaled = 0.0F;
+ }
if (scaled > cmd_max) {
scaled = cmd_max;
perf_count(_perfcnt_scaling_error);