top of page
Writer's pictureArjun Mahajan

Odometry and PID Control: Our Journey with goBILDA

Updated: Nov 3

Hello fellow FTC teams! We are TEAM X, and we want to share our journey in mastering odometry and PID control, which have been crucial to our success on the field. We'll explain these concepts, share how we implemented them, and dive into why we switched to the goBILDA Pinpoint Odometry System. We'll also get into the technical details to help you understand how you can apply these strategies to your own robots.

Odo
 

Understanding Odometry

Odometry is like a robot's internal GPS. It helps the robot keep track of its position (where it is) and orientation (which way it's facing) by measuring how much its wheels have turned. This is essential during the autonomous period in FTC matches when the robot must navigate the field without driver input.

How Odometry Works

At its core, odometry calculates the robot's position based on wheel rotations. Here's how we implemented it:

  • Odometry Pods: These are modules attached to the robot that have wheels (often called dead wheels because they are not powered) connected to encoders. Encoders measure the rotation of the wheels very precisely.

  • Omni Wheels in Odometry Pods: We use omni wheels in our odometry pods. Omni wheels have small rollers around the circumference, allowing them to roll smoothly in any direction with minimal friction. This reduces slippage and provides more accurate measurements, especially when the robot moves sideways or makes turns.

  • Calculating Position and Heading: By tracking the rotation of the omni wheels in the odometry pods, we calculate the robot's movement in the X (forward/backward) and Y (side-to-side) directions. Additionally, by comparing the differences in wheel rotations, we determine the robot's heading (its orientation on the field).

The Importance of Accurate Odometry

Accurate odometry allows the robot to:

  • Navigate Precisely: Reach specific locations on the field to score points.

  • Perform Consistent Autonomous Actions: Repeat tasks reliably match after match.

  • Avoid Obstacles: Maneuver around other robots and game elements.

 

Diving into PID Control

While odometry tells the robot where it is, PID control determines how it gets there. PID stands for Proportional, Integral, Derivative, and its a control process that determines how much and how quickly correction is applied to the robot so it can smoothly reach its target position, also known as a reference or a setpoint.

The Components of PID Control

  1. Proportional (P):

    • Purpose: Reacts to the current error—the difference between the desired reference (target position) and the current position.

    • Function: The larger the error, the stronger the corrective action.

    • Technical Detail: P_output = Kp * error

      • Kp is the proportional gain constant.

      • A higher Kp makes the robot respond more aggressively but can cause overshoot if too high.

    • Example of Proportional Component: Imagine the robot is 10 cm away from the target. The proportional term will apply a force directly proportional to this 10 cm error. The farther the robot is from the target, the greater the force applied. This pushes the robot toward the target but might cause it to overshoot because it only responds to the current error without considering the path taken to reach it.

  2. Integral (I):

    • Purpose: Addresses accumulated past errors.

    • Function: Summarizes the error over time and eliminates residual steady-state errors that the proportional term can't correct.

    • Technical Detail: I_output = Ki ∑ error dt

      • Ki is the integral gain constant.

      • Accumulates the error over time (∑ error * dt), where dt is the time interval.

      • Can correct small errors but may cause instability if too high due to accumulated error (integral windup).

    • Example of the Integral Component: Let’s say there’s friction on the track, causing the robot to stop slightly short of the target even though it’s moving in the right direction. This persistent small error would accumulate over time. The integral term sums these small errors, building up a corrective force that helps the robot overcome friction and reach the exact target position. Essentially, it helps correct for any consistent biases that the proportional term alone can't handle.

  3. Derivative (D):

    • Purpose: Predicts future errors based on the rate of change.

    • Function: Dampens the response, reducing overshoot and oscillations.

    • Technical Detail: D_output = Kd * (error - previous_error) / dt

      • Kd is the derivative gain constant.

      • Considers how quickly the error is changing.

    • Example of the Derivative Component: Now, as the robot approaches the target, the derivative term measures the rate at which the robot is closing in on the target. If the robot is moving too quickly and could overshoot, the derivative term will slow it down by applying a counteracting force, preventing oscillation around the target. This helps dampen the motion and smooth out the approach, ensuring the robot doesn’t oscillate or overshoot.

