Skip to content

Commit

Permalink
Merge pull request odriverobotics#626 from pbrier/master
Browse files Browse the repository at this point in the history
Added integrator_limit to allow prevention of integrator windup
  • Loading branch information
madcowswe authored Oct 10, 2021
2 parents 98f7d37 + ef03591 commit f5caa53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Firmware/MotorControl/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ bool Controller::update() {
} else {
vel_integrator_torque_ += ((vel_integrator_gain * gain_scheduling_multiplier) * current_meas_period) * v_err;
}
// integrator limiting to prevent windup
vel_integrator_torque_ = std::clamp(vel_integrator_torque_, -config_.vel_integrator_limit, config_.vel_integrator_limit);
}

float ideal_electrical_power = 0.0f;
Expand Down
1 change: 1 addition & 0 deletions Firmware/MotorControl/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Controller : public ODriveIntf::ControllerIntf {
float vel_integrator_gain = 2.0f / 6.0f; // [Nm/(turn/s * s)]
float vel_limit = 2.0f; // [turn/s] Infinity to disable.
float vel_limit_tolerance = 1.2f; // ratio to vel_lim. Infinity to disable.
float vel_integrator_limit = INFINITY; // Vel. integrator clamping value. Infinity to disable.
float vel_ramp_rate = 1.0f; // [(turn/s) / s]
float torque_ramp_rate = 0.01f; // Nm / sec
bool circular_setpoints = false;
Expand Down
5 changes: 5 additions & 0 deletions Firmware/odrive-interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ interfaces:
type: float32
unit: Nm/(turn/s * s)
doc: units = Nm/(turn/s * s), default = 0.32
doc: units = 'Nm/(turn/s), default = 0.16
vel_integrator_limit:
type: float32
unit: Nm
doc: Limit the integrator output (independent of proportional gain output) to prevent 'integrator windup'. Set to infinity to disable. Units = Nm, default = inf
vel_limit:
type: float32
unit: turn/s
Expand Down

0 comments on commit f5caa53

Please sign in to comment.