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

fuse -> ROS 2 fuse_core: Fix Async (Redux) #294

Merged

Conversation

sloretz
Copy link
Collaborator

@sloretz sloretz commented Dec 5, 2022

@methylDragon Here's an alternative to #293. I'm running the test_async_sensor_model test locally with --retest-until-fail 1000. I think this addresses the two issues found so far.

@svwilliams for visibility

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: methylDragon <methylDragon@gmail.com>
Signed-off-by: methylDragon <methylDragon@gmail.com>
@methylDragon methylDragon marked this pull request as ready for review December 6, 2022 21:02
@methylDragon
Copy link
Collaborator

methylDragon commented Dec 6, 2022

I've updated the PR to include the following changes:

  • Add an initialized_ flag that prevents an async class from getting initialized twice (with the appropriate tests)
  • Change the tests to test with multithreaded executors (and made the init test more strict)
  • Fix async issues by using reentrant callback groups on top of the chaining take_data()
  • Update docstrings

We uncovered a potential bug in rclcpp's executors' handling of mutually exclusive callback groups, but in this case it doesn't block the progress for fuse_core

@methylDragon methylDragon changed the title [wip] Async issues fuse -> ROS 2 fuse_core: Fix Async (Redux) Dec 6, 2022
@methylDragon
Copy link
Collaborator

methylDragon commented Dec 6, 2022

See: #276

Signed-off-by: methylDragon <methylDragon@gmail.com>
methylDragon
methylDragon previously approved these changes Dec 6, 2022
Copy link
Collaborator

@methylDragon methylDragon left a comment

Choose a reason for hiding this comment

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

Approving, but double checking with @sloretz that my changes are alright

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Collaborator Author

sloretz commented Dec 7, 2022

I made a few changes after self-reviewing and reading this bit of fuse_tutorials.

  • In ROS 1 - start and stop are scheduling onStart and onStop and nothing else. I updated this PR to make sure the ROS 2 port behaves the same (meaning I removed the bits where we cleared the callback queue when the Context was still valid)
  • There's an edge case in stop() that was fixed by Call onStop() directly if !ros::ok() in stop() #182. When ROS is shutdown the AsyncSpinner won't call anymore callbacks, so the onStop method won't get called. That's why there's a special case where onStop is called directly, and it also opportunistically took the opportunity to clean up the AsyncSpinner (though IIUC it doesn't have to do that). The ROS 2 executor has the same behavior of no longer servicing callbacks when the Context shuts down, so I made the logic the same as it was before.
  • I fixed the race condition between initialize and destruction by making initialize() block until the spinner thread starts. This made internal_stop() simpler.

@sloretz
Copy link
Collaborator Author

sloretz commented Dec 7, 2022

@ros-pull-request-builder retest this please

Copy link
Collaborator

@methylDragon methylDragon left a comment

Choose a reason for hiding this comment

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

I realized we should have initialized_ = false inside internal_stop so the user can choose to reinitialize the model

Aside from that, minor comments to consider

@methylDragon
Copy link
Collaborator

@ros-pull-request-builder retest this please

Copy link
Collaborator

@methylDragon methylDragon left a comment

Choose a reason for hiding this comment

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

Let's add an initialized_ = false in the internal stops, other than that, LGTM!

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz
Copy link
Collaborator Author

sloretz commented Dec 7, 2022

Let's add an initialized_ = false in the internal stops

Added in 9c95cf6

@sloretz
Copy link
Collaborator Author

sloretz commented Dec 7, 2022

@ros-pull-request-builder retest this please

@methylDragon methylDragon merged commit 271a601 into locusrobotics:rolling Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants