|
1 | | -Welcome to the documentation for realtime_tools |
2 | | -=============================================== |
| 1 | +:github_url: https://github.com/ros-controls/realtime_tools/blob/{REPOS_FILE_BRANCH}/doc/index.rst |
3 | 2 |
|
4 | | -Contains a set of tools that can be used from a hard realtime thread, without breaking the realtime behavior. |
5 | | - |
6 | | -For more information of the ros2_control framework see `control.ros.org <https://control.ros.org/>`__. |
7 | | - |
8 | | -Realtime Publisher |
9 | | ------------------- |
10 | | -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: |
11 | | - |
12 | | -.. code-block:: cpp |
13 | | -
|
14 | | - #include <realtime_tools/realtime_publisher.h> |
15 | | -
|
16 | | - class MyController : public controller_interface::ControllerInterface |
17 | | - { |
18 | | - ... |
19 | | - private: |
20 | | - std::shared_ptr<realtime_tools::RealtimePublisher<my_msgs::msg::MyMsg>> state_publisher_; |
21 | | - std::shared_ptr<rclcpp::Publisher<my_msgs::msg::MyMsg>> s_publisher_; |
22 | | - } |
23 | | -
|
24 | | - controller_interface::CallbackReturn MyController::on_configure( |
25 | | - const rclcpp_lifecycle::State & /*previous_state*/) |
26 | | - { |
27 | | - ... |
28 | | - s_publisher_ = get_node()->create_publisher<my_msgs::msg::MyMsg>( |
29 | | - "~/status", rclcpp::SystemDefaultsQoS()); |
30 | | - state_publisher_ = |
31 | | - std::make_unique<realtime_tools::RealtimePublisher<ControllerStateMsg>>(s_publisher_); |
32 | | - ... |
33 | | - } |
| 3 | +realtime_tools |
| 4 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
34 | 5 |
|
35 | | - controller_interface::return_type MyController::update( |
36 | | - const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) |
37 | | - { |
38 | | - ... |
39 | | - // Publish controller state |
40 | | - state_publisher_->lock(); |
41 | | - state_publisher_->msg_ = some_msg; |
42 | | - state_publisher_->unlockAndPublish(); |
43 | | - } |
44 | | -
|
45 | | -
|
46 | | -API documentation |
47 | | ------------------- |
48 | | - |
49 | | -.. toctree:: |
50 | | - :maxdepth: 2 |
51 | | - |
52 | | - C++ API <generated/index> |
53 | | - |
54 | | - |
55 | | -Indices and Search |
56 | | -================== |
| 6 | +Contains a set of tools that can be used from a hard realtime thread, without breaking the realtime behavior. |
57 | 7 |
|
58 | | -* :ref:`genindex` |
59 | | -* :ref:`search` |
| 8 | +.. include:: ../realtime_tools/doc/realtime_publisher.rst |
0 commit comments