1.4 KiB
1.4 KiB
Robot Localization Guide
What is Localization?
Answering: "Where is my robot on the field?"
The Grid System
12ft x 12ft field → 12x12 grid of 12" cells
Cell (0,0) = Red backstage
Cell (11,11) = Blue backstage
Cell (6,6) = Center
Sensor Fusion
Combine three sensors:
-
Odometry (Encoders) - Track wheel rotation
- Accuracy: ±1" per foot (cumulative drift)
- Always available
-
IMU (Gyroscope) - Measure heading
- Accuracy: ±2° (non-cumulative)
- Corrects heading drift
-
Vision (AprilTags) - Detect position markers
- Accuracy: ±2" (when visible)
- Ground truth - resets drift
Fusion Strategy
if vision available:
position = vision (most accurate)
correct odometry
elif IMU available:
position = odometry
heading = IMU
else:
position = odometry only (dead reckoning)
Fault Tolerance
| Sensors | Accuracy | Confidence |
|---|---|---|
| All 3 | ±2" | 100% |
| Odometry + IMU | ±4" | 70% |
| Odometry only | ±12" | 40% |
System keeps working when sensors fail!
Usage
RobotLocalizer localizer = new RobotLocalizer(odometry, imu, vision);
localizer.setInitialPose(new Pose2D(12, 12, 0));
while (opModeIsActive()) {
localizer.update();
GridCell cell = localizer.getCurrentCell();
double confidence = localizer.getConfidence();
// Make decisions based on position
}
See README.md for full examples.