-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/pure pursuit #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Pure Pursuit path following controller for autonomous robot navigation. The implementation provides an asynchronous controller that computes motor velocities based on lookahead points along a predefined path.
Key changes:
- Adds
AsyncAdaptivePurePursuitControllerclass with path loading, lookahead point calculation, and curvature-based control - Integrates the controller with existing tank drive and odometry systems
- Supports loading paths from CSV files
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/purepusuit.cpp | Implements the Pure Pursuit controller with path following logic and control loop |
| include/purepursuit.h | Declares the controller class, PathPoint structure, and public/private interfaces |
| include/subsystems.h | Adds purepursuit.h to subsystems includes |
| include/main.h | Adds purepursuit.h to main includes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (path.empty()) return {0, 0, 0, 0}; | ||
|
|
||
| // Simple nearest-point + lookahead approach | ||
| double minDist = 1e9; |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a magic number 1e9 as an initial distance is unclear and could overflow for certain coordinate systems. Use std::numeric_limits<double>::max() from <limits> or std::numeric_limits<double>::infinity() for a clearer and more robust implementation.
| } | ||
| } | ||
|
|
||
| int lookaheadIdx = std::min(nearestIdx + 5, (int)path.size() - 1); |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 5 is hardcoded for lookahead index offset. This should either be calculated based on lookaheadDist parameter (which is currently unused), or extracted as a named constant to clarify its purpose and make it configurable.
| int lookaheadIdx = std::min(nearestIdx + 5, (int)path.size() - 1); | |
| // Find the first point at least lookaheadDist away from the robot pose, starting from nearestIdx | |
| int lookaheadIdx = nearestIdx; | |
| double accumDist = 0.0; | |
| for (int i = nearestIdx; i < static_cast<int>(path.size()) - 1; ++i) { | |
| double dx = path[i + 1].x - path[i].x; | |
| double dy = path[i + 1].y - path[i].y; | |
| accumDist += std::sqrt(dx * dx + dy * dy); | |
| if (accumDist >= lookaheadDist) { | |
| lookaheadIdx = i + 1; | |
| break; | |
| } | |
| } | |
| // Clamp to last point if we run out of path | |
| lookaheadIdx = std::min(lookaheadIdx, static_cast<int>(path.size()) - 1); |
| #include <cmath> | ||
| #include <iostream> | ||
|
|
||
| #include "tank_drive.h" |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forward declaration would be sufficient here since the class only stores a pointer to TankDrive. Replace the include with class TankDrive; to reduce compilation dependencies and improve build times.
| #include "tank_drive.h" | |
| class TankDrive; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
wrote pure pursuit, based off existing code, adapted for our codebase
#18