Skip to content

Conversation

@greenbear26
Copy link
Contributor

No description provided.

@greenbear26 greenbear26 requested a review from Copilot October 25, 2025 21:00
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 motion profiling functionality for path following, enabling smooth velocity control along a trajectory. The implementation calculates acceleration and deceleration phases based on waypoints, providing velocity targets at any position along the path.

Key changes:

  • Motion profile generation from waypoints with configurable velocity and acceleration constraints
  • Velocity calculation at any position along the path using trapezoidal motion profiling
  • Distance mapping infrastructure to track accumulated distances along waypoints

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

File Description
src/motionprofiling/motion_profile_generator.cpp Implements profile generation by calculating distances between waypoints and determining acceleration/deceleration boundaries
src/motionprofiling/motion_profile.cpp Implements velocity calculation based on position using square root relationship for acceleration phases
include/motionprofiling/motion_profile_generator.h Defines the API for generating motion profiles from waypoints
include/motionprofiling/motion_profile.h Defines the MotionProfile class interface and data members

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 5 to 8

MotionProfileGenerator::MotionProfileGenerator() {}

MotionProfile MotionProfileGenerator::generateProfile(Pose[] waypoints, double maxVelocity, double acceleration) {
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ does not support array syntax Pose[] in function parameters. Use std::vector<Pose> or const std::vector<Pose>& instead.

Suggested change
MotionProfileGenerator::MotionProfileGenerator() {}
MotionProfile MotionProfileGenerator::generateProfile(Pose[] waypoints, double maxVelocity, double acceleration) {
#include <vector>
MotionProfileGenerator::MotionProfileGenerator() {}
MotionProfile MotionProfileGenerator::generateProfile(const std::vector<Pose>& waypoints, double maxVelocity, double acceleration) {

Copilot uses AI. Check for mistakes.
Comment on lines 12 to 13
totalDistance += math::hypot(
waypoints[i].x - waypoints[i-1].x, waypoints[i].y - waypoints[i-1].y);
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::hypot from <cmath> instead of math::hypot. The standard library function is the idiomatic choice in C++.

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 13
this.distanceMap = distanceMap;
this.totalDistance = totalDistance;
this.maxVelocity = maxVelocity;
this.endAccelerationDistance = endAccelerationDistance;
this.startDecelerationDistance = startDecelerationDistance;
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ uses this-> or direct member access, not this. syntax. Change to this->distanceMap or simply distanceMap in the member initializer list.

Suggested change
this.distanceMap = distanceMap;
this.totalDistance = totalDistance;
this.maxVelocity = maxVelocity;
this.endAccelerationDistance = endAccelerationDistance;
this.startDecelerationDistance = startDecelerationDistance;
this->distanceMap = distanceMap;
this->totalDistance = totalDistance;
this->maxVelocity = maxVelocity;
this->endAccelerationDistance = endAccelerationDistance;
this->startDecelerationDistance = startDecelerationDistance;

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 26
double dist = math::hypot(
pose.x - distancePair.first.x,
pose.y - distancePair.first.y);
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::hypot from <cmath> instead of math::hypot. The standard library function is the idiomatic choice in C++.

Copilot uses AI. Check for mistakes.
* @param acceleration The acceleration to be used in the motion profile.
* @return A MotionProfile object representing the generated motion profile.
*/
static MotionProfile generateProfile(Pose[] waypoints, double maxVelocity, double acceleration);
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ does not support array syntax Pose[] in function parameters. Use std::vector<Pose> or const std::vector<Pose>& instead.

Copilot uses AI. Check for mistakes.
#include "pose.h"
#include "math.h"

MotionProfileGenerator::MotionProfileGenerator() {}
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor is defined but generateProfile is declared as static in the header. Either make the method non-static and remove the constructor, or use the constructor if instance state is needed.

Suggested change
MotionProfileGenerator::MotionProfileGenerator() {}

Copilot uses AI. Check for mistakes.
odom->init();
}

TankDrive::~TankDrive() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if I should change this, but should we be deleting the odometry here as well?

@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.

add trapezoidal motion profiling

3 participants