Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ realtime_tools

Contains a set of tools that can be used from a hard realtime thread, without breaking the realtime behavior.

Some documentation can be found at [docs.ros.org](http://docs.ros.org/en/rolling/p/realtime_tools/doc/index.html).
Further documentation can be found at [docs.ros.org](https://control.ros.org/rolling/doc/realtime_tools/doc/index.html).

## Contributing
As an open-source project, we welcome each contributor, regardless of their background and experience. Pick a [PR](https://github.com/ros-controls/realtime_tools/pulls) and review it, or [create your own](https://github.com/ros-controls/realtime_tools/contribute)!
If you are new to the project, please read the [contributing guide](https://control.ros.org/rolling/doc/contributing/contributing.html) for more information on how to get started. We are happy to help you with your first contribution.

## Build status
ROS2 Distro | Branch | Build status | Documentation | Package Build
ROS2 Distro | Branch | Build status | API Documentation | Package Build
:---------: | :----: | :----------: | :-----------: | :---------------:
**Rolling** | [`master`](https://github.com/ros-controls/realtime_tools/tree/master) | [![Binary Build](https://github.com/ros-controls/realtime_tools/actions/workflows/rolling-binary-build.yml/badge.svg?branch=master)](https://github.com/ros-controls/realtime_tools/actions/workflows/rolling-binary-build.yml?branch=master) <br> [![Source Build](https://github.com/ros-controls/realtime_tools/actions/workflows/rolling-source-build.yml/badge.svg?branch=master)](https://github.com/ros-controls/realtime_tools/actions/workflows/rolling-source-build.yml?branch=master) <br> [![build.ros2.org](https://build.ros2.org/buildStatus/icon?job=Rdev__realtime_tools__ubuntu_noble_amd64&subject=build.ros2.org)](https://build.ros2.org/job/Rdev__realtime_tools__ubuntu_noble_amd64/) | [API](http://docs.ros.org/en/rolling/p/realtime_tools/) | [![Build Status](https://build.ros2.org/buildStatus/icon?job=Rbin_uN64__realtime_tools__ubuntu_noble_amd64__binary)](https://build.ros2.org/job/Rbin_uN64__realtime_tools__ubuntu_noble_amd64__binary/)
**Kilted** | [`master`](https://github.com/ros-controls/realtime_tools/tree/master) | see above <br> [![build.ros2.org](https://build.ros2.org/buildStatus/icon?job=Kdev__realtime_tools__ubuntu_noble_amd64&subject=build.ros2.org)](https://build.ros2.org/job/Kdev__realtime_tools__ubuntu_noble_amd64/) | [API](http://docs.ros.org/en/rolling/p/realtime_tools/) | [![Build Status](https://build.ros2.org/buildStatus/icon?job=Kbin_uN64__realtime_tools__ubuntu_noble_amd64__binary)](https://build.ros2.org/job/Kbin_uN64__realtime_tools__ubuntu_noble_amd64__binary/)
Expand Down
8 changes: 8 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
: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.

.. include:: ../realtime_tools/doc/realtime_publisher.rst
9 changes: 9 additions & 0 deletions doc/migration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:github_url: https://github.com/ros-controls/realtime_tools/blob/{REPOS_FILE_BRANCH}/doc/migration.rst

Migration Guides: Jazzy to Kilted
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This list summarizes important changes between Jazzy (previous) and Kilted (current) releases, where changes to user code might be necessary.

RealtimeBox
*******************************
* ``RealtimeBox`` is deprecated. Update your code to use ``realtime_thread_safe_box.hpp`` header, and class name ``RealtimeThreadSafeBox`` instead. (`#318 <https://github.com/ros-controls/realtime_tools/pull/318>`__, `#342 <https://github.com/ros-controls/realtime_tools/pull/342>`__).
9 changes: 9 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:github_url: https://github.com/ros-controls/realtime_tools/blob/{REPOS_FILE_BRANCH}/doc/release_notes.rst

Release Notes: Jazzy to Kilted
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This list summarizes the changes between Jazzy (previous) and Kilted (current) releases.

RealtimeBox
*******************************
* ``RealtimeBox`` got renamed to ``RealtimeThreadSafeBox`` and uses real-time mutexes now (`#318 <https://github.com/ros-controls/realtime_tools/pull/318>`__, `#342 <https://github.com/ros-controls/realtime_tools/pull/342>`__).
38 changes: 1 addition & 37 deletions realtime_tools/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,7 @@ Contains a set of tools that can be used from a hard realtime thread, without br

For more information of the ros2_control framework see `control.ros.org <https://control.ros.org/>`__.

Realtime Publisher
------------------
The ``realtime_tools::RealtimePublisher`` allows users that write C++ ros2_controllers to publish messages on a ROS topic from a hard realtime loop. The normal ROS publisher is not realtime safe, and should not be used from within the update loop of a realtime controller. The realtime publisher is a wrapper around the ROS publisher; the wrapper creates an extra non-realtime thread that publishes messages on a ROS topic. The example below shows a typical usage of the realtime publisher in the ``on_configure()`` (non-realtime method) and ``update()`` (realtime method) methods of a realtime controller:

.. code-block:: cpp

#include <realtime_tools/realtime_publisher.h>

class MyController : public controller_interface::ControllerInterface
{
...
private:
std::shared_ptr<realtime_tools::RealtimePublisher<my_msgs::msg::MyMsg>> state_publisher_;
std::shared_ptr<rclcpp::Publisher<my_msgs::msg::MyMsg>> s_publisher_;
}

controller_interface::CallbackReturn MyController::on_configure(
const rclcpp_lifecycle::State & /*previous_state*/)
{
...
s_publisher_ = get_node()->create_publisher<my_msgs::msg::MyMsg>(
"~/status", rclcpp::SystemDefaultsQoS());
state_publisher_ =
std::make_unique<realtime_tools::RealtimePublisher<ControllerStateMsg>>(s_publisher_);
...
}

controller_interface::return_type MyController::update(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
{
...
// Publish controller state
state_publisher_->lock();
state_publisher_->msg_ = some_msg;
state_publisher_->unlockAndPublish();
}

.. include:: realtime_publisher.rst

API documentation
------------------
Expand Down
36 changes: 36 additions & 0 deletions realtime_tools/doc/realtime_publisher.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Realtime Publisher
------------------
The ``realtime_tools::RealtimePublisher`` allows users that write C++ ros2_controllers to publish messages on a ROS topic from a hard realtime loop. The normal ROS publisher is not realtime safe, and should not be used from within the update loop of a realtime controller. The realtime publisher is a wrapper around the ROS publisher; the wrapper creates an extra non-realtime thread that publishes messages on a ROS topic. The example below shows a typical usage of the realtime publisher in the ``on_configure()`` (non-realtime method) and ``update()`` (realtime method) methods of a realtime controller:

.. code-block:: cpp

#include <realtime_tools/realtime_publisher.hpp>

class MyController : public controller_interface::ControllerInterface
{
...
private:
std::shared_ptr<realtime_tools::RealtimePublisher<my_msgs::msg::MyMsg>> state_publisher_;
std::shared_ptr<rclcpp::Publisher<my_msgs::msg::MyMsg>> s_publisher_;
}

controller_interface::CallbackReturn MyController::on_configure(
const rclcpp_lifecycle::State & /*previous_state*/)
{
...
s_publisher_ = get_node()->create_publisher<my_msgs::msg::MyMsg>(
"~/status", rclcpp::SystemDefaultsQoS());
state_publisher_ =
std::make_unique<realtime_tools::RealtimePublisher<ControllerStateMsg>>(s_publisher_);
...
}

controller_interface::return_type MyController::update(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
{
...
// Publish controller state
state_publisher_->lock();
state_publisher_->msg_ = some_msg;
state_publisher_->unlockAndPublish();
}
Loading