Combining the PID Components

The total PID output is the sum of all three components:

PID_output = P_output + I_output + D_output
Changing these parameter values is what it means to "tune a PID controller". They change how the controller behaves.

This output adjusts the robot's motors to correct its path.

Tuning PID Parameters

  • Start with P: Adjust Kp until the robot responds adequately without excessive overshoot.

  • Add D: Introduce Kd to reduce overshoot and dampen oscillations.

  • Integrate I Carefully: Add Ki if there is a steady-state error that P and D can't eliminate, but be cautious to prevent integral windup.

Our Experience with PID Control

By implementing PID control, we achieved:

  • Smooth Movements: The robot accelerates and decelerates gently, reducing mechanical stress.

  • Precise Positioning: It stops exactly where we want it to, essential for tasks like placing game elements.

  • Consistency: Improved repeatability in autonomous routines across different matches.

 

From 3-Pod to 2-Pod Odometry with goBILDA Pinpoint

Last season, we used a traditional 3-pod odometry system, which involved:

  • Three Odometry Pods: Two pods tracked forward/backward movement, and the third pod measured lateral movement to calculate the robot's heading.

  • Challenges:

    • Space Constraints: Three pods took up significant space.

    • Mechanical Complexity: More parts increased the risk of failures.

    • Wheel Slippage: The third pod was prone to slippage, affecting heading accuracy.

We also tried using the RevHub's built-in IMU to replace the third pod, but:

  • Slow Update Rate: The RevHub IMU's refresh rate was too low for our needs.

  • Less Accuracy: It didn't provide the precision required for consistent autonomous routines.

Why We Switched to goBILDA's Pinpoint Odometry System

The goBILDA Pinpoint Odometry System offered solutions to our problems:

  1. High Refresh Rate IMU:

    • 1,500 Hz Update Rate: Updates position every 0.00065 seconds.

    • Advantage: Minimizes the distance traveled between updates, reducing cumulative errors and improving heading accuracy.

  2. Reduced Mechanical Complexity:

    • Only 2 Pods Needed: Eliminates the third pod.

    • Advantage: Saves space and reduces potential mechanical failures.

  3. Pre-Calibrated IMU:

    • High Precision: goBILDA calibrates each IMU to a 0.002% error margin.

    • Advantage: Provides reliable heading information without the need for constant recalibration.

  4. Optimized for FTC:

    • Designed Specifically for Dead-Wheel Odometry: Ensures compatibility with FTC robots.

    • Sensor Fusion Algorithm: Combines data from encoders and the IMU for accurate pose estimation.

Instead of estimating your position every 0.01 - 0.03 seconds, the Pinpoint estimates your robot’s position every 0.00065 seconds.

Technical Advantages of goBILDA's System

  • Constant Velocity Pose Estimation Algorithm:

    • Accounts for the robot's velocity to improve position estimates.

    • Reduces errors caused by acceleration and deceleration phases.

  • Reduced Slippage Impact:

    • High-frequency updates allow the system to detect and correct for slippage quickly.

    • Improves accuracy during rapid movements and turns.

  • Integration with Control Systems:

    • Compatible with common FTC programming environments.

    • Easy to interface via standard communication protocols.

 

Comparing 3-Pod and goBILDA's 2-Pod Systems

Feature

3-Pod System

goBILDA 2-Pod System + IMU

Number of Pods

3

2

Heading Measurement

Third odometry pod

High-speed IMU

Update Rate

100-300 Hz

1,500 Hz

Mechanical Complexity

Higher

Lower

Space Requirements

More space needed

Compact design

Accuracy

Prone to slippage errors

High precision with calibration

Ease of Calibration

Manual calibration required

Pre-calibrated IMU

Impact of Slippage

Significant

Minimized

Integration Effort

Moderate

