Skip to content
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

[JTC] Process tolerances sent with action goal #716

Merged
merged 32 commits into from
Jul 3, 2024

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Jul 24, 2023

From here:

JointTrajectoryController ignores goal_time_tolerance set via FollowJointTrajectory.Goal.goal_time_tolerance together with path_tolerance and goal_tolerance .

This PR proposes a way how to process the tolerances: The tolerances from one action goal are not saved for the next one, but the default ones will be used if no tolerances are set with the following action goals.

(Temporary) deactivation is also implemented like documented in the msg definition.

From the node parameter we cannot set velocity or acceleration tolerances (except for a single stopped_velocity_tolerance for the goal tolerances of all joints). Should we add them as parameters as well, to have the same structure like the action message?

This new feature could break some existing projects, because the tolerances were just ignored and might now be breaking behaviors. Should we introduce a temporary parameter to opt-in?

Fixes #249

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2023

Codecov Report

Attention: Patch coverage is 35.29412% with 44 lines in your changes missing coverage. Please review.

Project coverage is 47.05%. Comparing base (0b43291) to head (534746c).
Report is 33 commits behind head on master.

Current head 534746c differs from pull request most recent head 34ca300

Please upload reports for the commit 34ca300 to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #716       +/-   ##
===========================================
- Coverage   71.86%   47.05%   -24.81%     
===========================================
  Files          41       41               
  Lines        3650     3925      +275     
  Branches     1794     1863       +69     
===========================================
- Hits         2623     1847      -776     
- Misses        707      780       +73     
- Partials      320     1298      +978     
Flag Coverage Δ
unittests 47.05% <35.29%> (-24.81%) ⬇️

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

Files Coverage Δ
...jectory_controller/joint_trajectory_controller.hpp 0.00% <ø> (-100.00%) ⬇️
...ory_controller/src/joint_trajectory_controller.cpp 48.15% <25.00%> (-31.38%) ⬇️
...include/joint_trajectory_controller/tolerances.hpp 45.26% <37.50%> (-30.42%) ⬇️

... and 36 files with indirect coverage changes

@mergify
Copy link
Contributor

mergify bot commented Aug 15, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

@mergify
Copy link
Contributor

mergify bot commented Aug 16, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

@mergify
Copy link
Contributor

mergify bot commented Sep 12, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

@mergify
Copy link
Contributor

mergify bot commented Sep 14, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

@christophfroehlich christophfroehlich added the backport-iron This label should be used by maintaines only! Label triggers PR backport to ROS2 Iron. label Nov 11, 2023
Copy link
Contributor

mergify bot commented Nov 15, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

@christophfroehlich christophfroehlich added the backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble. label Dec 7, 2023
Copy link
Contributor

mergify bot commented Dec 21, 2023

This pull request is in conflict. Could you fix it @christophfroehlich?

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

Few minor comments. Rest looks good to me.
Thank you for the changes!

Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Very good PR! Thanks. I have a few minor comments, but we can also merge without resolving them. They are mostly cosmetic nature.

From the node parameter we cannot set velocity or acceleration tolerances (except for a single stopped_velocity_tolerance for the goal tolerances of all joints). Should we add them as parameters as well, to have the same structure like the action message?

This would be nice to have in the follow-up PR.

This new feature could break some existing projects, because the tolerances were just ignored and might now be breaking behaviors. Should we introduce a temporary parameter to opt-in?

No. Just to add a note to migration notes.

@@ -95,6 +97,8 @@ SegmentTolerances get_segment_tolerances(Params const & params)

SegmentTolerances tolerances;
tolerances.goal_time_tolerance = constraints.goal_time;
auto logger = rclcpp::get_logger("tolerance");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe might be better to have a logger object and initialize child tolerances here of the JTC node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't had a better idea as passing the JTC logger as argument to the get_segment_tolerances methods. There is no persistent class with a configuration/constructor method to pass the logger only once.

*
* \param default_tolerances The default tolerances to use if the action goal does not specify any.
* \param goal The new action goal
* \param params The ROS Parameters
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure why do we need ROS parameters because the default tolerances should be added through parameters, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only field we need is the params.joints actually, I can change it to have a std::vector as argument instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

SegmentTolerances active_tolerances(default_tolerances);

active_tolerances.goal_time_tolerance = rclcpp::Duration(goal.goal_time_tolerance).seconds();
auto logger = rclcpp::get_logger("tolerance");
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to have a static object for this, as mentioned above because we are creating objects all the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above

Copy link
Member

Choose a reason for hiding this comment

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

Not sure that we need a header file here. Maybe just add this on top of the .cpp file. Those are not too big.

Copy link
Contributor Author

@christophfroehlich christophfroehlich Jun 24, 2024

Choose a reason for hiding this comment

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

I use it in test_tolerances.cpp and test_trajectory_actions.cpp, that's why I created this header file.
I can add it to test_trajectory_controller_utils.hpp if you prefer

Copy link
Contributor Author

@christophfroehlich christophfroehlich Jun 24, 2024

Choose a reason for hiding this comment

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

I moved it into the other utils header file, but had to mark it as [[maybe_unused]].

@christophfroehlich
Copy link
Contributor Author

Very good PR! Thanks. I have a few minor comments, but we can also merge without resolving them. They are mostly cosmetic nature.

From the node parameter we cannot set velocity or acceleration tolerances (except for a single stopped_velocity_tolerance for the goal tolerances of all joints). Should we add them as parameters as well, to have the same structure like the action message?

This would be nice to have in the follow-up PR.

I opened a follow-up issue.

This new feature could break some existing projects, because the tolerances were just ignored and might now be breaking behaviors. Should we introduce a temporary parameter to opt-in?

No. Just to add a note to migration notes.

Done.

@destogl I addressed all your comments, please have a look once again.

Test still are fine.

$ colcon test --packages-select joint_trajectory_controller
Starting >>> joint_trajectory_controller
[Processing: joint_trajectory_controller]                   
[Processing: joint_trajectory_controller]                           
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
[Processing: joint_trajectory_controller]                             
Finished <<< joint_trajectory_controller [4min 49s]                   

Summary: 1 package finished [4min 50s]

@bmagyar bmagyar merged commit 07061f9 into ros-controls:master Jul 3, 2024
5 of 20 checks passed
@christophfroehlich christophfroehlich deleted the jtc/action_tolerances branch July 3, 2024 17:57
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
(cherry picked from commit 07061f9)

# Conflicts:
#	doc/migration/Jazzy.rst
#	doc/release_notes/Jazzy.rst
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
(cherry picked from commit 07061f9)

# Conflicts:
#	doc/migration/Jazzy.rst
#	doc/release_notes/Jazzy.rst
@christophfroehlich
Copy link
Contributor Author

@bmagyar do we want to backport this to humble/iron? Then I'd update the release notes accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintaines only! Label triggers PR backport to ROS2 humble. backport-iron This label should be used by maintaines only! Label triggers PR backport to ROS2 Iron. enhancement
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

JointTrajectoryController ignores tolerances sent via action client
5 participants