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

Add private buffer & tf listener to PSM #654

Merged
merged 5 commits into from
Oct 7, 2021

Conversation

JafarAbdi
Copy link
Member

Description

Address #617
Fix: #646

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@schornakj
Copy link
Contributor

This fixes the issues I was seeing related to #646. Awesome!

@codecov
Copy link

codecov bot commented Aug 31, 2021

Codecov Report

Merging #654 (fee9fb0) into main (7292b9c) will decrease coverage by 0.02%.
The diff coverage is 81.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
- Coverage   54.22%   54.21%   -0.01%     
==========================================
  Files         192      192              
  Lines       20227    20224       -3     
==========================================
- Hits        10966    10962       -4     
- Misses       9261     9262       +1     
Impacted Files Coverage Δ
...it/planning_scene_monitor/planning_scene_monitor.h 33.34% <ø> (ø)
...anning_scene_monitor/src/current_state_monitor.cpp 74.41% <ø> (+0.23%) ⬆️
...nning_scene_monitor/src/planning_scene_monitor.cpp 45.31% <80.00%> (-0.18%) ⬇️
moveit_ros/moveit_servo/src/servo_node.cpp 78.19% <100.00%> (-0.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7292b9c...fee9fb0. Read the comment docs.

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

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

Having the transforms updated either through the PSM tf listener or through a CSM listener is quite ugly.

Why did you not just add a mechanism to start the tf listener in the CSM when it's used from the PSM - whether or not there are MultiDOF joints around?

{
RCLCPP_WARN(LOGGER, "The tf2_ros::Buffer is attached to tf2_ros::TransformListener and the internal tf "
"subscribers inside CurrentStateMonitor, you may want to remove the transform listener to "
"avoid duplicate addition to the same transforms");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still a very valid warning when CSM is used outside PSM.
There was probably a reason why this was added in the first place and I would be grateful for the feedback in such a case.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, we should keep the warning

Copy link
Member Author

Choose a reason for hiding this comment

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

I added this warning in the last PR to warn about the previous behavior of using an external tf listener, but since we have an internal one now it will always print this warning which may confuse users

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, so in both cases (PSM+CSM, CSM standalone) we use a dedicated thread for the tf_buffer, right? I guess there is no straight-forward way to check for external listeners anymore. It's fine to remove this warning then, IMO.
Thoughts for a follow-up: Since we don't want external listeners to run at the same time (only PSM is allowed), how about we make the current CSM constructors friend constructors for PSM and only provide public versions without tf_buffer?

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

I think this is a good step forward, especially removing the buffer from the PSM constructor.

Having the transforms updated either through the PSM tf listener or through a CSM listener is quite ugly.

I totally agree. Ideally, we would be initializing a single listener and then simply registering the CSM callback dynamically. If buffer and listener are maintained by the PSM, this would be straight forward. If we want to be able to run CSM standalone, the buffer and listener need default values in the CSM constructor.

Why did you not just add a mechanism to start the tf listener in the CSM when it's used from the PSM - whether or not there are MultiDOF joints around?

Not sure if I follow you there. Are you basically describing what I wrote above?

@henningkayser henningkayser added the blocks release This PR should be merged before the next release label Sep 14, 2021
@henningkayser henningkayser moved this from In Progress to Review in progress in Galactic/Rolling - 2.3.0 - September 10 Sep 21, 2021
Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

+1 after addressing the comments

{
RCLCPP_WARN(LOGGER, "The tf2_ros::Buffer is attached to tf2_ros::TransformListener and the internal tf "
"subscribers inside CurrentStateMonitor, you may want to remove the transform listener to "
"avoid duplicate addition to the same transforms");
Copy link
Member

Choose a reason for hiding this comment

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

I agree, we should keep the warning

Copy link
Contributor

@schornakj schornakj left a comment

Choose a reason for hiding this comment

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

I tested the latest version of this PR in the context of #646 and it also fixes the problems I'd reported there.

Copy link
Member

@tylerjw tylerjw left a comment

Choose a reason for hiding this comment

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

minor comment to help users transition to the new psm constructor

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

I think this has turned out pretty great! lgtm

@schornakj
Copy link
Contributor

schornakj commented Oct 6, 2021

One new thing I do see when testing with this branch is new error log messages from the move_group node:

[move_group-6] [ERROR] [1633475204.932107474] [tf2_buffer]: Do not call canTransform or lookupTransform with a timeout unless you are using another thread for populating data. Without a dedicated thread it will always timeout.  If you have a separate thread servicing tf messages, call setUsingDedicatedThread(true) on your Buffer instance.

This doesn't appear to have a functional effect, though.

Update: this error log is from an old version of the PR, so there's nothing that needs to be fixed here.

Copy link
Contributor

@schornakj schornakj left a comment

Choose a reason for hiding this comment

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

Explicit re-approval: I tested with the latest version of this PR and it works as expected.

@henningkayser
Copy link
Member

Explicit re-approval: I tested with the latest version of this PR and it works as expected.

Thanks for looking into this again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocks release This PR should be merged before the next release
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Planning Scene is missing TF frames
5 participants