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
This commit is contained in:
Andrew Tridgell 2014-11-20 16:58:16 +11:00
parent ecc7a3cbb4
commit ead0458e97
1 changed files with 9 additions and 4 deletions

View File

@ -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);