Our Key Innovation, the Quadratic-Damped PID
Our key innovation about our follower is our quadratic-damped PID. We include this quadratic damping term in our translational PID, allowing it to be nearly 5x faster at decelerating, more aggressive, and accurate while minimizing premature deceleration for faster deceleration. You can learn about how we came up with this idea with our first empirical approach.
Pseudo code of PD controller with quadratic damping
error = target - current
derivative = kD * -velocity
quadraticDamping = kQ * -velocity * abs(velocity)
proportional = error * proportionalConstant
outputPower = proportional + derivative + quadraticDamping
Why Quadratic Damping Is Needed?
We wanted to brake as fast as zero power brake mode, so that required quadratic regression to model the realistic, non-linear braking behavior of the robot with a quadratic-damped term. We later realized that applying small amounts of reverse power to the wheels uses the same system as zero power brake mode, but allows us to correct and control the robot’s position. If you use a less aggressive PID controller that simply coasts to the target, quadratic damping isn’t necessary. It’s only required when you want high speed and braking that requires replicating the robot’s real braking dynamics at high speeds.
Why is the Braking Non-Linear?
When you reverse the motor power, the motor’s internal back-EMF also reverses. This causes the motor to brake rapidly using its own momentum, even with very small power inputs like -0.00001. Essentially, the faster the wheel was initially spinning, the stronger the braking force generated. This is exactly how the zero power brake mode brakes.
In an ideal scenario, the braking force would be directly proportional to velocity. However, when the robot’s powered wheels are braking to a stop, the deceleration is not perfectly linear. The friction involved in braking causes the relationship between velocity and braking distance to become non-linear. This is why we call kD
: kBrake
and kQ
: kFriction
in our code.
How much difference does the Quadratic Damping make?
Other libraries (e.g. Roadrunner, Pedro Path) rely on gentle PID + coasting:
- Coasting (~
-40 in/s²
) needs ~45in
to stop from60 in/s
With quadratic damping + back-EMF braking:
- ~
10 in
to stop from60 in/s
→ nearly 5× faster deceleration - Leaves more time to accelerate before braking
Pros
- Faster - more time accelerating, less time decelerating
- More accurate - higher proportional constant reduces steady-state error
- More responsive - reacts quickly without oscillation due to quadratic damping
Trade-offs
- Higher power usage - requires more voltage, applying reverse power to brake faster
- Sharper stops - can feel less smooth (minor shaking at final stop)
How does -velocity = Derivative term in PID?
Let the positional error be:
error = target - current
Taking the derivative of both sides:
d/dt error = d/dt target - d/dt current
If the target position is constant, then:
d/dt target = 0
Then:
d/dt error = 0 - d/dt current
Since the rate of change of the current position is just velocity, when the target position is fixed, the derivative of the position error is simply the negative of the current velocity.
d/dt error = -velocity