A complete Pure Pursuit path following system for FTC robots using Java.
- True Pure Pursuit Algorithm - Not just PID to waypoints, but actual lookahead point following
- Multiple Path Types - LinearPath, CubicPath, PolyLine, and PathChain support
- Adaptive Control - Velocity adjustment based on path curvature
- Multiple Localizers - Support for Pinpoint, SparkFun OTOS, and Three Dead Wheel
- Real-time Tuning - FTC Dashboard integration for parameter adjustment
- Comprehensive Examples - Ready-to-use OpModes for testing and learning
- Basic Usage:
// Initialize drive system
MecanumDrive drive = new MecanumDrive(hardwareMap, telemetry, startPose);
// Create a path
LinearPath path = new LinearPath(
new Point(0, 0), // Start point
new Point(48, 24) // End point
);
// Follow the path
drive.followPath(path);
// Main loop
while (opModeIsActive() && drive.isFollowingPath()) {
drive.updateLocalizer();
drive.updatePurePursuit();
sleep(20); // 50Hz update rate
}-
Configuration:
- Set your localizer type in
DriveConstants.LOCALIZER_CLASS - Configure motor names in
DriveConstants.MotorConfig - Tune parameters in
DriveConstants.TunableParams
- Set your localizer type in
-
Testing:
- Run
SimplePurePursuitTestfor basic functionality - Use
PurePursuitTunerwith FTC Dashboard for parameter optimization - Try
PurePursuitExamplefor advanced scenarios
- Run
- LinearPath - Straight line between two points
- CubicPath - Smooth curved path using 4 control points
- PolyLine - Multi-segment path through waypoints
- PathChain - Combine multiple paths into one sequence
LOOKAHEAD_DISTANCE- How far ahead to look on the path (6-24 inches)MAX_VELOCITY- Maximum robot speed (inches/second)CURVATURE_VELOCITY_SCALING- How much to slow down for curvesPATH_COMPLETION_TOLERANCE- How close to path end to stop
- Start with
SimplePurePursuitTestto verify basic functionality - Use
PurePursuitTunerwith FTC Dashboard for real-time parameter adjustment - Adjust
LOOKAHEAD_DISTANCE:- Too small = oscillation and instability
- Too large = cutting corners and overshoot
- Tune
MAX_VELOCITYbased on your robot's capabilities - Adjust
CURVATURE_VELOCITY_SCALINGfor smooth cornering
- Adaptive Lookahead - Automatically adjusts based on robot speed
- Path Visualization - Real-time path display on FTC Dashboard
- Progress Tracking - Monitor path completion percentage
- Smooth Velocity Control - Automatic speed adjustment for curves
Main Methods:
followPath(Path path)- Start following a pathupdatePurePursuit()- Update control (call in main loop)stopPathFollowing()- Stop path followingisFollowingPath()- Check if currently following a pathgetPathProgress()- Get completion percentage (0.0 to 1.0)
Legacy Support:
- Original waypoint methods still available for backwards compatibility
setTarget(WayPoint)andupdatePIDS()work alongside pure pursuit
- FTC SDK 8.0+
- FTC Dashboard (for tuning)
- Supported localizer (Pinpoint recommended)
- Mecanum drive system
This implementation is designed for FTC teams wanting professional-grade path following. The pure pursuit algorithm provides smooth, predictable robot movement that's essential for competitive autonomous routines.