Refactor quintic optimizer into a pure 2D backend#2
Open
zefew6 wants to merge 5 commits intoMarineRock10:mainfrom
Open
Refactor quintic optimizer into a pure 2D backend#2zefew6 wants to merge 5 commits intoMarineRock10:mainfrom
zefew6 wants to merge 5 commits intoMarineRock10:mainfrom
Conversation
- switch the planner backend to quintic splines with per-segment time variables and acceleration-aware penalties - decouple TrajectoryOptimizer from GridMap and A* through pluggable trajectory environment interfaces, including a safe corridor hook and grid map adapter - add a pure backend demo and make test_opt save visualization images in headless environments
There was a problem hiding this comment.
Pull request overview
This PR refactors the trajectory optimization backend to be “pure 2D” by decoupling it from GridMap/A* through a pluggable environment interface, switching the spline backend to quintic with per-segment timing variables, and improving demos for headless visualization output.
Changes:
- Introduces
TrajectoryEnv(with optional SDF + safe-corridor hooks) and aGridMapEnvadapter, and updates the optimizer/demo wiring to use it. - Refactors
TrajectoryOptimizerto use quintic splines, add acceleration-aware penalties/metrics, and optimize per-segment time variables. - Adds a pure-backend demo executable and updates
test_optvisualization to save PNGs in headless environments.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/test_opt.cpp |
Saves visualizations to PNG and updates optimizer construction to use GridMapEnv; adds accel metric printing. |
src/test_backend.cpp |
New pure-backend demo using SafeCorridorEnv without GridMap/A*. |
include/perception_tool/grid_map_env.hpp |
Adds GridMapEnv adapter implementing TrajectoryEnv from GridMap SDF/gradient. |
include/backend_tool/traj_opt.hpp |
Refactors optimizer API to accept TrajectoryEnv, switches to quintic spline backend, adds per-segment timing + accel/corridor penalties & metrics. |
include/backend_tool/traj_env.hpp |
Defines TrajectoryEnv interface and SafeCorridorEnv implementation. |
CMakeLists.txt |
Adds test_backend executable. |
.gitignore |
Ignores build/ and *.png. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+205
to
+206
| cv::imwrite(output_path, img); | ||
| std::cout << "Saved visualization to " << output_path << std::endl; |
include/backend_tool/traj_opt.hpp
Outdated
Comment on lines
+485
to
+488
| std::cout << "Cost breakdown - Vel: " << v_cost | ||
| << ", Acc: " << a_cost | ||
| << ", Coll: " << occ_cost | ||
| << ", Corridor: " << corridor_cost << std::endl; |
Comment on lines
109
to
111
| params.piece_len = astar_traj.total_length / astar_traj.total_time; | ||
| params.total_time = astar_traj.total_time; | ||
| params.total_len = astar_traj.total_length; |
- replace the local spline core with the latest version from Bziyue/SplineTrajectory - adapt the quintic optimizer to the new trajectory, energy-gradient, and propagateGrad interfaces - keep the 2D pure-backend planner flow compiling and running with the updated spline backend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
switch the planner backend to quintic splines with per-segment time variables and acceleration-aware penalties
decouple TrajectoryOptimizer from GridMap and A* through pluggable trajectory environment interfaces, including a safe corridor hook and grid map adapter
add a pure backend demo and make test_opt save visualization images in headless environments