Files
weevil/templates/localization/docs/GRID_SYSTEM.md
Eric Ratliff 636e1252dc feat: Add localization template with grid-based sensor fusion
Implements comprehensive robot localization system as third template option.
Teams can now start with professional positioning and navigation code.

Template Features:
- 12x12 field grid system (12-inch cells)
- Multi-sensor fusion (encoders, IMU, vision)
- Kalman-filter-style sensor combination
- Fault-tolerant positioning (graceful degradation)
- 21 files, ~1,500 lines, 3 passing tests

Core Components:
- GridCell/Pose2D/FieldGrid - Coordinate system
- RobotLocalizer - Sensor fusion engine
- OdometryTracker - Dead reckoning from encoders
- ImuLocalizer - Heading from gyroscope
- VisionLocalizer - Position from AprilTags

Sensor Fusion Strategy:
Priority 1: Vision (AprilTags) → ±2" accuracy, 100% confidence
Priority 2: IMU + Odometry → ±4" accuracy, 70% confidence
Priority 3: Odometry only → ±12" accuracy, 40% confidence

System gracefully degrades when sensors fail, maintaining operation
even with partial sensor availability.

Hardware Abstraction:
- Interfaces (Encoder, GyroSensor, VisionCamera)
- Mock implementations for unit testing
- Teams implement FTC wrappers for their hardware

Documentation:
- LOCALIZATION_GUIDE.md - System architecture and usage
- GRID_SYSTEM.md - Field coordinate reference
- README.md - Quick start and examples

Usage:
  weevil new my-robot --template localization
  cd my-robot
  ./gradlew test  # 3 tests pass in < 1 second

This teaches professional robotics concepts (sensor fusion, fault
tolerance, coordinate systems) not found in other FTC tools. Positions
Nexus Workshops as teaching advanced autonomous programming.

Updated src/templates/mod.rs to register localization template with
proper metadata and feature descriptions.

All tests passing (10/10 template tests).
2026-02-03 00:46:00 -06:00

1.1 KiB

Field Grid System

Grid Layout

12x12 cells, each 12" x 12":

    0   1   2   3   4   5   6   7   8   9  10  11
11  .   .   .   .   .   .   .   .   .   .   .   B
10  .   .   .   .   .   .   .   .   .   .   .   .
 9  .   .   .   .   .   .   .   .   .   .   .   .
 8  .   .   .   .   .   .   .   .   .   .   .   .
 7  .   .   .   .   .   .   .   .   .   .   .   .
 6  .   .   .   .   .   X   .   .   .   .   .   .
 5  .   .   .   .   .   .   .   .   .   .   .   .
 4  .   .   .   .   .   .   .   .   .   .   .   .
 3  .   .   .   .   .   .   .   .   .   .   .   .
 2  .   .   .   .   .   .   .   .   .   .   .   .
 1  .   .   .   .   .   .   .   .   .   .   .   .
 0  R   .   .   .   .   .   .   .   .   .   .   .

R = Red backstage (0,0)
B = Blue backstage (11,11)
X = Center (6,6)

Usage

GridCell cell = new GridCell(5, 7);
double dist = cell.distanceTo(FieldGrid.CENTER);
double angle = cell.angleTo(FieldGrid.BLUE_BACKSTAGE);

Common Locations

FieldGrid.RED_BACKSTAGE    // (0, 0)
FieldGrid.BLUE_BACKSTAGE   // (11, 11)
FieldGrid.CENTER           // (6, 6)