-
Notifications
You must be signed in to change notification settings - Fork 2
Feature: Motion profiling #36
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 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.
|
|
||
| MotionProfileGenerator::MotionProfileGenerator() {} | ||
|
|
||
| MotionProfile MotionProfileGenerator::generateProfile(Pose[] waypoints, double maxVelocity, double acceleration) { |
Copilot
AI
Oct 25, 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.
C++ does not support array syntax Pose[] in function parameters. Use std::vector<Pose> or const std::vector<Pose>& instead.
| 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) { |
| totalDistance += math::hypot( | ||
| waypoints[i].x - waypoints[i-1].x, waypoints[i].y - waypoints[i-1].y); |
Copilot
AI
Oct 25, 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.
Use std::hypot from <cmath> instead of math::hypot. The standard library function is the idiomatic choice in C++.
| this.distanceMap = distanceMap; | ||
| this.totalDistance = totalDistance; | ||
| this.maxVelocity = maxVelocity; | ||
| this.endAccelerationDistance = endAccelerationDistance; | ||
| this.startDecelerationDistance = startDecelerationDistance; |
Copilot
AI
Oct 25, 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.
C++ uses this-> or direct member access, not this. syntax. Change to this->distanceMap or simply distanceMap in the member initializer list.
| 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; |
| double dist = math::hypot( | ||
| pose.x - distancePair.first.x, | ||
| pose.y - distancePair.first.y); |
Copilot
AI
Oct 25, 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.
Use std::hypot from <cmath> instead of math::hypot. The standard library function is the idiomatic choice in C++.
| * @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); |
Copilot
AI
Oct 25, 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.
C++ does not support array syntax Pose[] in function parameters. Use std::vector<Pose> or const std::vector<Pose>& instead.
| #include "pose.h" | ||
| #include "math.h" | ||
|
|
||
| MotionProfileGenerator::MotionProfileGenerator() {} |
Copilot
AI
Oct 25, 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 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.
| MotionProfileGenerator::MotionProfileGenerator() {} |
| odom->init(); | ||
| } | ||
|
|
||
| TankDrive::~TankDrive() { |
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.
I wasn't sure if I should change this, but should we be deleting the odometry here as well?
No description provided.