Skip to content

Trajectory blending with new trajectory deferral#2401

Open
vedh1234 wants to merge 3 commits into
ros-controls:masterfrom
vedh1234:feat--trajectory-blending-with-deferring-the-new-traj
Open

Trajectory blending with new trajectory deferral#2401
vedh1234 wants to merge 3 commits into
ros-controls:masterfrom
vedh1234:feat--trajectory-blending-with-deferring-the-new-traj

Conversation

@vedh1234

@vedh1234 vedh1234 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Partial port of the ROS 1 "update existing trajectory" behavior to ROS 2 joint_trajectory_controller.

Related to #84

What this PR does:

  • Adds a new parameter allow_trajectory_blending (default: true)
  • When enabled, a trajectory with a future header.stamp is deferred: the currently active trajectory continues executing until that start time arrives, then the new trajectory is installed
  • This eliminates the legacy behavior where a future-stamped trajectory would immediately kill the active trajectory and create a slow spline ramp to the first point
  • Deferred trajectories are correctly dropped on goal cancellation, controller deactivation, and controller reset
  • Action Server feedback/tolerance checking is suppressed during the deferral period to prevent spurious aborts
  • Immediate trajectories (stamp = 0 or stamp <= now) behave exactly as before (no behavioral change)

What this PR does NOT target: ( Compared to ROS1 blending feature )

  • Does not allow omitted joints to continue their old trajectory after the new one starts (ROS 1 full blend). Omitted joints freeze at their current position via fill_partial_goal(), same as legacy ROS 2 behavior
  • Does not handle speed scaling during the deferral period. The trigger uses wall-clock time, so if speed_scaling != 1.0, there will be a positional mismatch at handoff
  • Does not track multiple action goals simultaneously. The new goal immediately preempts the old one at the Action Server level; only the physical trajectory execution is deferred

Is this user-facing behavior change?

Yes. When allow_trajectory_blending is true (default), the active trajectory will continue running until the new trajectory's start time.

Did you use Generative AI?

Yes, Google Gemini and Claude were used to make improvements in manually written code, architectural analysis, edge-case review.

Additional Information

TODOs

To send us a pull request, please:

  • Fork the repository.
  • Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
  • Ensure local tests pass. (colcon test and pre-commit run (requires you to install pre-commit by pip3 install pre-commit)
  • Commit to your fork using clear commit messages.
  • Send a pull request, answering any default questions in the pull request interface.
  • Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.47826% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.58%. Comparing base (68630ae) to head (69e118d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ory_controller/src/joint_trajectory_controller.cpp 94.44% 0 Missing and 2 partials ⚠️
...ntroller/test/test_trajectory_controller_utils.hpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2401      +/-   ##
==========================================
- Coverage   85.61%   85.58%   -0.04%     
==========================================
  Files         148      148              
  Lines       15837    15797      -40     
  Branches     1339     1339              
==========================================
- Hits        13559    13520      -39     
+ Misses       1792     1790       -2     
- Partials      486      487       +1     
Flag Coverage Δ
unittests 85.58% <93.47%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...jectory_controller/joint_trajectory_controller.hpp 62.50% <100.00%> (+22.50%) ⬆️
...ory_controller/test/test_trajectory_controller.cpp 99.35% <100.00%> (+0.01%) ⬆️
...ntroller/test/test_trajectory_controller_utils.hpp 84.45% <0.00%> (ø)
...ory_controller/src/joint_trajectory_controller.cpp 84.31% <94.44%> (+0.32%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@christophfroehlich christophfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Partial port of the ROS 1 "update existing trajectory" behavior to ROS 2 joint_trajectory_controller.

Fixes #84

For documentation here, what is different from the ROS 1 behavior/what is maybe missing to port?

Please also update the release_notes and update the documentation.

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