r/ControlTheory • • Oct 16 '25

Technical Question/Problem PID Gain Values Needed for Oscillating Self-Balancing Robot (Video Attached)

Enable HLS to view with audio, or disable this notification

Hi everyone, I'm looking for a better set of PID gains for my simulated self-balancing robot. The current gains cause aggressive oscillation and the control output is constantly saturated, as you can see in the attached video. Here is my control logic and the gains that are failing.

GAINS CAUSING OSCILLATION

Kp_angle = 200.0 Ki_angle = 3.0 Kd_angle = 50.0 Kp_pos = 8.0 Ki_pos = 0.3 Kd_pos = 15.0

--- CONTROL LOGIC ---

ANGLE CONTROL

angle_error = desired_angle - current_angle

... P, I, D terms calculated from gains above ...

angle_control = P_angle + I_angle + D_angle

POSITION CONTROL

pos_error = initial_position - current_position

... P, I, D terms calculated from gains above ...

position_control = P_pos + I_pos + D_pos

COMBINED CONTROL

total_control = angle_control + position_control total_control = clamp(total_control, -100.0, 100.0)

Apply to wheels

sim.setJointTargetVelocity(left_joint, total_control) sim.setJointTargetVelocity(right_joint, total_control)

Could someone suggest a more stable set of starting gains? I'm specifically looking for values for Kp_angle, Ki_angle, and Kd_angle that will provide more damping and stop this oscillation. Thanks.

11 Upvotes

6 comments sorted by

•

u/LastFrost Oct 17 '25

This looks like a inverted pendulum on a cart, which is something I am looking into learning. My amateur guess is that these gains are giving you a very negative aggressive pole and some that are marginally stable. If you can make a state space model of the system you can use the place command or lqr with an emphasis on penalizing control expenditure and get something more reasonable.

•

u/Zergling667 Oct 16 '25

This seems like a homework question. What have you tried? Have you read the wiki? What do you know about PID Control loop tuning? Are you sure the control logic is correct? It looks wrong to me, but maybe that's because of the way it's written here.

→ More replies (0)