mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-18 18:20:15 +08:00
Clamped max_torque to 0 for ACIM motors in case max_torque happened to be negative.
This commit is contained in:
@@ -192,17 +192,18 @@ float Motor::effective_current_lim() {
|
||||
return current_lim;
|
||||
}
|
||||
|
||||
//return the maximum available torque for the motor.
|
||||
//Note - for ACIM motors, available torque is allowed to be 0.
|
||||
float Motor::max_available_torque() {
|
||||
//return the maximum available torque for the motor.
|
||||
//Note - for ACIM motors, available torque is allowed to be 0.
|
||||
if (config_.motor_type == Motor::MOTOR_TYPE_ACIM) {
|
||||
float max_torque = effective_current_lim() * config_.torque_constant * current_control_.acim_rotor_flux;
|
||||
max_torque = fmin(max_torque, config_.torque_lim);
|
||||
max_torque = std::clamp(max_torque, 0.0f, max_torque);
|
||||
max_torque = std::min(max_torque, config_.torque_lim);
|
||||
return max_torque;
|
||||
}
|
||||
else {
|
||||
float max_torque = effective_current_lim() * config_.torque_constant;
|
||||
max_torque = fmin(max_torque, config_.torque_lim);
|
||||
max_torque = std::min(max_torque, config_.torque_lim);
|
||||
return max_torque;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user