Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It seems like publishing a ROS message is not passing the data to the executor so the executor sends the data during `spin_once`. That said, it might not be synchronous either as this is (middleware-)implementation defined. See [`rmw_publish_loaned_message`][1]. It seems like by default, FastDDS uses an async mode which uses an internal thread to send the data. That's fine with this code I think and we can basically treat that once we call publish, the message is basically sent. Thus, instead of `spin_once` after stop is requested (due to signals), we simply drain the queue directly from `Ros2ExecutorThread`. This requires making `Ros2ExecutorThread` to be a friend of `Ros2Adapter`. There's no issues with thread (as we are using a SPSC queue for the published message) because the `TimerCallback` of `Ros2Adapter` is executing as a part of `Ros2ExecutorThread` anyway. Moving it out of `TimerCallback` and into `Ros2ExecutorThread` is no different from a threading perspective. Fixes #104. [1]: https://docs.ros.org/en/jazzy/p/rmw/generated/function_rmw_8h_1ab01da69d8613952343abd5d65107399a.html
- Loading branch information