From 99cc8a6369094066b1f1574c865ceff72e4c11a9 Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke <48475933+Nils-ChristianIseke@users.noreply.github.com> Date: Sun, 27 Apr 2025 18:41:56 +0200 Subject: [PATCH 1/2] Add $ to Beginner-CLI-Tools and Beginner-Client Libraires (#5359) Signed-off-by: Nils-Christian Iseke Signed-off-by: Nils-Christian Iseke <48475933+Nils-ChristianIseke@users.noreply.github.com> Signed-off-by: Christophe Bedard Co-authored-by: Christophe Bedard (cherry picked from commit 278c5078bf71738b494dd0999d6e7c7430da8e69) # Conflicts: # source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst --- .../Recording-And-Playing-Back-Data.rst | 408 +++++++++++++++++- .../Understanding-ROS2-Actions.rst | 2 +- .../Understanding-ROS2-Nodes.rst | 9 +- .../Understanding-ROS2-Topics.rst | 5 +- .../Using-Rqt-Console/Using-Rqt-Console.rst | 12 +- .../Colcon-Tutorial.rst | 2 + .../Custom-ROS2-Interfaces.rst | 44 +- .../Beginner-Client-Libraries/Pluginlib.rst | 2 +- .../Using-Parameters-In-A-Class-CPP.rst | 2 +- 9 files changed, 431 insertions(+), 55 deletions(-) diff --git a/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst b/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst index 582bb519213..1a9ba920d3a 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst @@ -66,22 +66,22 @@ Let's also make a new directory to store our saved recordings, just as good prac .. code-block:: console - mkdir bag_files - cd bag_files + $ mkdir bag_files + $ cd bag_files .. group-tab:: macOS .. code-block:: console - mkdir bag_files - cd bag_files + $ mkdir bag_files + $ cd bag_files .. group-tab:: Windows .. code-block:: console - md bag_files - cd bag_files + $ md bag_files + $ cd bag_files 2 Choose a topic @@ -242,6 +242,402 @@ To get an idea of how often position data is published, you can run the command: $ ros2 topic hz /turtle1/pose +<<<<<<< HEAD +======= +Managing Service Data +--------------------- + +1 Setup +^^^^^^^ + +You'll be recording service data between ``introspection_client`` and ``introspection_service``, then display and replay that same data later on. +To record service data between service client and server, ``Service Introspection`` must be enabled on the node. + +Let's start ``introspection_client`` and ``introspection_service`` nodes and enable ``Service Introspection``. +You can see more details for :doc:`Service Introspection Demo <../../Demos/Service-Introspection>`. + +Open a new terminal and run ``introspection_service``, enabling ``Service Introspection``: + +.. code-block:: console + + $ ros2 run demo_nodes_cpp introspection_service --ros-args -p service_configure_introspection:=contents + +Open another terminal and run ``introspection_client``, enabling ``Service Introspection``: + +.. code-block:: console + + $ ros2 run demo_nodes_cpp introspection_client --ros-args -p client_configure_introspection:=contents + +2 Check service availability +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``ros2 bag`` can only record data from available services. +To see the list of your system's services, open a new terminal and run the command: + +.. code-block:: console + + $ ros2 service list + /add_two_ints + /introspection_client/describe_parameters + /introspection_client/get_parameter_types + /introspection_client/get_parameters + /introspection_client/get_type_description + /introspection_client/list_parameters + /introspection_client/set_parameters + /introspection_client/set_parameters_atomically + /introspection_service/describe_parameters + /introspection_service/get_parameter_types + /introspection_service/get_parameters + /introspection_service/get_type_description + /introspection_service/list_parameters + /introspection_service/set_parameters + /introspection_service/set_parameters_atomically + +To check if ``Service Introspection`` is enabled on the client and service, run the command: + +.. code-block:: console + + $ ros2 service echo --flow-style /add_two_ints + info: + event_type: REQUEST_SENT + stamp: + sec: 1713995389 + nanosec: 386809259 + client_gid: [1, 15, 96, 219, 162, 1, 108, 201, 0, 0, 0, 0, 0, 0, 21, 3] + sequence_number: 133 + request: [{a: 2, b: 3}] + response: [] + --- + +You should see the service communication. + +3 Record services +^^^^^^^^^^^^^^^^^ + +To record service data, the following options are supported. +Service data can be recorded with topics at the same time. + +To record specific services: + +.. code-block:: console + + $ ros2 bag record --service + +To record all services: + +.. code-block:: console + + $ ros2 bag record --all-services + +Run the command: + +.. code-block:: console + + $ ros2 bag record --service /add_two_ints + [INFO] [1713995957.643573503] [rosbag2_recorder]: Press SPACE for pausing/resuming + [INFO] [1713995957.662067587] [rosbag2_recorder]: Event publisher thread: Starting + [INFO] [1713995957.662067614] [rosbag2_recorder]: Listening for topics... + [INFO] [1713995957.666048323] [rosbag2_recorder]: Subscribed to topic '/add_two_ints/_service_event' + [INFO] [1713995957.666092458] [rosbag2_recorder]: Recording... + +Now ``ros2 bag`` is recording the service data published on the ``/add_two_ints`` service. +To stop the recording, enter ``Ctrl+C`` in the terminal. + +The data will be accumulated in a new bag directory with a name in the pattern of ``rosbag2_year_month_day-hour_minute_second``. +This directory will contain a ``metadata.yaml`` along with the bag file in the recorded format. + +4 Inspect service data +^^^^^^^^^^^^^^^^^^^^^^ + +You can see details about your recording by running: + +.. code-block:: console + + $ ros2 bag info + Files: rosbag2_2024_04_24-14_59_17_0.mcap + Bag size: 15.1 KiB + Storage id: mcap + ROS Distro: rolling + Duration: 9.211s + Start: Apr 24 2024 14:59:17.676 (1713995957.676) + End: Apr 24 2024 14:59:26.888 (1713995966.888) + Messages: 0 + Topic information: + Service: 1 + Service information: Service: /add_two_ints | Type: example_interfaces/srv/AddTwoInts | Event Count: 78 | Serialization Format: cdr + +5 Play service data +^^^^^^^^^^^^^^^^^^^ + +Before replaying the bag file, enter ``Ctrl+C`` in the terminal where ``introspection_client`` is running. +When ``introspection_client`` stops running, ``introspection_service`` also stops printing the result because there are no incoming requests. + +Replaying the service data from the bag file will start sending the requests to ``introspection_service``. + +Enter the command: + +.. code-block:: console + + $ ros2 bag play --publish-service-requests + [INFO] [1713997477.870856190] [rosbag2_player]: Set rate to 1 + [INFO] [1713997477.877417477] [rosbag2_player]: Adding keyboard callbacks. + [INFO] [1713997477.877442404] [rosbag2_player]: Press SPACE for Pause/Resume + [INFO] [1713997477.877447855] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message + [INFO] [1713997477.877452655] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10% + [INFO] [1713997477.877456954] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10% + [INFO] [1713997477.877573647] [rosbag2_player]: Playback until timestamp: -1 + +Your ``introspection_service`` terminal will once again start printing the following service messages: + +.. code-block:: console + + [INFO] [1713997478.090466075] [introspection_service]: Incoming request + a: 2 b: 3 + +This is because ``ros2 bag play`` sends the service request data from the bag file to the ``/add_two_ints`` service. + +We can also introspect service communication as ``ros2 bag play`` is playing it back to verify the ``introspection_service``. + +Run this command before ``ros2 bag play`` to see the ``introspection_service``: + +.. code-block:: console + + $ ros2 service echo --flow-style /add_two_ints + +You can see the service request from the bag file and the service response from ``introspection_service``. + +.. code-block:: console + + info: + event_type: REQUEST_RECEIVED + stamp: + sec: 1713998176 + nanosec: 372700698 + client_gid: [1, 15, 96, 219, 80, 2, 158, 123, 0, 0, 0, 0, 0, 0, 20, 4] + sequence_number: 1 + request: [{a: 2, b: 3}] + response: [] + --- + info: + event_type: RESPONSE_SENT + stamp: + sec: 1713998176 + nanosec: 373016882 + client_gid: [1, 15, 96, 219, 80, 2, 158, 123, 0, 0, 0, 0, 0, 0, 20, 4] + sequence_number: 1 + request: [] + response: [{sum: 5}] + +Managing Action Data +-------------------- + +1 Setup +^^^^^^^ + +You'll be recording action data between ``fibonacci_action_client`` and ``fibonacci_action_server``, then display and replay that same data later on. +To record action data between action client and server, ``Action Introspection`` must be enabled on the nodes. + +Let's start ``fibonacci_action_client`` and ``fibonacci_action_server`` nodes and enable ``Action Introspection``. +You can see more details for :doc:`Action Introspection Demo <../../Demos/Action-Introspection>`. + +Open a new terminal and run ``fibonacci_action_server``, enabling ``Action Introspection``: + +.. code-block:: console + + $ ros2 run action_tutorials_py fibonacci_action_server --ros-args -p action_server_configure_introspection:=contents + +Open another terminal and run ``fibonacci_action_client``, enabling ``Action Introspection``: + +.. code-block:: console + + $ ros2 run action_tutorials_cpp fibonacci_action_client --ros-args -p action_client_configure_introspection:=contents + +2 Check action availability +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +``ros2 bag`` can only record data from available actions. +To see the list of your system's actions, open a new terminal and run the command: + +.. code-block:: console + + $ ros2 action list + /fibonacci + +To check if ``Action Introspection`` is enabled on the action, run the command: + +.. code-block:: console + + $ ros2 action echo --flow-style /fibonacci + interface: GOAL_SERVICE + info: + event_type: REQUEST_SENT + stamp: + sec: 1744917904 + nanosec: 760683446 + client_gid: [1, 15, 165, 231, 234, 109, 65, 202, 0, 0, 0, 0, 0, 0, 19, 4] + sequence_number: 1 + request: [{goal_id: {uuid: [81, 55, 121, 145, 81, 66, 209, 93, 214, 113, 255, 100, 120, 6, 102, 83]}, goal: {order: 10}}] + response: [] + --- + ... + +3 Record actions +^^^^^^^^^^^^^^^^ + +To record action data, the following options are supported. +Action data can be recorded with topics and services at the same time. + +To record specific actions: + +.. code-block:: console + + $ ros2 bag record --action + +To record all actions: + +.. code-block:: console + + $ ros2 bag record --all-actions + +Run the command: + +.. code-block:: console + + $ ros2 bag record --action /fibonacci + [INFO] [1744953225.214114862] [rosbag2_recorder]: Press SPACE for pausing/resuming + [INFO] [1744953225.218369761] [rosbag2_recorder]: Listening for topics... + [INFO] [1744953225.218386223] [rosbag2_recorder]: Event publisher thread: Starting + [INFO] [1744953225.218580294] [rosbag2_recorder]: Recording... + [INFO] [1744953225.725417634] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/cancel_goal/_service_event' + [INFO] [1744953225.727901848] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/feedback' + [INFO] [1744953225.729655213] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/get_result/_service_event' + [INFO] [1744953225.731315612] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/send_goal/_service_event' + [INFO] [1744953225.735061252] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/status' + ... + +Now ``ros2 bag`` is recording the action data for the ``/fibonacci`` action: goal, result, and feedback. +To stop the recording, enter ``Ctrl+C`` in the terminal. + +The data will be accumulated in a new bag directory with a name in the pattern of ``rosbag2_year_month_day-hour_minute_second``. +This directory will contain a ``metadata.yaml`` along with the bag file in the recorded format. + +4 Inspect action data +^^^^^^^^^^^^^^^^^^^^^ + +You can see details about your recording by running: + +.. code-block:: console + + $ ros2 bag info + Files: rosbag2_2025_04_17-22_20_40_0.mcap + Bag size: 20.7 KiB + Storage id: mcap + ROS Distro: rolling + Duration: 9.019568080s + Start: Apr 17 2025 22:20:47.263125070 (1744953647.263125070) + End: Apr 17 2025 22:20:56.282693150 (1744953656.282693150) + Messages: 0 + Topic information: + Services: 0 + Service information: + Actions: 1 + Action information: + Action: /fibonacci | Type: example_interfaces/action/Fibonacci | Topics: 2 | Service: 3 | Serialization Format: cdr + Topic: feedback | Count: 9 + Topic: status | Count: 3 + Service: send_goal | Event Count: 4 + Service: cancel_goal | Event Count: 0 + Service: get_result | Event Count: 4 + +5 Play action data +^^^^^^^^^^^^^^^^^^ + +Before replaying the bag file, enter :kbd:`Ctrl-C` in the terminal where ``fibonacci_action_client`` is running. +When ``fibonacci_action_client`` stops running, ``fibonacci_action_server`` also stops printing the result because there are no incoming requests. + +Replaying the action data from the bag file will start sending the requests to ``fibonacci_action_server``. + +Enter the command: + +.. code-block:: console + + $ ros2 bag play --send-actions-as-client + [INFO] [1744953720.691068674] [rosbag2_player]: Set rate to 1 + [INFO] [1744953720.702365209] [rosbag2_player]: Adding keyboard callbacks. + [INFO] [1744953720.702409447] [rosbag2_player]: Press SPACE for Pause/Resume + [INFO] [1744953720.702423063] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message + [INFO] [1744953720.702431404] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10% + [INFO] [1744953720.702437677] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10% + Progress bar enabled at 3 Hz. + Progress bar [?]: [R]unning, [P]aused, [B]urst, [D]elayed, [S]topped + [INFO] [1744953720.702577680] [rosbag2_player]: Playback until timestamp: -1 + + + ====== Playback Progress ====== + [1744953656.281683207] Duration 9.02/9.02 [R] + +Your ``fibonacci_action_server`` terminal will once again start printing the following service messages: + +.. code-block:: console + + [INFO] [1744953720.815577088] [fibonacci_action_server]: Executing goal... + [INFO] [1744953720.815927050] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1]) + [INFO] [1744953721.816509658] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2]) + [INFO] [1744953722.817220270] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3]) + [INFO] [1744953723.817876426] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5]) + [INFO] [1744953724.818498515] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8]) + [INFO] [1744953725.819182228] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13]) + [INFO] [1744953726.820032562] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21]) + [INFO] [1744953727.820738690] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]) + [INFO] [1744953728.821449308] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) + +This is because ``ros2 bag play`` sends the action goal request data from the bag file to the ``/fibonacci`` action. + +We can also introspect action communication as ``ros2 bag play`` is playing it back to verify the ``fibonacci_action_server``. + +Run this command before ``ros2 bag play`` to see the ``fibonacci_action_server``. +You can see the action goal request from the bag file and the service response from ``fibonacci_action_server``: + +.. code-block:: console + + $ ros2 action echo --flow-style /fibonacci + interface: STATUS_TOPIC + status_list: [{goal_info: {goal_id: {uuid: [34, 116, 225, 217, 48, 121, 146, 36, 240, 98, 99, 134, 55, 227, 184, 72]}, stamp: {sec: 1744953720, nanosec: 804984321}}, status: 4}] + --- + interface: GOAL_SERVICE + info: + event_type: REQUEST_RECEIVED + stamp: + sec: 1744953927 + nanosec: 957359210 + client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4] + sequence_number: 1 + request: [{goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, goal: {order: 10}}] + response: [] + --- + interface: GOAL_SERVICE + info: + event_type: RESPONSE_SENT + stamp: + sec: 1744953927 + nanosec: 957726145 + client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4] + sequence_number: 1 + request: [] + response: [{accepted: true, stamp: {sec: 1744953927, nanosec: 957615866}}] + --- + interface: STATUS_TOPIC + status_list: [{goal_info: {goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, stamp: {sec: 1744953927, nanosec: 957663383}}, status: 2}] + --- + interface: FEEDBACK_TOPIC + goal_id: + uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12] + feedback: + sequence: [0, 1, 1] + --- + ... + +>>>>>>> 278c507 (Add $ to Beginner-CLI-Tools and Beginner-Client Libraires (#5359)) Summary ------- diff --git a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.rst b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.rst index b33e05cc2ed..d790b178e7a 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.rst @@ -239,7 +239,7 @@ Enter the following command with the action type in your terminal: Which will return: -.. code-block:: console +.. code-block:: text # The desired heading in radians float32 theta diff --git a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.rst b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.rst index 1978a5c2a36..6c28b16734a 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.rst @@ -77,16 +77,12 @@ You can find node names by using ``ros2 node list`` ``ros2 node list`` will show you the names of all running nodes. This is especially useful when you want to interact with a node, or when you have a system running many nodes and need to keep track of them. -Open a new terminal while turtlesim is still running in the other one, and enter the following command: - -.. code-block:: console - - $ ros2 node list - +Open a new terminal while turtlesim is still running in the other one, and enter the following command. The terminal will return the node name: .. code-block:: console + $ ros2 node list /turtlesim Open another new terminal and start the teleop node with the command: @@ -102,6 +98,7 @@ You will now see the names of two active nodes: .. code-block:: console + $ ros2 node list /turtlesim /teleop_turtle diff --git a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.rst b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.rst index c68850b5cd6..464430f4218 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.rst @@ -200,10 +200,11 @@ Specifically, what structure of data the message expects. $ ros2 interface show geometry_msgs/msg/Twist -.. code-block:: console +Which will return: - # This expresses velocity in free space broken into its linear and angular parts. +.. code-block:: text + # This expresses velocity in free space broken into its linear and angular parts. Vector3 linear float64 x float64 y diff --git a/source/Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.rst b/source/Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.rst index 6406be62f52..2ff4b5ceea3 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.rst @@ -87,13 +87,11 @@ Press ``Ctrl+C`` in the terminal where you ran the ``ros2 topic pub`` command to ROS 2's logger levels are ordered by severity: -.. code-block:: console - - Fatal - Error - Warn - Info - Debug + 1. Fatal + 2. Error + 3. Warn + 4. Info + 5. Debug There is no exact standard for what each level indicates, but it's safe to assume that: diff --git a/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst b/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst index 384a8f5f3e3..94219b943e6 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst @@ -257,6 +257,8 @@ These files will add all of the required elements to your path and library paths .. group-tab:: Windows + In a Windows command line interface: + .. code-block:: console $ call install\setup.bat diff --git a/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst b/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst index e46b0c8bee1..ad588e70df1 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst @@ -188,49 +188,31 @@ In a new terminal, run the following command from within your workspace (``ros2_ $ call install/setup.bat -Now you can confirm that your interface creation worked by using the ``ros2 interface show`` command: +Now you can confirm that your interface creation worked by using the ``ros2 interface show`` command. +The output you see in your terminal should look similar to the following: .. code-block:: console $ ros2 interface show tutorial_interfaces/msg/Num - -should return: - -.. code-block:: bash - - int64 num - -And + int64 num .. code-block:: console $ ros2 interface show tutorial_interfaces/msg/Sphere - -should return: - -.. code-block:: console - - geometry_msgs/Point center - float64 x - float64 y - float64 z - float64 radius - -And + geometry_msgs/Point center + float64 x + float64 y + float64 z + float64 radius .. code-block:: console $ ros2 interface show tutorial_interfaces/srv/AddThreeInts - -should return: - -.. code-block:: bash - - int64 a - int64 b - int64 c - --- - int64 sum + int64 a + int64 b + int64 c + --- + int64 sum 7 Test the new interfaces ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst b/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst index 3b2aeda6eb8..58cdf7906e9 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst @@ -276,7 +276,7 @@ Navigate back to the root of your workspace, ``ros2_ws``, and build your new pac .. code-block:: console - colcon build --packages-select polygon_base polygon_plugins + $ colcon build --packages-select polygon_base polygon_plugins From ``ros2_ws``, be sure to source the setup files: diff --git a/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-CPP.rst b/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-CPP.rst index 0f4a5ffc579..3f6e98224e6 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-CPP.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-CPP.rst @@ -45,7 +45,7 @@ Navigate into ``ros2_ws/src`` and create a new package: .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_parameters --dependencies rclcpp + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_parameters --dependencies rclcpp Your terminal will return a message verifying the creation of your package ``cpp_parameters`` and all its necessary files and folders. From bd4ca4e39937530e9370ff14036e1f908985789e Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 27 Apr 2025 09:48:30 -0700 Subject: [PATCH 2/2] Fix conflict Signed-off-by: Christophe Bedard --- .../Recording-And-Playing-Back-Data.rst | 396 ------------------ 1 file changed, 396 deletions(-) diff --git a/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst b/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst index 1a9ba920d3a..857492e50fe 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.rst @@ -242,402 +242,6 @@ To get an idea of how often position data is published, you can run the command: $ ros2 topic hz /turtle1/pose -<<<<<<< HEAD -======= -Managing Service Data ---------------------- - -1 Setup -^^^^^^^ - -You'll be recording service data between ``introspection_client`` and ``introspection_service``, then display and replay that same data later on. -To record service data between service client and server, ``Service Introspection`` must be enabled on the node. - -Let's start ``introspection_client`` and ``introspection_service`` nodes and enable ``Service Introspection``. -You can see more details for :doc:`Service Introspection Demo <../../Demos/Service-Introspection>`. - -Open a new terminal and run ``introspection_service``, enabling ``Service Introspection``: - -.. code-block:: console - - $ ros2 run demo_nodes_cpp introspection_service --ros-args -p service_configure_introspection:=contents - -Open another terminal and run ``introspection_client``, enabling ``Service Introspection``: - -.. code-block:: console - - $ ros2 run demo_nodes_cpp introspection_client --ros-args -p client_configure_introspection:=contents - -2 Check service availability -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -``ros2 bag`` can only record data from available services. -To see the list of your system's services, open a new terminal and run the command: - -.. code-block:: console - - $ ros2 service list - /add_two_ints - /introspection_client/describe_parameters - /introspection_client/get_parameter_types - /introspection_client/get_parameters - /introspection_client/get_type_description - /introspection_client/list_parameters - /introspection_client/set_parameters - /introspection_client/set_parameters_atomically - /introspection_service/describe_parameters - /introspection_service/get_parameter_types - /introspection_service/get_parameters - /introspection_service/get_type_description - /introspection_service/list_parameters - /introspection_service/set_parameters - /introspection_service/set_parameters_atomically - -To check if ``Service Introspection`` is enabled on the client and service, run the command: - -.. code-block:: console - - $ ros2 service echo --flow-style /add_two_ints - info: - event_type: REQUEST_SENT - stamp: - sec: 1713995389 - nanosec: 386809259 - client_gid: [1, 15, 96, 219, 162, 1, 108, 201, 0, 0, 0, 0, 0, 0, 21, 3] - sequence_number: 133 - request: [{a: 2, b: 3}] - response: [] - --- - -You should see the service communication. - -3 Record services -^^^^^^^^^^^^^^^^^ - -To record service data, the following options are supported. -Service data can be recorded with topics at the same time. - -To record specific services: - -.. code-block:: console - - $ ros2 bag record --service - -To record all services: - -.. code-block:: console - - $ ros2 bag record --all-services - -Run the command: - -.. code-block:: console - - $ ros2 bag record --service /add_two_ints - [INFO] [1713995957.643573503] [rosbag2_recorder]: Press SPACE for pausing/resuming - [INFO] [1713995957.662067587] [rosbag2_recorder]: Event publisher thread: Starting - [INFO] [1713995957.662067614] [rosbag2_recorder]: Listening for topics... - [INFO] [1713995957.666048323] [rosbag2_recorder]: Subscribed to topic '/add_two_ints/_service_event' - [INFO] [1713995957.666092458] [rosbag2_recorder]: Recording... - -Now ``ros2 bag`` is recording the service data published on the ``/add_two_ints`` service. -To stop the recording, enter ``Ctrl+C`` in the terminal. - -The data will be accumulated in a new bag directory with a name in the pattern of ``rosbag2_year_month_day-hour_minute_second``. -This directory will contain a ``metadata.yaml`` along with the bag file in the recorded format. - -4 Inspect service data -^^^^^^^^^^^^^^^^^^^^^^ - -You can see details about your recording by running: - -.. code-block:: console - - $ ros2 bag info - Files: rosbag2_2024_04_24-14_59_17_0.mcap - Bag size: 15.1 KiB - Storage id: mcap - ROS Distro: rolling - Duration: 9.211s - Start: Apr 24 2024 14:59:17.676 (1713995957.676) - End: Apr 24 2024 14:59:26.888 (1713995966.888) - Messages: 0 - Topic information: - Service: 1 - Service information: Service: /add_two_ints | Type: example_interfaces/srv/AddTwoInts | Event Count: 78 | Serialization Format: cdr - -5 Play service data -^^^^^^^^^^^^^^^^^^^ - -Before replaying the bag file, enter ``Ctrl+C`` in the terminal where ``introspection_client`` is running. -When ``introspection_client`` stops running, ``introspection_service`` also stops printing the result because there are no incoming requests. - -Replaying the service data from the bag file will start sending the requests to ``introspection_service``. - -Enter the command: - -.. code-block:: console - - $ ros2 bag play --publish-service-requests - [INFO] [1713997477.870856190] [rosbag2_player]: Set rate to 1 - [INFO] [1713997477.877417477] [rosbag2_player]: Adding keyboard callbacks. - [INFO] [1713997477.877442404] [rosbag2_player]: Press SPACE for Pause/Resume - [INFO] [1713997477.877447855] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message - [INFO] [1713997477.877452655] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10% - [INFO] [1713997477.877456954] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10% - [INFO] [1713997477.877573647] [rosbag2_player]: Playback until timestamp: -1 - -Your ``introspection_service`` terminal will once again start printing the following service messages: - -.. code-block:: console - - [INFO] [1713997478.090466075] [introspection_service]: Incoming request - a: 2 b: 3 - -This is because ``ros2 bag play`` sends the service request data from the bag file to the ``/add_two_ints`` service. - -We can also introspect service communication as ``ros2 bag play`` is playing it back to verify the ``introspection_service``. - -Run this command before ``ros2 bag play`` to see the ``introspection_service``: - -.. code-block:: console - - $ ros2 service echo --flow-style /add_two_ints - -You can see the service request from the bag file and the service response from ``introspection_service``. - -.. code-block:: console - - info: - event_type: REQUEST_RECEIVED - stamp: - sec: 1713998176 - nanosec: 372700698 - client_gid: [1, 15, 96, 219, 80, 2, 158, 123, 0, 0, 0, 0, 0, 0, 20, 4] - sequence_number: 1 - request: [{a: 2, b: 3}] - response: [] - --- - info: - event_type: RESPONSE_SENT - stamp: - sec: 1713998176 - nanosec: 373016882 - client_gid: [1, 15, 96, 219, 80, 2, 158, 123, 0, 0, 0, 0, 0, 0, 20, 4] - sequence_number: 1 - request: [] - response: [{sum: 5}] - -Managing Action Data --------------------- - -1 Setup -^^^^^^^ - -You'll be recording action data between ``fibonacci_action_client`` and ``fibonacci_action_server``, then display and replay that same data later on. -To record action data between action client and server, ``Action Introspection`` must be enabled on the nodes. - -Let's start ``fibonacci_action_client`` and ``fibonacci_action_server`` nodes and enable ``Action Introspection``. -You can see more details for :doc:`Action Introspection Demo <../../Demos/Action-Introspection>`. - -Open a new terminal and run ``fibonacci_action_server``, enabling ``Action Introspection``: - -.. code-block:: console - - $ ros2 run action_tutorials_py fibonacci_action_server --ros-args -p action_server_configure_introspection:=contents - -Open another terminal and run ``fibonacci_action_client``, enabling ``Action Introspection``: - -.. code-block:: console - - $ ros2 run action_tutorials_cpp fibonacci_action_client --ros-args -p action_client_configure_introspection:=contents - -2 Check action availability -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -``ros2 bag`` can only record data from available actions. -To see the list of your system's actions, open a new terminal and run the command: - -.. code-block:: console - - $ ros2 action list - /fibonacci - -To check if ``Action Introspection`` is enabled on the action, run the command: - -.. code-block:: console - - $ ros2 action echo --flow-style /fibonacci - interface: GOAL_SERVICE - info: - event_type: REQUEST_SENT - stamp: - sec: 1744917904 - nanosec: 760683446 - client_gid: [1, 15, 165, 231, 234, 109, 65, 202, 0, 0, 0, 0, 0, 0, 19, 4] - sequence_number: 1 - request: [{goal_id: {uuid: [81, 55, 121, 145, 81, 66, 209, 93, 214, 113, 255, 100, 120, 6, 102, 83]}, goal: {order: 10}}] - response: [] - --- - ... - -3 Record actions -^^^^^^^^^^^^^^^^ - -To record action data, the following options are supported. -Action data can be recorded with topics and services at the same time. - -To record specific actions: - -.. code-block:: console - - $ ros2 bag record --action - -To record all actions: - -.. code-block:: console - - $ ros2 bag record --all-actions - -Run the command: - -.. code-block:: console - - $ ros2 bag record --action /fibonacci - [INFO] [1744953225.214114862] [rosbag2_recorder]: Press SPACE for pausing/resuming - [INFO] [1744953225.218369761] [rosbag2_recorder]: Listening for topics... - [INFO] [1744953225.218386223] [rosbag2_recorder]: Event publisher thread: Starting - [INFO] [1744953225.218580294] [rosbag2_recorder]: Recording... - [INFO] [1744953225.725417634] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/cancel_goal/_service_event' - [INFO] [1744953225.727901848] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/feedback' - [INFO] [1744953225.729655213] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/get_result/_service_event' - [INFO] [1744953225.731315612] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/send_goal/_service_event' - [INFO] [1744953225.735061252] [rosbag2_recorder]: Subscribed to topic '/fibonacci/_action/status' - ... - -Now ``ros2 bag`` is recording the action data for the ``/fibonacci`` action: goal, result, and feedback. -To stop the recording, enter ``Ctrl+C`` in the terminal. - -The data will be accumulated in a new bag directory with a name in the pattern of ``rosbag2_year_month_day-hour_minute_second``. -This directory will contain a ``metadata.yaml`` along with the bag file in the recorded format. - -4 Inspect action data -^^^^^^^^^^^^^^^^^^^^^ - -You can see details about your recording by running: - -.. code-block:: console - - $ ros2 bag info - Files: rosbag2_2025_04_17-22_20_40_0.mcap - Bag size: 20.7 KiB - Storage id: mcap - ROS Distro: rolling - Duration: 9.019568080s - Start: Apr 17 2025 22:20:47.263125070 (1744953647.263125070) - End: Apr 17 2025 22:20:56.282693150 (1744953656.282693150) - Messages: 0 - Topic information: - Services: 0 - Service information: - Actions: 1 - Action information: - Action: /fibonacci | Type: example_interfaces/action/Fibonacci | Topics: 2 | Service: 3 | Serialization Format: cdr - Topic: feedback | Count: 9 - Topic: status | Count: 3 - Service: send_goal | Event Count: 4 - Service: cancel_goal | Event Count: 0 - Service: get_result | Event Count: 4 - -5 Play action data -^^^^^^^^^^^^^^^^^^ - -Before replaying the bag file, enter :kbd:`Ctrl-C` in the terminal where ``fibonacci_action_client`` is running. -When ``fibonacci_action_client`` stops running, ``fibonacci_action_server`` also stops printing the result because there are no incoming requests. - -Replaying the action data from the bag file will start sending the requests to ``fibonacci_action_server``. - -Enter the command: - -.. code-block:: console - - $ ros2 bag play --send-actions-as-client - [INFO] [1744953720.691068674] [rosbag2_player]: Set rate to 1 - [INFO] [1744953720.702365209] [rosbag2_player]: Adding keyboard callbacks. - [INFO] [1744953720.702409447] [rosbag2_player]: Press SPACE for Pause/Resume - [INFO] [1744953720.702423063] [rosbag2_player]: Press CURSOR_RIGHT for Play Next Message - [INFO] [1744953720.702431404] [rosbag2_player]: Press CURSOR_UP for Increase Rate 10% - [INFO] [1744953720.702437677] [rosbag2_player]: Press CURSOR_DOWN for Decrease Rate 10% - Progress bar enabled at 3 Hz. - Progress bar [?]: [R]unning, [P]aused, [B]urst, [D]elayed, [S]topped - [INFO] [1744953720.702577680] [rosbag2_player]: Playback until timestamp: -1 - - - ====== Playback Progress ====== - [1744953656.281683207] Duration 9.02/9.02 [R] - -Your ``fibonacci_action_server`` terminal will once again start printing the following service messages: - -.. code-block:: console - - [INFO] [1744953720.815577088] [fibonacci_action_server]: Executing goal... - [INFO] [1744953720.815927050] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1]) - [INFO] [1744953721.816509658] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2]) - [INFO] [1744953722.817220270] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3]) - [INFO] [1744953723.817876426] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5]) - [INFO] [1744953724.818498515] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8]) - [INFO] [1744953725.819182228] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13]) - [INFO] [1744953726.820032562] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21]) - [INFO] [1744953727.820738690] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]) - [INFO] [1744953728.821449308] [fibonacci_action_server]: Feedback: array('i', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) - -This is because ``ros2 bag play`` sends the action goal request data from the bag file to the ``/fibonacci`` action. - -We can also introspect action communication as ``ros2 bag play`` is playing it back to verify the ``fibonacci_action_server``. - -Run this command before ``ros2 bag play`` to see the ``fibonacci_action_server``. -You can see the action goal request from the bag file and the service response from ``fibonacci_action_server``: - -.. code-block:: console - - $ ros2 action echo --flow-style /fibonacci - interface: STATUS_TOPIC - status_list: [{goal_info: {goal_id: {uuid: [34, 116, 225, 217, 48, 121, 146, 36, 240, 98, 99, 134, 55, 227, 184, 72]}, stamp: {sec: 1744953720, nanosec: 804984321}}, status: 4}] - --- - interface: GOAL_SERVICE - info: - event_type: REQUEST_RECEIVED - stamp: - sec: 1744953927 - nanosec: 957359210 - client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4] - sequence_number: 1 - request: [{goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, goal: {order: 10}}] - response: [] - --- - interface: GOAL_SERVICE - info: - event_type: RESPONSE_SENT - stamp: - sec: 1744953927 - nanosec: 957726145 - client_gid: [1, 15, 165, 231, 190, 254, 1, 50, 0, 0, 0, 0, 0, 0, 19, 4] - sequence_number: 1 - request: [] - response: [{accepted: true, stamp: {sec: 1744953927, nanosec: 957615866}}] - --- - interface: STATUS_TOPIC - status_list: [{goal_info: {goal_id: {uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12]}, stamp: {sec: 1744953927, nanosec: 957663383}}, status: 2}] - --- - interface: FEEDBACK_TOPIC - goal_id: - uuid: [191, 200, 153, 122, 221, 251, 152, 172, 60, 69, 94, 20, 212, 160, 40, 12] - feedback: - sequence: [0, 1, 1] - --- - ... - ->>>>>>> 278c507 (Add $ to Beginner-CLI-Tools and Beginner-Client Libraires (#5359)) Summary -------