VingVing Robot LogoVingVing Robot

Documentation v0.0.3

VingVing Robot Docs

PID Tuning

Master the four PID controllers for precise robot movement

Understanding PID Control

VingVing Robot uses four separate PID controllers to achieve precise path following. Each controller serves a specific purpose and needs to be tuned independently.

Translational

Corrects lateral position error

Heading

Corrects rotation error

Drive

Controls forward movement

Centripetal

Compensates for curves

How Each Component Works

Watch these animations to understand how P, I, D, and F affect robot behavior:

Proportional (P)

Higher P = Faster response but more overshoot

Target
🤖
Start

Notice the robot overshoots the target, then oscillates before settling. Higher P gain increases response speed but causes more overshoot.

Integral (I)

Eliminates steady-state error over time

Target
🤖
Start

The robot gradually eliminates the error over time. I gain accumulates error to eliminate steady-state offset.

Derivative (D)

Reduces overshoot and dampens oscillations

Target
🤖
Start

The robot approaches smoothly with minimal overshoot. D gain predicts future error and dampens oscillations.

Feedforward (F)

Pre-emptive control reduces lag

Target
🤖
Start

The robot moves directly to the target with no delay. Feedforward provides pre-emptive control based on the setpoint.

PID Coefficients Explained

P - Proportional

Responds to current error. Larger P means faster correction but more overshoot.

✓ Increase P if: Robot is too slow to respond

✗ Decrease P if: Robot oscillates or overshoots

I - Integral

Responds to accumulated error over time. Eliminates steady-state offset.

✓ Increase I if: Robot doesn't quite reach the target

✗ Decrease I if: Robot becomes unstable or overshoots late

D - Derivative

Responds to rate of change of error. Dampens oscillations and reduces overshoot.

✓ Increase D if: Robot oscillates around target

✗ Decrease D if: Robot becomes sluggish or noisy

F - Feedforward

Provides pre-emptive control based on target. Reduces lag and improves tracking.

✓ Increase F if: Robot lags behind the path

✗ Decrease F if: Robot leads the path too aggressively

Tuning Each Controller

1

Translational PID

Controls lateral (sideways) position error. This keeps the robot on the path when it drifts.

Using Translational Tuner

The Translational Tuner keeps the robot in place while you push it sideways. Tune the PID to make it resist your push and return to position.

Using Translational Tuner
1. Select "Manual" → "Translational Tuner" from Tuning OpMode
2. Robot will drive forward and backward slowly
3. Push the robot sideways (left/right) while it's moving
4. Observe how quickly it corrects back to the path
5. Adjust P, I, D values in RobotConfig based on behavior

Recommended Starting Values

.translationalPIDFCoefficients(new PIDFCoefficients(
    0.1,   // P - Start here, increase if too slow
    0.0,   // I - Usually can stay at 0
    0.01,  // D - Add a small amount to reduce oscillation
    0.003  // F - Small feedforward helps tracking
))

Tuning Tips:

  • Start with P only, set I and D to 0
  • Increase P until robot responds quickly but oscillates slightly
  • Add D to dampen oscillations (usually 10-20% of P value)
  • Add small I only if robot doesn't fully correct position
2

Heading PID

Controls rotational error. This keeps the robot pointing in the correct direction.

Using Heading Tuner

Using Heading Tuner
1. Select "Manual" → "Heading Tuner"
2. Robot drives forward/backward while maintaining heading
3. Try to rotate the robot manually
4. Observe how it fights back to maintain heading
5. Adjust PID values for crisp rotation control

Recommended Starting Values

.headingPIDFCoefficients(new PIDFCoefficients(
    1.0,   // P - Rotation usually needs higher P
    0.0,   // I - Start at 0
    0.0,   // D - Not usually needed for heading
    0.005  // F - Small value helps maintain heading
))

Tuning Tips:

  • Heading typically needs higher P values than translational
  • D is often not needed - rotation is naturally damped
  • If robot drifts in heading during long movements, add small I
  • F helps maintain constant heading during movement
3

Drive PID (Filtered)

Controls forward/backward movement along the path. Uses filtering for smoother control.

Using Drive Tuner

Using Drive Tuner
1. Select "Manual" → "Drive Tuner"
2. Robot drives in a straight line forward and back
3. Watch how smoothly it accelerates and decelerates
4. Check if it reaches full speed or lags behind
5. Tune for smooth, fast movement without overshoot

Recommended Starting Values

.drivePIDFCoefficients(new FilteredPIDFCoefficients(
    0.5,   // P - Forward movement gain
    0.001, // I - Very small, eliminates lag
    0.001, // D - Helps smooth deceleration
    0.6,   // F - Should be tuned based on max velocity
    0.75   // Filter coefficient (0-1, higher = less filtering)
))

Tuning Tips:

  • F (feedforward) is most important - tune this first
  • F should be approximately: 1.0 / (max velocity in in/s)
  • Increase P if robot is too slow to accelerate
  • Filter coefficient: higher = more responsive, lower = smoother
4

Centripetal Force Compensation

Compensates for centripetal force when following curved paths. Not a traditional PID.

Using Centripetal Tuner

Using Centripetal Tuner
1. Select "Manual" → "Centripetal Tuner"
2. Robot follows a curved path repeatedly
3. Watch if robot cuts corners (too low) or swings wide (too high)
4. Adjust centripetalScaling value
5. Perfect value makes robot follow curve precisely

Recommended Starting Value

.centripetalScaling(0.0005)  // Usually between 0.0003 - 0.001

Tuning Tips:

  • Only tune this AFTER all other PIDs are tuned
  • If robot cuts inside corners: increase value
  • If robot swings wide on curves: decrease value
  • Value depends on robot weight and wheel friction

Recommended Tuning Process

  1. 1.
    Start with Translational

    Tune P first, then add D, rarely need I

  2. 2.
    Move to Heading

    Usually just needs P and F, rarely D or I

  3. 3.
    Tune Drive

    Focus on F first, then adjust P for responsiveness

  4. 4.
    Fine-tune Centripetal

    Small adjustments using the Circle test

  5. 5.
    Test Everything

    Run Line, Triangle, and Circle tests to verify

Troubleshooting

Robot oscillates back and forthâ–¼

Cause: P value too high, or D value too low

Solution: Decrease P by 20-30%, or increase D to dampen oscillations

Robot is slow to respondâ–¼

Cause: P value too low, or excessive filtering

Solution: Increase P gradually, or increase filter coefficient

Robot doesn't reach target preciselyâ–¼

Cause: Steady-state error, need I term

Solution: Add small I value (start with 0.001) to eliminate offset

Robot overshoots and takes long to settleâ–¼

Cause: I value accumulating too much error

Solution: Decrease I value, or set it to 0 and rely on P and D

Next Steps

Once your PIDs are tuned, verify with comprehensive testing!