-
Notifications
You must be signed in to change notification settings - Fork 89
Add guidelines for realtimebox/queue #347
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fc32d49
Add top-level index.rst for control.ros.org
christophfroehlich 235a8d0
Add migration and release notes for control.ros.org
christophfroehlich 9088207
Update readme
christophfroehlich 69b18bf
Add guidelines for realtimebox/queue
christophfroehlich d6f59ec
Merge branch 'master' into add/guidelines
christophfroehlich df96d74
Rephrase docs
christophfroehlich 4dec51f
Apply suggestions from code review
christophfroehlich 4dd5aa8
Update doc/index.rst
christophfroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,49 @@ | ||
| :github_url: https://github.com/ros-controls/realtime_tools/blob/{REPOS_FILE_BRANCH}/doc/index.rst | ||
|
|
||
| ############## | ||
| realtime_tools | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ############## | ||
|
|
||
| Contains a set of tools that can be used from a hard realtime thread, without breaking the realtime behavior. | ||
|
|
||
| *************************************** | ||
| Exchange data between different threads | ||
| *************************************** | ||
| This package contains different concepts for exchanging data between different threads. In the following, a guideline for the usage for ros2_controllers is given. | ||
|
|
||
| Provided concepts | ||
| ================= | ||
|
|
||
| RealtimeThreadSafeBox | ||
| --------------------- | ||
| A Box that ensures thread-safe access to the boxed contents. Access is best effort. If it can not lock it will return. | ||
|
|
||
| LockFreeQueue | ||
| --------------------- | ||
| This class provides a base implementation for lock-free queues on top of `Boost.Lockfree <https://www.boost.org/doc/libs/latest/doc/html/lockfree.html>`__ for lock-free queues with various functionalities, such as pushing, popping, and checking the state of the queue. It supports both single-producer single-consumer (SPSC) and multiple-producer multiple-consumer (MPMC) queues. | ||
|
|
||
| .. RealtimePublisher | ||
| .. --------------------- | ||
| .. include:: ../realtime_tools/doc/realtime_publisher.rst | ||
|
|
||
| Guidelines | ||
| ================= | ||
| There exist the following typical use-cases for ros2_controllers: | ||
|
|
||
| * Passing command messages from topic subscribers in a non-realtime thread to the realtime-thread (one-way). | ||
|
|
||
| * If you care only about the latest received message, use the ``realtime_tools::RealtimeThreadSafeBox``. | ||
| * If you care about the intermediate messages, i.e., receiving more than one message before the realtime-thread can process it: Use the ``realtime_tools::LockFreeQueue`` and set a suitable queue size for your application, i.e., consider the maximum expected topic rate vs controller update rate. | ||
|
|
||
| * Send data from the realtime thread to the non-realtime thread for publishing data (one-way): Use the ``realtime_tools::RealtimePublisher``. | ||
|
|
||
| * Exchange data (two-way) between a non-realtime thread and a realtime-thread like state information, current goals etc.: | ||
|
|
||
| * For primitive types like ``bool``, you can simply use ``std::atomic<bool>``, see `cppreference <https://en.cppreference.com/w/cpp/atomic/atomic/>`__. | ||
| * For all other types, when missing some data samples from RT loop is not of major importance, then use the ``realtime_tools::RealtimeThreadSafeBox`` with ``try_set`` method. In the contrary situation, it is recommended to use ``realtime_tools::LockFreeQueue`` to avoid missing any samples. | ||
|
|
||
| *************************************** | ||
| Other classes and helper methods | ||
| *************************************** | ||
|
|
||
| Tba. |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.