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

Change spin_thread default to false #89

Closed
wants to merge 1 commit into from

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Jan 28, 2019

This changes the default value of spin_thread to false if the TransformListener is given a node. I'm assuming if a user has a node then they probably have an executor too. If so, then true for this parameter is potentially a problem because spinning on the same entities in two wait sets is explicitly undefined behavior in rcl

Noticed while looking at ros2/rcl#375.

@sloretz sloretz self-assigned this Jan 28, 2019
@sloretz sloretz requested a review from tfoote January 28, 2019 19:43
@sloretz sloretz added in progress Actively being worked on (Kanban column) in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jan 28, 2019
Copy link
Contributor

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

This likely works around the current issue. But it's not good practice for us to let people get into undefined behavior. In ROS1 this setup it's own callback queue. To that end we should do the same here. However I believe that is not available yet in the rclcpp API. It certainly wasn't when this was implemented.

The main reason for the extra thread being required is that the waitForTransform (now canTransform with timeout) methods would block any new incoming transforms thus guaranteeing that they would always timeout unless there's another thread processing the incoming transform subscriptions.

There's some todos re using the clock's sleep_for

// TODO(sloretz) sleep using clock_->sleep_for when implemented
but even more optimal would be something like a yield_for method that would put the thread back in the pool until the timeout instead of blocking/sleeping. However I don't know if that's technically possible.

In the mean time I think that a cleaner fix might be doing something such to making sure that the wait_list's don't overlap to avoid the undefined behaviors.

Edit: I found one releated thread: ros2/rclcpp#519

@sloretz
Copy link
Contributor Author

sloretz commented Feb 27, 2019

I don't know what the right way to avoid spinning on the node in multiple wait sets is, but it sounds like this PR isn't it.

@sloretz sloretz closed this Feb 27, 2019
@sloretz sloretz removed the in review Waiting for review (Kanban column) label Feb 27, 2019
@sloretz sloretz deleted the sloretz/spin_thread_default_false branch February 27, 2019 21:53
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