Boats: stop motors when commanding zero speed

This commit is contained in:
Matthias Grob 2023-05-03 15:16:42 +02:00
parent d0d113405a
commit e0e5b38c0e
2 changed files with 14 additions and 1 deletions

View File

@ -48,9 +48,10 @@ ActuatorEffectivenessCustom::getEffectivenessMatrix(Configuration &configuration
return false; return false;
} }
// motors // Motors
_motors.enablePropellerTorque(false); _motors.enablePropellerTorque(false);
const bool motors_added_successfully = _motors.addActuators(configuration); const bool motors_added_successfully = _motors.addActuators(configuration);
_motors_mask = _motors.getMotors();
// Torque // Torque
const bool torque_added_successfully = _torque.addActuators(configuration); const bool torque_added_successfully = _torque.addActuators(configuration);
@ -58,3 +59,9 @@ ActuatorEffectivenessCustom::getEffectivenessMatrix(Configuration &configuration
return (motors_added_successfully && torque_added_successfully); return (motors_added_successfully && torque_added_successfully);
} }
void ActuatorEffectivenessCustom::updateSetpoint(const matrix::Vector<float, NUM_AXES> &control_sp,
int matrix_index, ActuatorVector &actuator_sp, const matrix::Vector<float, NUM_ACTUATORS> &actuator_min,
const matrix::Vector<float, NUM_ACTUATORS> &actuator_max)
{
stopMaskedMotorsWithZeroThrust(_motors_mask, actuator_sp);
}

View File

@ -45,9 +45,15 @@ public:
bool getEffectivenessMatrix(Configuration &configuration, EffectivenessUpdateReason external_update) override; bool getEffectivenessMatrix(Configuration &configuration, EffectivenessUpdateReason external_update) override;
void updateSetpoint(const matrix::Vector<float, NUM_AXES> &control_sp, int matrix_index,
ActuatorVector &actuator_sp, const matrix::Vector<float, NUM_ACTUATORS> &actuator_min,
const matrix::Vector<float, NUM_ACTUATORS> &actuator_max) override;
const char *name() const override { return "Custom"; } const char *name() const override { return "Custom"; }
protected: protected:
ActuatorEffectivenessRotors _motors; ActuatorEffectivenessRotors _motors;
ActuatorEffectivenessControlSurfaces _torque; ActuatorEffectivenessControlSurfaces _torque;
uint32_t _motors_mask{};
}; };