Skip to content

Conversation

@vvictorrr
Copy link

@vvictorrr vvictorrr commented Oct 30, 2025

wrote pure pursuit, based off existing code, adapted for our codebase

#18

@vvictorrr vvictorrr requested a review from ctgoyette October 30, 2025 00:40
@greenbear26 greenbear26 requested a review from Copilot November 4, 2025 01:48
Copy link

Copilot AI left a 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 AsyncAdaptivePurePursuitController class 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;
Copy link

Copilot AI Nov 4, 2025

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.

Copilot uses AI. Check for mistakes.
}
}

int lookaheadIdx = std::min(nearestIdx + 5, (int)path.size() - 1);
Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
#include <cmath>
#include <iostream>

#include "tank_drive.h"
Copy link

Copilot AI Nov 4, 2025

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.

Suggested change
#include "tank_drive.h"
class TankDrive;

Copilot uses AI. Check for mistakes.
vvictorrr and others added 2 commits November 10, 2025 15:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ctgoyette ctgoyette linked an issue Nov 13, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pure pursuit

2 participants