mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-21 06:23:07 +08:00
1.3 KiB
1.3 KiB
Control
The motor controller is a cascaded style position, velocity and current control loop, as per the diagram below. When the control mode is set to position control, the whole loop runs. When running in velocity control mode, the position control part is removed and the velocity command is fed directly in to the second stage input. In current control mode, only the current controller is used.
Position loop:
The position controller is a P loop with a single proportional gain.
vel_cmd = (pos_setpoint - pos_feedback) * pos_gain
Velocity loop:
The velocity controller is a PI loop.
vel_error_sum += (vel_cmd - vel_feedback) * vel_integrator_gaincurrent_cmd = (vel_cmd - vel_feedback) * vel_gain + vel_error_sum + vel_feedforward
Current loop:
The current controller is a PI loop.
current_error_sum += (current_cmd - current_fb) * current_integrator_gainvoltage_cmd = (current_cmd - current_fb) * current_gain + current_error_sum + current_feedforward
For more detail refer to controller.cpp.
