diff --git a/src/DCMotor.cpp b/src/DCMotor.cpp index e5491cee..7a7ad803 100644 --- a/src/DCMotor.cpp +++ b/src/DCMotor.cpp @@ -132,6 +132,9 @@ void DCMotor::move(float new_target) { setPhaseVoltage(voltage.q, 0.0f, 0.0f); }; +void DCMotor::setOutput(float voltage_target) { + setPhaseVoltage(voltage_target, 0.0f, 0.0f); +} void DCMotor::setPhaseVoltage(float Uq, float Ud, float angle_el) { if (enabled==1) diff --git a/src/DCMotor.h b/src/DCMotor.h index 9d4a7efb..94d6d201 100644 --- a/src/DCMotor.h +++ b/src/DCMotor.h @@ -48,6 +48,8 @@ class DCMotor : public FOCMotor { */ void move(float new_target = NOT_SET) override; + void setOutput(float voltage_target = NOT_SET) override; //directly set the voltage on the output - used for setting it to zero + /** * @param Uq Voltage to set to the motor * @param Ud ignored for DC motors diff --git a/src/common/base_classes/FOCMotor.h b/src/common/base_classes/FOCMotor.h index 8ae0e8af..1b325f85 100644 --- a/src/common/base_classes/FOCMotor.h +++ b/src/common/base_classes/FOCMotor.h @@ -123,6 +123,8 @@ class FOCMotor */ virtual void move(float target = NOT_SET)=0; + virtual void setOutput(float target = NOT_SET) = 0; + /** * Method using FOC to set Uq to the motor at the optimal angle * Heart of the FOC algorithm