Skip to content

Speed limit#9

Open
The-Sole-King wants to merge 3 commits intomainfrom
speed_limit
Open

Speed limit#9
The-Sole-King wants to merge 3 commits intomainfrom
speed_limit

Conversation

@The-Sole-King
Copy link

Adds MAX_SPEED_MPS, MAX_LAT_ACC_MPS2, forward limit

Adds curvature → turn radius → turn-speed

Clamps speed using both global + lateral constraints

Adds /ap1/planning/current_speed_limit publisher

Fully contained inside planning package

Does not affect other AP1 submodules

@The-Sole-King The-Sole-King requested a review from a team as a code owner November 28, 2025 06:44
@alyashour
Copy link
Member

@The-Sole-King please resolve merge conflict before review.

Copy link
Member

@alyashour alyashour left a comment

Choose a reason for hiding this comment

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

Hi @The-Sole-King really good work! Need some changes pls.

// send speed msg to ctrl
speed_profile_pub_->publish(create_speed_profile());
// 1. Create route
auto route = create_route();
Copy link
Member

Choose a reason for hiding this comment

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

This code creates the route twice, this is inefficient. Create a ref to the route instead when it's created and pass that into create_speed_profile.

// 3. Publish current speed limit (for UI)
// Use the first waypoint's computed limit.
std_msgs::msg::Float64 limit_msg;
if (!speed_profile.speeds.empty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of combining the metrics into 1 and publishing every frame add a service that responds with:

  • hardware speed limit (hard coded config)
  • sector speed limit (straight ahead speed limit of the current sector. Sectors aren't implemented yet so just output -1 or infinity or something)
  • the lateral and forward max acceleration (also hard coded in config)

While planning might need to calculate the car's lat/lon acceleration, there's no need to publish that info to Console.

Comment on lines +41 to +47
// ===================== SPEED PROFILE CONSTANTS ===================== //

constexpr double MAX_SPEED_MPS = 6.0; // Global max speed
constexpr double MAX_LAT_ACC_MPS2 = 1.5; // Lateral accel limit (turning)
constexpr double MAX_FWD_ACC_MPS2 = 2.0; // Forward accel limit
constexpr double MIN_TURN_RADIUS = 0.01; // Avoid division by zero

Copy link
Member

Choose a reason for hiding this comment

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

Load these values from a config file. This is an example of this from Control: https://github.com/WE-Autopilot/control/blob/6fe7ee518dd046b2ba135196c259269cc74542ed/src/ackermann_controller.cpp#L89-L105

Although apparently there is a way to do it through ROS - might be worth looking into.

double dy2 = y3 - y2;

double cross = dx1 * dy2 - dy1 * dx2;
[[maybe_unused]] double dot = dx1 * dx2 + dy1 * dy2;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this kept in if unused?

// 2. Dynamic turn-based speed profiling
// =======================================================================
double last_speed = this->speed_; // previously commanded speed
double dt = 0.1; // assume 10 Hz planning loop
Copy link
Member

Choose a reason for hiding this comment

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

No need to assume, see PlannerNode.rate_hz

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.

2 participants