-
Notifications
You must be signed in to change notification settings - Fork 56
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
rtt_roscomm: Shortcut ROS spinner callback queue for rtt subscribers #156
Open
spd-intermodalics
wants to merge
5
commits into
toolchain-2.9
Choose a base branch
from
feature/shortcut-ros-spinner-callbackqueue
base: toolchain-2.9
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
rtt_roscomm: Shortcut ROS spinner callback queue for rtt subscribers #156
spd-intermodalics
wants to merge
5
commits into
toolchain-2.9
from
feature/shortcut-ros-spinner-callbackqueue
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The patch introduces a new "queue" without a queue to bypass the global CallbackQueue of ROS for the subscriptions of Orocos messages. Instead, the network thread will immediately execute the callback, and will pass it to the global CallbackQueue only in case that it fails to execute with TryAgain status. Helper functions are provided to generate a subscriber with a custom implementation of CallbackQueueInterface. This method is chosen for the subscribers of the message transporter.
spd-intermodalics
force-pushed
the
feature/shortcut-ros-spinner-callbackqueue
branch
from
September 11, 2020 08:20
f8b9b28
to
8129810
Compare
meyerj
requested changes
Sep 23, 2020
rtt_roscomm/include/rtt_roscomm/rtt_rostopic_ros_msg_transporter.hpp
Outdated
Show resolved
Hide resolved
The patch mainly removes the use of helper functions to subscribe with a custom callback. Instead, a SubscribeOptions object is populated and used during the subscribe() call. The documentation is improved.
meyerj
reviewed
Oct 1, 2020
The patch modifies the rostopic queue size to always 1 when subscribing, bacause when shortcutting the callback that processes messages at ROS side, this buffer will be never fill. Instead, the buffering happens at the RTT data object buffer with the correct size according to the policy.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Optimized ROS subscription pipeline using a custom
CallbackQueueInterface
implementationOptimized ROS subscription pipeline, avoiding unnecessary copies by directly pushing the data to Orocos and bypassing unnecessary ROS threads.
Goal
Do not depend on ROS spinner threads for subscriptions. Minimize latency of port reads and decouple multiple components with ROS subscriptions connected to ports. At the moment they all share the same pool of ROS spinner threads.
Approach
The patch introduces a new "queue" without a queue to bypass the global
ros::CallbackQueue
of ROS for the subscripers of Orocos messages. Instead, the network thread will immediately execute the callback, and will pass it to the globalros::CallbackQueue
only in case that it fails to execute withros::CallbackInterface::TryAgain
status.Implementation
ros::CallbackQueueInterface
is provided that doesn't hold a queue but directly calls thecall()
method of theros::CallbackInterface
received.CallbackQueueInterface
.References
Callbacks and spinning
Explanation about Callbacks and Spinning:
http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning
Check specially the section 4. Advanced: Using Different Callback Queues.
Our use-case is not in 4.1. Shortcutting the callback queue by not having a queue.
Function
Subscriber::subscribe()
Reference
All the overloaded
Subscriber::subscribe()
creates aSubscribeOptions ops
and callssubscribe(ops)
. The way to use a custom callback queue is to replace then entry inSubscribeOptions
options as inops.callback_queue
differentfrom
0(
0is default
callback_queue`, the ROS global queue callback).Function
CallbackQueue::callOneCB()
Reference
The function
CallbackQueue::callOneCB()
executes a callback and then it removes it. The execution of the callback,inherited from
CallbackInterface
is a simplecb->call()
. In this case, theCallbackInterface
is itself aSubscriptionQueue
which can be executed through thatcall()
.The function also deals with
ros::CallbackInterface::TryAgain
result, which would be the case if in a multi-threaded situation the callback is being taken by another thread. We don't expect to get into this situation ever, but in case it happens, we can forward the callback to the global callback queue and let the ROS spinner deal with it, as in the original behavior.Function
Subscription::handleMessage()
Reference
The function
Subscription::handleMessage()
is the function that calls theaddCallback()
to push the callback to the global queue for a subscription.Function
SubscriptionQueue::call()
Reference
The
SubscriptionQueue
is itself aCallbackInterface
so it can becall()
ed which executes normally all the needed delivery of the message.