Easy with goBILDA support

 

Implementing the goBILDA System: Our Experience

Setup and Integration

  • Installation:

    • Mounted the two odometry pods with omni wheels securely on the robot chassis.

    • Connected the goBILDA Pinpoint Odometry Computer to our control system via I2C.

  • Configuration:

    • Updated our codebase to interface with the goBILDA API.

    • Adjusted our autonomous routines to utilize the new, more accurate position data.

Results Achieved

  • Improved Autonomous Performance:

    • Higher Accuracy: Our robot consistently reached target positions within a smaller margin of error.

    • Faster Movements: With accurate real-time data, we increased our robot's speed without sacrificing precision.

  • Reliability:

    • Reduced Mechanical Issues: Fewer components led to fewer failures during matches.

    • Consistent Heading: The high-speed IMU provided stable orientation data even during quick turns.

  • Ease of Use:

    • Simplified Calibration: The pre-calibrated IMU saved time during setup.

    • Support Resources: goBILDA provided documentation and support, easing the integration process.

 

Getting Technical with PID Control in Our Robot

To fully leverage the precise data from the goBILDA system, we fine-tuned our PID controllers.

Motor Control with PID

  • Drive Motors:

    • Implemented PID controllers to adjust motor power based on the error between desired and actual positions.

    • Used encoder feedback to measure wheel rotations.

  • Tuning Process:

    • Step 1: Set Ki and Kd to zero, increase Kp until the robot responds promptly without overshooting excessively.

    • Step 2: Increase Kd to reduce overshoot and dampen oscillations.

    • Step 3: Introduce Ki carefully to eliminate any steady-state error.

Addressing Common Issues

  • Integral Windup:

    • Occurs when the integral term accumulates a large error during periods when the actuator (motor) cannot respond quickly enough.

    • Solution: Implemented integral windup guarding by limiting the maximum value of the integral term.

  • Noise and Derivative Kick:

    • High-frequency noise can cause the derivative term to fluctuate rapidly.

    • Solution: Applied a low-pass filter to the derivative calculation to smooth out the noise.

Multi-Axis PID Control

  • Separate Controllers for X and Y Axes:

    • Managed movements in each axis independently to simplify control logic.

    • Adjusted PID parameters for each axis based on robot dynamics.

  • Heading Control:

    • Implemented a PID controller for rotational movement using the IMU's heading data.

    • Ensured the robot maintains the correct orientation during movements.

 

Tips for Other Teams

Based on our experience, here are some recommendations:

  1. Invest in Accurate Odometry:

    • The precision of your robot's navigation is only as good as the data it receives. Systems like goBILDA's Pinpoint can significantly enhance performance.

  2. Utilize Omni Wheels for Odometry Pods:

    • They reduce slippage and provide more accurate readings, especially during complex maneuvers.

  3. Fine-Tune Your PID Controllers:

    • Spend time tuning your PID parameters. Small adjustments can make a big difference in performance.

  4. Monitor for Integral Windup:

    • Be aware of potential issues with the integral term and implement safeguards.

  5. Filter Sensor Data:

    • Apply filtering techniques to reduce the impact of noise on your control algorithms.

  6. Test Extensively:

    • Run your robot through various autonomous routines to identify and address issues before competition.

 

Conclusion

Our switch to the goBILDA Pinpoint Odometry System, combined with carefully tuned PID control, has greatly improved our robot's performance in FTC competitions. We've achieved:

  • Enhanced Accuracy: More precise navigation and consistent autonomous routines.

  • Increased Speed: Ability to move faster without sacrificing control.

  • Simplified Design: Reduced mechanical complexity, saving space and reducing failure points.

We hope our experiences help your team in your robotics journey. Remember, investing time in understanding and implementing odometry and PID control can pay off significantly on the field.

Good luck teams, see you at the next competition!

 

References

Recent Posts

See All

Subscribe

Subscribe to our mailing list for regular updates on news, events, insightful blogs, and free code!

Thanks for subscribing!

bottom of page