Skip to content

Conversation

@urfeex
Copy link
Member

@urfeex urfeex commented Mar 24, 2025

When transferring trajectories with many waypoints it can take quite a
while until all points are transferred from the controller to the
hardware interface, especially on lower hardware_interface update rates.

With this change, execution starts as soon as enough trajectory points
are transferred to fill 5 control cycles.

This PR effectively allows reducing the hardware_interface update_rate
when using the passthrough_trajectory_controller significantly. This
will reduce the networking requirements improving the overall user
experience.

@codecov
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 0% with 82 lines in your changes missing coverage. Please review.

Project coverage is 5.58%. Comparing base (1b121b7) to head (d4c475f).
Report is 415 commits behind head on main.

Files with missing lines Patch % Lines
ur_robot_driver/src/hardware_interface.cpp 0.00% 70 Missing ⚠️
...trollers/src/passthrough_trajectory_controller.cpp 0.00% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1313      +/-   ##
========================================
+ Coverage   3.59%   5.58%   +1.99%     
========================================
  Files         13      31      +18     
  Lines        947    3113    +2166     
  Branches     152     379     +227     
========================================
+ Hits          34     174     +140     
- Misses       843    2937    +2094     
+ Partials      70       2      -68     
Flag Coverage Δ
unittests 5.58% <0.00%> (+1.99%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@urfeex urfeex force-pushed the buffering branch 2 times, most recently from 1f84b1d to 7ac040d Compare March 28, 2025 10:57
@urfeex urfeex requested a review from a team March 28, 2025 11:28
@urfeex urfeex marked this pull request as ready for review March 28, 2025 11:28
Copy link
Contributor

@urmahp urmahp left a comment

Choose a reason for hiding this comment

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

Overall looks good, added some comments.

@urfeex urfeex requested a review from urmahp March 31, 2025 12:02
@urfeex urfeex changed the title Start executing passthrogh trajectories earlier than all points are transferred. Start executing passthrough trajectories earlier than all points are transferred. Mar 31, 2025
Copy link
Contributor

@urmahp urmahp left a comment

Choose a reason for hiding this comment

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

Overall it looks good. Have small suggestions which is not really related to this PR, but is part of the touched code, so I stumbled across them.

} else if (!has_velocities(trajectory_joint_velocities_) && has_accelerations(trajectory_joint_accelerations_)) {
ur_driver_->writeTrajectorySplinePoint(trajectory_joint_positions_[i], trajectory_joint_accelerations_[i],
trajectory_times_[i]);
} else if (has_velocities(trajectory_joint_velocities_) && has_accelerations(trajectory_joint_accelerations_)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that it is not possible to create a trajectory with points, that has no velocity specified, but has accelerations? As it is now, then we will just skip those points.
Would it make sense to do something along the lines of:
ur_driver_->writeTrajectorySplinePoint(trajectory_joint_positions_[i], urcl::vector6d_t{ 0, 0, 0, 0, 0, 0 }, trajectory_joint_accelerations_[i], trajectory_times_[i]);

if (!has_velocities(trajectory_joint_velocities_) && !has_accelerations(trajectory_joint_accelerations_)) {
for (size_t i = 0; i < trajectory_joint_positions_.size(); i++) {
for (size_t i = point_index_sent; i < point_index_received; i++) {
if (!has_velocities(trajectory_joint_velocities_) && !has_accelerations(trajectory_joint_accelerations_)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that positions is always going to be part of the points received from the forward controller?
If we can end up in a situation where positions is not part of the received points, then I think we should handle it more cleanly with a separate if statement and Logging an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the current implementation that we have with the passthrough trajectory controller, that is given. But I do see the point that a better handling would be to catch that here. I would actually advocate for the same thing regarding the acceleration but no velocity. If the user wants to specify accelerations combined with 0 velocities that should be done explicitly.

I'll add catching and raising an error.

urfeex and others added 6 commits April 2, 2025 13:14
…ransferred.

When transferring trajectories with many waypoints it can take quite a
while until all points are transferred from the controller to the
hardware interface, especially on lower hardware_interface update rates.

With this change, execution starts as soon as enough trajectory points
are transferred to fill 5 control cycles.

This PR effectively allows reducing the hardware_interface update_rate
when using the passthrough_trajectory_controller significantly. This
will reduce the networking requirements improving the overall user
experience.
If we miss the new trajectory, wen cannot resize the vectors
appropriately.
Co-authored-by: Mads Holm Peters <[email protected]>
@urfeex urfeex merged commit 14f80ac into main Apr 7, 2025
7 of 10 checks passed
@urfeex urfeex deleted the buffering branch April 7, 2025 05:05
mergify bot pushed a commit that referenced this pull request Apr 7, 2025
…transferred. (#1313)

* Start executing passthrough trajectories earlier than all points are transferred.

When transferring trajectories with many waypoints it can take quite a
while until all points are transferred from the controller to the
hardware interface, especially on lower hardware_interface update rates.

With this change, execution starts as soon as enough trajectory points
are transferred to fill 5 control cycles.

This PR effectively allows reducing the hardware_interface update_rate
when using the passthrough_trajectory_controller significantly. This
will reduce the networking requirements improving the overall user
experience.

* Make sure we acknowledge a new trajectory before sending points

If we miss the new trajectory, wen cannot resize the vectors
appropriately.

(cherry picked from commit 14f80ac)

# Conflicts:
#	ur_controllers/src/passthrough_trajectory_controller.cpp
#	ur_robot_driver/urdf/ur.ros2_control.xacro
urfeex added a commit that referenced this pull request Apr 7, 2025
…transferred. (#1313)

* Start executing passthrough trajectories earlier than all points are transferred.

When transferring trajectories with many waypoints it can take quite a
while until all points are transferred from the controller to the
hardware interface, especially on lower hardware_interface update rates.

With this change, execution starts as soon as enough trajectory points
are transferred to fill 5 control cycles.

This PR effectively allows reducing the hardware_interface update_rate
when using the passthrough_trajectory_controller significantly. This
will reduce the networking requirements improving the overall user
experience.

* Make sure we acknowledge a new trajectory before sending points

If we miss the new trajectory, wen cannot resize the vectors
appropriately.
urfeex added a commit that referenced this pull request Apr 7, 2025
…transferred. (backport of #1313) (#1335)

* Start executing passthrough trajectories earlier than all points are transferred.

When transferring trajectories with many waypoints it can take quite a
while until all points are transferred from the controller to the
hardware interface, especially on lower hardware_interface update rates.

With this change, execution starts as soon as enough trajectory points
are transferred to fill 5 control cycles.

This PR effectively allows reducing the hardware_interface update_rate
when using the passthrough_trajectory_controller significantly. This
will reduce the networking requirements improving the overall user
experience.

* Make sure we acknowledge a new trajectory before sending points

If we miss the new trajectory, wen cannot resize the vectors
appropriately.

Co-authored-by: Felix Exner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants