From 14fe343485a56b5a782518a4f09b72660c3a2124 Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke <48475933+Nils-ChristianIseke@users.noreply.github.com> Date: Sat, 19 Apr 2025 08:19:29 +0200 Subject: [PATCH 1/6] Update README.md Signed-off-by: Nils-Christian Iseke <48475933+Nils-ChristianIseke@users.noreply.github.com> --- README.md | 61 +------------------------------------------------------ 1 file changed, 1 insertion(+), 60 deletions(-) diff --git a/README.md b/README.md index 120d9b355e9..622532c4760 100644 --- a/README.md +++ b/README.md @@ -6,67 +6,8 @@ The sources from this repository are built and uploaded to the site nightly by a ## Contributing to the documentation Contributions to this site are most welcome. -Please see the [Contributing to ROS 2 Documentation](https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html) page to learn more. +Please see the [Contributing to ROS 2 Documentation](https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html) page to learn how to contribute. ## Contributing to ROS 2 To contribute to the ROS 2 source code project please refer to the [ROS 2 contributing guidelines](https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing.html). - -## Prerequisites - -To build this you need to install - -* make -* graphviz - -With [venv](https://docs.python.org/3/library/venv.html) - -``` -# activate the venv -python3 -m venv ros2doc - -# activate venv -source ros2doc/bin/activate - -# install required packages -pip install -r requirements.txt -c constraints.txt - -# deactivate the venv -(ros2doc) deactivate -``` - -### Pinned versions - -For development we currently use Noble as our build platform. -And all python versions are pinned in the constraints file to make sure that things are reproducible. -To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade. - -## Building HTML - -### Local development test - -For local testing of the current tree use: - -`make html` - -`sensible-browser build/html/index.html` - -### Spelling Check - -To check the spelling, use: - -`make spellcheck` - -> [!NOTE] -> If that detects specific words that need to be ignored, add it to [codespell_whitelist](./codespell_whitelist.txt). \ -> To include any custom corrections that are to be applied, add it to [codespell_dictionary](./codespell_dictionary.txt). - -### Deployment test - -To test building the multisite version deployed to the website use: - -`make multiversion` - -`sensible-browser build/html/rolling/index.html` - -**NB:** This will ignore local workspace changes and build from the branches. From 0f50acbf2205953103dd965eb5ab99e50322822d Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke Date: Tue, 22 Apr 2025 20:11:59 +0200 Subject: [PATCH 2/6] Moving "Pinned Versions" from Readme to Documentation Signed-off-by: Nils-Christian Iseke --- .../Contributing/Contributing-To-ROS-2-Documentation.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst index 397285bdfe1..449bc318e95 100644 --- a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst +++ b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst @@ -145,6 +145,14 @@ This will open a menu on the right, where you can click on "Upload document arti :width: 100% :alt: Steps to find rendered HTML files on ROS Github action +Pinned versions +^^^^^^^^^^^^^^^ + +For development we currently use Noble as our build platform. +And all python versions are pinned in the constraints file to make sure that things are reproducible. +To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade. + + Building the site for all branches ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 9f71c8f216bc72f248487f68f97f520f38783e12 Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke Date: Tue, 22 Apr 2025 20:19:14 +0200 Subject: [PATCH 3/6] Merge remote-tracking branch 'upstream/rolling' into patch-4 Signed-off-by: Nils-Christian Iseke --- source/Releases/Release-Kilted-Kaiju.rst | 21 ++++ .../Code-Style-Language-Versions.rst | 14 +++ .../Understanding-ROS2-Services.rst | 2 +- .../Colcon-Tutorial.rst | 93 ++++++++-------- .../Creating-A-Workspace.rst | 100 +++++++++--------- .../Creating-Your-First-ROS2-Package.rst | 36 +++---- .../Custom-ROS2-Interfaces.rst | 64 +++++------ .../Getting-Started-With-Ros2doctor.rst | 22 ++-- .../Beginner-Client-Libraries/Pluginlib.rst | 21 ++-- ...ingle-Package-Define-And-Use-Interface.rst | 48 ++++----- .../Using-Parameters-In-A-Class-CPP.rst | 52 ++++----- .../Using-Parameters-In-A-Class-Python.rst | 51 ++++----- ...-A-Simple-Cpp-Publisher-And-Subscriber.rst | 70 ++++++------ ...riting-A-Simple-Cpp-Service-And-Client.rst | 33 +++--- ...g-A-Simple-Py-Publisher-And-Subscriber.rst | 58 +++++----- ...Writing-A-Simple-Py-Service-And-Client.rst | 27 ++--- .../Launch/Creating-Launch-Files.rst | 20 ++-- .../Intermediate/Launch/Launch-system.rst | 36 +++---- .../Launch/Using-Event-Handlers.rst | 4 +- .../Using-ROS2-Launch-For-Large-Projects.rst | 4 +- .../Launch/Using-Substitutions.rst | 56 ++++++---- 21 files changed, 422 insertions(+), 410 deletions(-) diff --git a/source/Releases/Release-Kilted-Kaiju.rst b/source/Releases/Release-Kilted-Kaiju.rst index 738ed7e6e7a..349b39d46da 100644 --- a/source/Releases/Release-Kilted-Kaiju.rst +++ b/source/Releases/Release-Kilted-Kaiju.rst @@ -64,6 +64,27 @@ Try replacing the ``ament_target_dependencies()`` call with the ``target_link_l For more information see `ament/ament_cmake#572 `__ and `ament/ament_cmake#292 `__. +``launch`` +^^^^^^^^^^ + +``PathJoinSubstitution`` +"""""""""""""""""""""""" + +``PathJoinSubstitution`` now supports concatenating strings or substitutions into a single path component. +For example: + +.. code-block:: python + + PathJoinSubstitution(['robot_description', 'urdf', [LaunchConfiguration('model'), '.xacro']]) + +If the ``model`` launch configuration was set to ``my_model``, this would result in a path equal to: + +.. code-block:: python + + 'robot_description/urdf/my_model.xacro' + +For more information, see `ros2/launch#835 `__ and `ros2/launch#838 `__. + Development progress -------------------- diff --git a/source/The-ROS2-Project/Contributing/Code-Style-Language-Versions.rst b/source/The-ROS2-Project/Contributing/Code-Style-Language-Versions.rst index 590a8a81155..276e0f51462 100644 --- a/source/The-ROS2-Project/Contributing/Code-Style-Language-Versions.rst +++ b/source/The-ROS2-Project/Contributing/Code-Style-Language-Versions.rst @@ -338,6 +338,20 @@ We chose the following more precise rule where PEP 8 leaves some freedom: * `We allow up to 100 characters per line (fifth paragraph) `_. * `We pick single quotes over double quotes as long as no escaping is necessary `_. * `We prefer hanging indents for continuation lines `_. +* `We prefer splitting having only one import per line `_: + + .. code-block:: python + + # This is preferred + from typing import Dict + from typing import List + + # over these + from typing import Dict, List + from typing import ( + Dict, + List, + ) Tools like the ``(ament_)pycodestyle`` Python package should be used in unit-test and/or editor integration for checking Python code style. diff --git a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.rst b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.rst index b49c7d6dfb0..8aee3afe374 100644 --- a/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.rst +++ b/source/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.rst @@ -237,7 +237,7 @@ Enter the command: .. code-block:: console - $ ros2 service call /spawn turtlesim_msgs/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}"64gg + $ ros2 service call /spawn turtlesim_msgs/srv/Spawn "{x: 2, y: 2, theta: 0.2, name: ''}" requester: making request: turtlesim.srv.Spawn_Request(x=2.0, y=2.0, theta=0.2, name='') response: diff --git a/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst b/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst index ef7bf5e2b01..384a8f5f3e3 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.rst @@ -39,21 +39,21 @@ Install colcon .. group-tab:: Linux - .. code-block:: bash + .. code-block:: console - sudo apt install python3-colcon-common-extensions + $ sudo apt install python3-colcon-common-extensions .. group-tab:: macOS - .. code-block:: bash + .. code-block:: console - python3 -m pip install colcon-common-extensions + $ python3 -m pip install colcon-common-extensions .. group-tab:: Windows - .. code-block:: bash + .. code-block:: console - pip install -U colcon-common-extensions + $ pip install -U colcon-common-extensions Install ROS 2 @@ -73,7 +73,7 @@ Commonly there is a ``src`` subdirectory. Inside that subdirectory is where the source code of ROS packages will be located. Typically the directory starts otherwise empty. -colcon does out of source builds. +colcon performs out-of-source builds. By default it will create the following directories as peers of the ``src`` directory: * The ``build`` directory will be where intermediate files are stored. @@ -93,24 +93,24 @@ First, create a directory (``ros2_ws``) to contain our workspace: .. group-tab:: Linux - .. code-block:: bash + .. code-block:: console - mkdir -p ~/ros2_ws/src - cd ~/ros2_ws + $ mkdir -p ~/ros2_ws/src + $ cd ~/ros2_ws .. group-tab:: macOS - .. code-block:: bash + .. code-block:: console - mkdir -p ~/ros2_ws/src - cd ~/ros2_ws + $ mkdir -p ~/ros2_ws/src + $ cd ~/ros2_ws .. group-tab:: Windows - .. code-block:: bash + .. code-block:: console - md \dev\ros2_ws\src - cd \dev\ros2_ws + $ md \dev\ros2_ws\src + $ cd \dev\ros2_ws At this point the workspace contains a single empty directory ``src``: @@ -126,9 +126,9 @@ Add some sources Let's clone the `examples `__ repository into the ``src`` directory of the workspace: -.. code-block:: bash +.. code-block:: console - git clone https://github.com/ros2/examples src/examples -b {REPOS_FILE_BRANCH} + $ git clone https://github.com/ros2/examples src/examples -b {REPOS_FILE_BRANCH} Now the workspace should have the source code to the ROS 2 examples: @@ -172,19 +172,19 @@ This allows the installed files to be changed by changing the files in the ``sou .. code-block:: console - colcon build --symlink-install + $ colcon build --symlink-install .. group-tab:: macOS .. code-block:: console - colcon build --symlink-install + $ colcon build --symlink-install .. group-tab:: Windows .. code-block:: console - colcon build --symlink-install --merge-install + $ colcon build --symlink-install --merge-install Windows doesn't allow long paths, so ``merge-install`` will combine all the paths into the ``install`` directory. @@ -213,13 +213,13 @@ To run tests for the packages we just built, run the following: .. code-block:: console - colcon test + $ colcon test .. group-tab:: macOS .. code-block:: console - colcon test + $ colcon test .. group-tab:: Windows @@ -227,7 +227,7 @@ To run tests for the packages we just built, run the following: .. code-block:: console - colcon test --merge-install + $ colcon test --merge-install You also need to specify ``--merge-install`` here since we used it for building above. @@ -245,27 +245,27 @@ These files will add all of the required elements to your path and library paths .. group-tab:: Linux - .. code-block:: bash + .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS - .. code-block:: bash + .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows - .. code-block:: bash + .. code-block:: console - call install\setup.bat + $ call install\setup.bat Or with Powershell: - .. code-block:: bash + .. code-block:: console - install\setup.ps1 + $ install\setup.ps1 Try a demo ^^^^^^^^^^ @@ -273,15 +273,15 @@ Try a demo With the environment sourced, we can run executables built by colcon. Let's run a subscriber node from the examples: -.. code-block:: bash +.. code-block:: console - ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function + $ ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function In another terminal, let's run a publisher node (don't forget to source the setup script): -.. code-block:: bash +.. code-block:: console - ros2 run examples_rclcpp_minimal_publisher publisher_member_function + $ ros2 run examples_rclcpp_minimal_publisher publisher_member_function You should see messages from the publisher and subscriber with numbers incrementing. @@ -307,6 +307,7 @@ Setup ``colcon_cd`` The command ``colcon_cd`` allows you to quickly change the current working directory of your shell to the directory of a package. As an example ``colcon_cd some_ros_package`` would quickly bring you to the directory ``~/ros2_ws/src/some_ros_package``. +To set up ``colcon_cd`` you need to run the following commands to modify your shell startup script: .. tabs:: @@ -314,15 +315,15 @@ As an example ``colcon_cd some_ros_package`` would quickly bring you to the dire .. code-block:: console - echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc - echo "export _colcon_cd_root=/opt/ros/{DISTRO}/" >> ~/.bashrc + $ echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc + $ echo "export _colcon_cd_root=/opt/ros/{DISTRO}/" >> ~/.bashrc .. group-tab:: macOS .. code-block:: console - echo "source /usr/local/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc - echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc + $ echo "source /usr/local/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc + $ echo "export _colcon_cd_root=~/ros2_install" >> ~/.bashrc .. group-tab:: Windows @@ -346,9 +347,9 @@ Tips * If you want to run a single particular test from a package: - .. code-block:: bash + .. code-block:: console - colcon test --packages-select YOUR_PKG_NAME --ctest-args -R YOUR_TEST_IN_PKG + $ colcon test --packages-select YOUR_PKG_NAME --ctest-args -R YOUR_TEST_IN_PKG Setup ``colcon`` mixins ----------------------- @@ -359,7 +360,7 @@ For example, to change the CMake build type to debug, you normally use: .. code-block:: console - colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug + $ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug To make common command line options easier to invoke this repository makes these "shortcuts" available. @@ -367,13 +368,13 @@ To install the default colcon mixins, run the following: .. code-block:: console - colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml - colcon mixin update default + $ colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml + $ colcon mixin update default Then, try out using the ``debug`` mixin: .. code-block:: console - colcon build --mixin debug + $ colcon build --mixin debug For more details, see the `colcon mixin repository `__. diff --git a/source/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.rst b/source/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.rst index 622da71554e..0e0b5803b94 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.rst @@ -58,13 +58,13 @@ Depending on how you installed ROS 2 (from source or binaries), and which platfo .. code-block:: console - source /opt/ros/{DISTRO}/setup.bash + $ source /opt/ros/{DISTRO}/setup.bash .. group-tab:: macOS .. code-block:: console - . ~/ros2_install/ros2-osx/setup.bash + $ . ~/ros2_install/ros2-osx/setup.bash .. group-tab:: Windows @@ -72,7 +72,7 @@ Depending on how you installed ROS 2 (from source or binaries), and which platfo .. code-block:: console - call C:\dev\ros2\local_setup.bat + $ call C:\dev\ros2\local_setup.bat Consult the :doc:`installation guide <../../../Installation>` you followed if these commands don't work for you. @@ -91,22 +91,22 @@ Let's choose the directory name ``ros2_ws``, for "development workspace": .. code-block:: console - mkdir -p ~/ros2_ws/src - cd ~/ros2_ws/src + $ mkdir -p ~/ros2_ws/src + $ cd ~/ros2_ws/src .. group-tab:: macOS .. code-block:: console - mkdir -p ~/ros2_ws/src - cd ~/ros2_ws/src + $ mkdir -p ~/ros2_ws/src + $ cd ~/ros2_ws/src .. group-tab:: Windows .. code-block:: console - md \ros2_ws\src - cd \ros2_ws\src + $ md \ros2_ws\src + $ cd \ros2_ws\src Another best practice is to put any packages in your workspace into the ``src`` directory. @@ -130,7 +130,7 @@ In the ``ros2_ws/src`` directory, run the following command: .. code-block:: console - git clone https://github.com/ros/ros_tutorials.git -b {DISTRO} + $ git clone https://github.com/ros/ros_tutorials.git -b {DISTRO} Now ``ros_tutorials`` is cloned in your workspace. The ``ros_tutorials`` repository contains the ``turtlesim`` package, which we'll use in the rest of this tutorial. @@ -153,11 +153,12 @@ From the root of your workspace (``ros2_ws``), run the following command: .. group-tab:: Linux - .. code-block:: bash + If you're still in the ``src`` directory with the ``ros_tutorials`` clone, make sure to run ``cd ..`` to move back up to the workspace (``ros2_ws``). - # cd if you're still in the ``src`` directory with the ``ros_tutorials`` clone - cd .. - rosdep install -i --from-path src --rosdistro {DISTRO} -y + .. code-block:: console + + $ cd .. + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -191,30 +192,35 @@ From the root of your workspace (``ros2_ws``), you can now build your packages u .. code-block:: console - colcon build + $ colcon build + Starting >>> turtlesim + Finished <<< turtlesim [5.49s] + + Summary: 1 package finished [5.58s] + .. group-tab:: macOS .. code-block:: console - colcon build + $ colcon build + Starting >>> turtlesim + Finished <<< turtlesim [5.49s] - .. group-tab:: Windows - - .. code-block:: console + Summary: 1 package finished [5.58s] - colcon build --merge-install - Windows doesn't allow long paths, so ``merge-install`` will combine all the paths into the ``install`` directory. + .. group-tab:: Windows -The console will return the following message: + .. code-block:: console -.. code-block:: console + $ colcon build --merge-install + Starting >>> turtlesim + Finished <<< turtlesim [5.49s] - Starting >>> turtlesim - Finished <<< turtlesim [5.49s] + Summary: 1 package finished [5.58s] - Summary: 1 package finished [5.58s] + Windows doesn't allow long paths, so ``merge-install`` will combine all the paths into the ``install`` directory. .. note:: @@ -225,7 +231,8 @@ The console will return the following message: * ``--event-handlers console_direct+`` shows console output while building (can otherwise be found in the ``log`` directory) * ``--executor sequential`` processes the packages one by one instead of using parallelism -Once the build is finished, enter the command in the workspace root (``~/ros2_ws``): +Once the build is finished, enter the command in the workspace root (``~/ros2_ws``). +You will see that colcon has created new directories: .. tabs:: @@ -233,25 +240,22 @@ Once the build is finished, enter the command in the workspace root (``~/ros2_ws .. code-block:: console - ls + $ ls + build install log src .. group-tab:: macOS .. code-block:: console - ls + $ ls + build install log src .. group-tab:: Windows .. code-block:: console - dir - -And you will see that colcon has created new directories: - -.. code-block:: console - - build install log src + $ dir + build install log src The ``install`` directory is where your workspace's setup files are, which you can use to source your overlay. @@ -270,13 +274,13 @@ In the new terminal, source your main ROS 2 environment as the "underlay", so yo .. code-block:: console - source /opt/ros/{DISTRO}/setup.bash + $ source /opt/ros/{DISTRO}/setup.bash .. group-tab:: macOS .. code-block:: console - . ~/ros2_install/ros2-osx/setup.bash + $ . ~/ros2_install/ros2-osx/setup.bash .. group-tab:: Windows @@ -284,7 +288,7 @@ In the new terminal, source your main ROS 2 environment as the "underlay", so yo .. code-block:: console - call C:\dev\ros2\local_setup.bat + $ call C:\dev\ros2\local_setup.bat Go into the root of your workspace: @@ -294,19 +298,19 @@ Go into the root of your workspace: .. code-block:: console - cd ~/ros2_ws + $ cd ~/ros2_ws .. group-tab:: macOS .. code-block:: console - cd ~/ros2_ws + $ cd ~/ros2_ws .. group-tab:: Windows .. code-block:: console - cd \ros2_ws + $ cd \ros2_ws In the root, source your overlay: @@ -316,19 +320,19 @@ In the root, source your overlay: .. code-block:: console - source install/local_setup.bash + $ source install/local_setup.bash .. group-tab:: macOS .. code-block:: console - . install/local_setup.bash + $ . install/local_setup.bash .. group-tab:: Windows .. code-block:: console - call install\setup.bat + $ call install\setup.bat .. note:: @@ -342,7 +346,7 @@ Now you can run the ``turtlesim`` package from the overlay: .. code-block:: console - ros2 run turtlesim turtlesim_node + $ ros2 run turtlesim turtlesim_node But how can you tell that this is the overlay turtlesim running, and not your main installation's turtlesim? @@ -367,7 +371,7 @@ Return to the second terminal (where the overlay is sourced) and run turtlesim a .. code-block:: console - ros2 run turtlesim turtlesim_node + $ ros2 run turtlesim turtlesim_node You will see the title bar on the turtlesim window now says "MyTurtleSim". @@ -380,7 +384,7 @@ Run turtlesim again: .. code-block:: console - ros2 run turtlesim turtlesim_node + $ ros2 run turtlesim turtlesim_node .. image:: images/underlay.png diff --git a/source/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.rst b/source/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.rst index 0234fecc132..3104af34ef0 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.rst @@ -139,19 +139,19 @@ Make sure you are in the ``src`` folder before running the package creation comm .. code-block:: console - cd ~/ros2_ws/src + $ cd ~/ros2_ws/src .. group-tab:: macOS .. code-block:: console - cd ~/ros2_ws/src + $ cd ~/ros2_ws/src .. group-tab:: Windows .. code-block:: console - cd \ros2_ws\src + $ cd \ros2_ws\src The command syntax for creating a new package in ROS 2 is: @@ -161,13 +161,13 @@ The command syntax for creating a new package in ROS 2 is: .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 .. group-tab:: Python .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 + $ ros2 pkg create --build-type ament_python --license Apache-2.0 For this tutorial, you will use the optional arguments ``--node-name`` and ``--license``. ``--node-name`` option creates a simple Hello World type executable in the package, and ``--license`` declares the license information for the package. @@ -180,13 +180,13 @@ Enter the following command in your terminal: .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 --node-name my_node my_package + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 --node-name my_node my_package .. group-tab:: Python .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 --node-name my_node my_package + $ ros2 pkg create --build-type ament_python --license Apache-2.0 --node-name my_node my_package You will now have a new folder within your workspace's ``src`` directory called ``my_package``. @@ -263,19 +263,19 @@ Return to the root of your workspace: .. code-block:: console - cd ~/ros2_ws + $ cd ~/ros2_ws .. group-tab:: macOS .. code-block:: console - cd ~/ros2_ws + $ cd ~/ros2_ws .. group-tab:: Windows .. code-block:: console - cd \ros2_ws + $ cd \ros2_ws Now you can build your packages: @@ -285,19 +285,19 @@ Now you can build your packages: .. code-block:: console - colcon build + $ colcon build .. group-tab:: macOS .. code-block:: console - colcon build + $ colcon build .. group-tab:: Windows .. code-block:: console - colcon build --merge-install + $ colcon build --merge-install Windows doesn't allow long paths, so ``merge-install`` will combine all the paths into the ``install`` directory. @@ -309,7 +309,7 @@ To build only the ``my_package`` package next time, you can run: .. code-block:: console - colcon build --packages-select my_package + $ colcon build --packages-select my_package 3 Source the setup file ^^^^^^^^^^^^^^^^^^^^^^^ @@ -324,19 +324,19 @@ Then, from inside the ``ros2_ws`` directory, run the following command to source .. code-block:: console - source install/local_setup.bash + $ source install/local_setup.bash .. group-tab:: macOS .. code-block:: console - . install/local_setup.bash + $ . install/local_setup.bash .. group-tab:: Windows .. code-block:: console - call install/local_setup.bat + $ call install/local_setup.bat Now that your workspace has been added to your path, you will be able to use your new package's executables. @@ -347,7 +347,7 @@ To run the executable you created using the ``--node-name`` argument during pack .. code-block:: console - ros2 run my_package my_node + $ ros2 run my_package my_node Which will return a message to your terminal: diff --git a/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst b/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst index 7a698412095..cb9570e964a 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.rst @@ -46,7 +46,7 @@ Since we will use the pub/sub and service/client packages created in earlier tut .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 tutorial_interfaces + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 tutorial_interfaces ``tutorial_interfaces`` is the name of the new package. Note that it is, and can only be, a CMake package, but this doesn't restrict in which type of packages you can use your messages and services. @@ -57,7 +57,7 @@ Create the directories in ``ros2_ws/src/tutorial_interfaces``: .. code-block:: console - mkdir msg srv + $ mkdir msg srv 2 Create custom definitions ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ Create the directories in ``ros2_ws/src/tutorial_interfaces``: In the ``tutorial_interfaces/msg`` directory you just created, make a new file called ``Num.msg`` with one line of code declaring its data structure: -.. code-block:: console +.. code-block:: bash int64 num @@ -75,7 +75,7 @@ This is a custom message that transfers a single 64-bit integer called ``num``. Also in the ``tutorial_interfaces/msg`` directory you just created, make a new file called ``Sphere.msg`` with the following content: -.. code-block:: console +.. code-block:: bash geometry_msgs/Point center float64 radius @@ -87,7 +87,7 @@ This custom message uses a message from another message package (``geometry_msgs Back in the ``tutorial_interfaces/srv`` directory you just created, make a new file called ``AddThreeInts.srv`` with the following request and response structure: -.. code-block:: console +.. code-block:: bash int64 a int64 b @@ -147,19 +147,19 @@ In the root of your workspace (``~/ros2_ws``), run the following command: .. code-block:: console - colcon build --packages-select tutorial_interfaces + $ colcon build --packages-select tutorial_interfaces .. group-tab:: macOS .. code-block:: console - colcon build --packages-select tutorial_interfaces + $ colcon build --packages-select tutorial_interfaces .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select tutorial_interfaces + $ colcon build --merge-install --packages-select tutorial_interfaces Now the interfaces will be discoverable by other ROS 2 packages. @@ -174,29 +174,29 @@ In a new terminal, run the following command from within your workspace (``ros2_ .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat Now you can confirm that your interface creation worked by using the ``ros2 interface show`` command: .. code-block:: console - ros2 interface show tutorial_interfaces/msg/Num + $ ros2 interface show tutorial_interfaces/msg/Num should return: -.. code-block:: console +.. code-block:: bash int64 num @@ -204,7 +204,7 @@ And .. code-block:: console - ros2 interface show tutorial_interfaces/msg/Sphere + $ ros2 interface show tutorial_interfaces/msg/Sphere should return: @@ -220,11 +220,11 @@ And .. code-block:: console - ros2 interface show tutorial_interfaces/srv/AddThreeInts + $ ros2 interface show tutorial_interfaces/srv/AddThreeInts should return: -.. code-block:: console +.. code-block:: bash int64 a int64 b @@ -469,13 +469,13 @@ After making the above edits and saving all the changes, build the package: .. code-block:: console - colcon build --packages-select cpp_pubsub + $ colcon build --packages-select cpp_pubsub On Windows: .. code-block:: console - colcon build --merge-install --packages-select cpp_pubsub + $ colcon build --merge-install --packages-select cpp_pubsub .. group-tab:: Python @@ -483,13 +483,13 @@ After making the above edits and saving all the changes, build the package: .. code-block:: console - colcon build --packages-select py_pubsub + $ colcon build --packages-select py_pubsub On Windows: .. code-block:: console - colcon build --merge-install --packages-select py_pubsub + $ colcon build --merge-install --packages-select py_pubsub Then open two new terminals, source ``ros2_ws`` in each, and run: @@ -499,21 +499,21 @@ Then open two new terminals, source ``ros2_ws`` in each, and run: .. code-block:: console - ros2 run cpp_pubsub talker + $ ros2 run cpp_pubsub talker .. code-block:: console - ros2 run cpp_pubsub listener + $ ros2 run cpp_pubsub listener .. group-tab:: Python .. code-block:: console - ros2 run py_pubsub talker + $ ros2 run py_pubsub talker .. code-block:: console - ros2 run py_pubsub listener + $ ros2 run py_pubsub listener Since ``Num.msg`` relays only an integer, the talker should only be publishing integer values, as opposed to the string it published previously: @@ -760,13 +760,13 @@ After making the above edits and saving all the changes, build the package: .. code-block:: console - colcon build --packages-select cpp_srvcli + $ colcon build --packages-select cpp_srvcli On Windows: .. code-block:: console - colcon build --merge-install --packages-select cpp_srvcli + $ colcon build --merge-install --packages-select cpp_srvcli .. group-tab:: Python @@ -775,13 +775,13 @@ After making the above edits and saving all the changes, build the package: .. code-block:: console - colcon build --packages-select py_srvcli + $ colcon build --packages-select py_srvcli On Windows: .. code-block:: console - colcon build --merge-install --packages-select py_srvcli + $ colcon build --merge-install --packages-select py_srvcli Then open two new terminals, source ``ros2_ws`` in each, and run: @@ -791,21 +791,21 @@ Then open two new terminals, source ``ros2_ws`` in each, and run: .. code-block:: console - ros2 run cpp_srvcli server + $ ros2 run cpp_srvcli server .. code-block:: console - ros2 run cpp_srvcli client + $ ros2 run cpp_srvcli client .. group-tab:: Python .. code-block:: console - ros2 run py_srvcli service + $ ros2 run py_srvcli service .. code-block:: console - ros2 run py_srvcli client + $ ros2 run py_srvcli client Summary diff --git a/source/Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor.rst b/source/Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor.rst index 4147ffbaaa5..a1d90b21682 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor.rst @@ -41,18 +41,15 @@ Tasks Let's examine your general ROS 2 setup as a whole with ``ros2doctor``. First, source ROS 2 in a new terminal, then enter the command: -.. code-block:: console - - ros2 doctor - -This will conduct checks over all your setup modules and return warnings and errors. - -If your ROS 2 setup is in perfect shape, you'll see a message similar to this: .. code-block:: console + $ ros2 doctor All checks passed +This will conduct checks over all your setup modules and return warnings and errors. +If your ROS 2 setup is in perfect shape, you'll see a message similar to the one above. + However, it's not unusual to have a few warnings returned. A ``UserWarning`` doesn't mean your setup is unusable; it's more likely just an indication that something is configured in a way that's not ideal. @@ -95,13 +92,13 @@ Start up the system by opening a new terminal, sourcing ROS 2, and entering the .. code-block:: console - ros2 run turtlesim turtlesim_node + $ ros2 run turtlesim turtlesim_node Open another terminal and source ROS 2 to run the teleop controls: .. code-block:: console - ros2 run turtlesim turtle_teleop_key + $ ros2 run turtlesim turtle_teleop_key Now run ``ros2doctor`` again in its own terminal. You will see the warnings and errors you had the last time you ran ``ros2doctor`` on your setup if you had any. @@ -109,6 +106,7 @@ Following those will be a couple new warnings relating to the system itself: .. code-block:: console + $ ros2 doctor UserWarning: Publisher without subscriber detected on /turtle1/color_sensor. UserWarning: Publisher without subscriber detected on /turtle1/pose. @@ -120,11 +118,11 @@ You can try this by opening two new terminals while turtlesim is still running, .. code-block:: console - ros2 topic echo /turtle1/color_sensor + $ ros2 topic echo /turtle1/color_sensor .. code-block:: console - ros2 topic echo /turtle1/pose + $ ros2 topic echo /turtle1/pose Then run ``ros2doctor`` in its terminal again. The ``publisher without subscriber`` warnings will be gone. @@ -149,7 +147,7 @@ To get a full report, enter the following command in the terminal: .. code-block:: console - ros2 doctor --report + $ ros2 doctor --report Which will return a list of information categorized into five groups: diff --git a/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst b/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst index 0caed3ac615..931dc8b5585 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Pluginlib.rst @@ -43,7 +43,7 @@ Create a new empty package in your ``ros2_ws/src`` folder with the following com .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 --dependencies pluginlib --node-name area_node polygon_base + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 --dependencies pluginlib --node-name area_node polygon_base Open your favorite editor, edit ``ros2_ws/src/polygon_base/include/polygon_base/regular_polygon.hpp``, and paste the following inside of it: @@ -101,7 +101,7 @@ Create a second empty package in your ``ros2_ws/src`` folder with the following .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 --dependencies polygon_base pluginlib --library-name polygon_plugins polygon_plugins + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 --dependencies polygon_base pluginlib --library-name polygon_plugins polygon_plugins 2.1 Source code for the plugins ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -286,32 +286,27 @@ From ``ros2_ws``, be sure to source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat Now run the node: .. code-block:: console - ros2 run polygon_base area_node - -It should print: - -.. code-block:: console - - Triangle area: 43.30 - Square area: 100.00 + $ ros2 run polygon_base area_node + Triangle area: 43.30 + Square area: 100.00 Summary ------- diff --git a/source/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.rst b/source/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.rst index 4f84e2164bd..496a18488b4 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.rst @@ -50,8 +50,8 @@ In your workspace ``src`` directory, create a package ``more_interfaces`` and ma .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 more_interfaces - mkdir more_interfaces/msg + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 more_interfaces + $ mkdir more_interfaces/msg 2 Create a msg file ^^^^^^^^^^^^^^^^^^^ @@ -292,22 +292,22 @@ Return to the root of the workspace to build the package: .. code-block:: console - cd ~/ros2_ws - colcon build --packages-up-to more_interfaces + $ cd ~/ros2_ws + $ colcon build --packages-up-to more_interfaces .. group-tab:: macOS .. code-block:: console - cd ~/ros2_ws - colcon build --packages-up-to more_interfaces + $ cd ~/ros2_ws + $ colcon build --packages-up-to more_interfaces .. group-tab:: Windows .. code-block:: console - cd /ros2_ws - colcon build --merge-install --packages-up-to more_interfaces + $ cd /ros2_ws + $ colcon build --merge-install --packages-up-to more_interfaces Then source the workspace and run the publisher: @@ -317,29 +317,29 @@ Then source the workspace and run the publisher: .. code-block:: console - source install/local_setup.bash - ros2 run more_interfaces publish_address_book + $ source install/local_setup.bash + $ ros2 run more_interfaces publish_address_book .. group-tab:: macOS .. code-block:: console - . install/local_setup.bash - ros2 run more_interfaces publish_address_book + $ . install/local_setup.bash + $ ros2 run more_interfaces publish_address_book .. group-tab:: Windows .. code-block:: console - call install/local_setup.bat - ros2 run more_interfaces publish_address_book + $ call install/local_setup.bat + $ ros2 run more_interfaces publish_address_book Or using Powershell: .. code-block:: console - install/local_setup.ps1 - ros2 run more_interfaces publish_address_book + $ install/local_setup.ps1 + $ ros2 run more_interfaces publish_address_book You should see the publisher relaying the msg you defined, including the values you set in ``publish_address_book.cpp``. @@ -351,29 +351,29 @@ To confirm the message is being published on the ``address_book`` topic, open an .. code-block:: console - source install/setup.bash - ros2 topic echo /address_book + $ source install/setup.bash + $ ros2 topic echo /address_book .. group-tab:: macOS .. code-block:: console - . install/setup.bash - ros2 topic echo /address_book + $ . install/setup.bash + $ ros2 topic echo /address_book .. group-tab:: Windows .. code-block:: console - call install/setup.bat - ros2 topic echo /address_book + $ call install/setup.bat + $ ros2 topic echo /address_book Or using Powershell: .. code-block:: console - install/setup.ps1 - ros2 topic echo /address_book + $ install/setup.ps1 + $ ros2 topic echo /address_book We won't create a subscriber in this tutorial, but you can try to write one yourself for practice (use :doc:`./Writing-A-Simple-Cpp-Publisher-And-Subscriber` to help). 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 af41178c2ce..f78b22669f2 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 @@ -231,7 +231,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -249,19 +249,19 @@ Navigate back to the root of your workspace, ``ros2_ws``, and build your new pac .. code-block:: console - colcon build --packages-select cpp_parameters + $ colcon build --packages-select cpp_parameters .. group-tab:: macOS .. code-block:: console - colcon build --packages-select cpp_parameters + $ colcon build --packages-select cpp_parameters .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select cpp_parameters + $ colcon build --merge-install --packages-select cpp_parameters Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -271,30 +271,26 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat -Now run the node: - -.. code-block:: console - - ros2 run cpp_parameters minimal_param_node - -The terminal should return the following message every second: +Now run the node. +The terminal should return the ``Hello World`` message every second: .. code-block:: console + $ ros2 run cpp_parameters minimal_param_node [INFO] [minimal_param_node]: Hello world! Now you can see the default value of your parameter, but you want to be able to set it yourself. @@ -309,20 +305,20 @@ Make sure the node is running: .. code-block:: console - ros2 run cpp_parameters minimal_param_node + $ ros2 run cpp_parameters minimal_param_node Open another terminal, source the setup files from inside ``ros2_ws`` again, and enter the following line: .. code-block:: console - ros2 param list + $ ros2 param list There you will see the custom parameter ``my_parameter``. To change it, simply run the following line in the console: .. code-block:: console - ros2 param set /minimal_param_node my_parameter earth + $ ros2 param set /minimal_param_node my_parameter earth You know it went well if you got the output ``Set parameter successful``. If you look at the other terminal, you should see the output change to ``[INFO] [minimal_param_node]: Hello earth!`` @@ -363,19 +359,19 @@ Open a console and navigate to the root of your workspace, ``ros2_ws``, and buil .. code-block:: console - colcon build --packages-select cpp_parameters + $ colcon build --packages-select cpp_parameters .. group-tab:: macOS .. code-block:: console - colcon build --packages-select cpp_parameters + $ colcon build --packages-select cpp_parameters .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select cpp_parameters + $ colcon build --merge-install --packages-select cpp_parameters Then source the setup files in a new terminal: @@ -385,31 +381,27 @@ Then source the setup files in a new terminal: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat - -Now run the node using the launch file we have just created: - -.. code-block:: console - - ros2 launch cpp_parameters cpp_parameters_launch.py + $ call install/setup.bat +Now run the node using the launch file we have just created. The terminal should return the following message the first time: .. code-block:: console - [INFO] [custom_minimal_param_node]: Hello earth! + $ ros2 launch cpp_parameters cpp_parameters_launch.py + [INFO] [custom_minimal_param_node]: Hello earth! Further outputs should show ``[INFO] [minimal_param_node]: Hello world!`` every second. diff --git a/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.rst b/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.rst index fcff5af4e9f..d2008b8e18f 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.rst @@ -45,7 +45,7 @@ Navigate into ``ros2_ws/src`` and create a new package: .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 python_parameters --dependencies rclpy + $ ros2 pkg create --build-type ament_python --license Apache-2.0 python_parameters --dependencies rclpy Your terminal will return a message verifying the creation of your package ``python_parameters`` and all its necessary files and folders. @@ -227,7 +227,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -245,19 +245,19 @@ Navigate back to the root of your workspace, ``ros2_ws``, and build your new pac .. code-block:: console - colcon build --packages-select python_parameters + $ colcon build --packages-select python_parameters .. group-tab:: macOS .. code-block:: console - colcon build --packages-select python_parameters + $ colcon build --packages-select python_parameters .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select python_parameters + $ colcon build --merge-install --packages-select python_parameters Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -267,30 +267,26 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat -Now run the node: - -.. code-block:: console - - ros2 run python_parameters minimal_param_node - -The terminal should return the following message every second: +Now run the node. +The terminal should return ``Hello world!`` every second: .. code-block:: console + $ ros2 run python_parameters minimal_param_node [INFO] [parameter_node]: Hello world! Now you can see the default value of your parameter, but you want to be able to set it yourself. @@ -305,20 +301,20 @@ Make sure the node is running: .. code-block:: console - ros2 run python_parameters minimal_param_node + $ ros2 run python_parameters minimal_param_node Open another terminal, source the setup files from inside ``ros2_ws`` again, and enter the following line: .. code-block:: console - ros2 param list + $ ros2 param list There you will see the custom parameter ``my_parameter``. To change it, simply run the following line in the console: .. code-block:: console - ros2 param set /minimal_param_node my_parameter earth + $ ros2 param set /minimal_param_node my_parameter earth You know it went well if you get the output ``Set parameter successful``. If you look at the other terminal, you should see the output change to ``[INFO] [minimal_param_node]: Hello earth!`` @@ -368,19 +364,19 @@ Open a console and navigate to the root of your workspace, ``ros2_ws``, and buil .. code-block:: console - colcon build --packages-select python_parameters + $ colcon build --packages-select python_parameters .. group-tab:: macOS .. code-block:: console - colcon build --packages-select python_parameters + $ colcon build --packages-select python_parameters .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select python_parameters + $ colcon build --merge-install --packages-select python_parameters Then source the setup files in a new terminal: @@ -390,30 +386,25 @@ Then source the setup files in a new terminal: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat Now run the node using the launch file we have just created: .. code-block:: console - ros2 launch python_parameters python_parameters_launch.py - -The terminal should return the following message the first time: - -.. code-block:: console - + $ ros2 launch python_parameters python_parameters_launch.py [INFO] [custom_minimal_param_node]: Hello earth! Further outputs should show ``[INFO] [minimal_param_node]: Hello world!`` every second. diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst index ed072cd2cf6..ac9e511d0df 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.rst @@ -46,7 +46,7 @@ So, navigate into ``ros2_ws/src``, and run the package creation command: .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_pubsub + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_pubsub Your terminal will return a message verifying the creation of your package ``cpp_pubsub`` and all its necessary files and folders. @@ -65,13 +65,13 @@ Download the example talker code by entering the following command: .. code-block:: console - wget -O publisher_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp + $ wget -O publisher_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp .. group-tab:: macOS .. code-block:: console - wget -O publisher_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp + $ wget -O publisher_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp .. group-tab:: Windows @@ -79,13 +79,13 @@ Download the example talker code by entering the following command: .. code-block:: console - curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp -o publisher_lambda_function.cpp + $ curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp -o publisher_lambda_function.cpp Or in powershell: .. code-block:: console - curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp -o publisher_lambda_function.cpp + $ curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_publisher/lambda.cpp -o publisher_lambda_function.cpp Now there will be a new file named ``publisher_lambda_function.cpp``. Open the file using your preferred text editor. @@ -306,13 +306,13 @@ Enter the following code in your terminal: .. code-block:: console - wget -O subscriber_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp + $ wget -O subscriber_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp .. group-tab:: macOS .. code-block:: console - wget -O subscriber_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp + $ wget -O subscriber_lambda_function.cpp https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp .. group-tab:: Windows @@ -320,13 +320,13 @@ Enter the following code in your terminal: .. code-block:: console - curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp -o subscriber_lambda_function.cpp + $ curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp -o subscriber_lambda_function.cpp Or in powershell: .. code-block:: console - curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp -o subscriber_lambda_function.cpp + $ curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclcpp/topics/minimal_subscriber/lambda.cpp -o subscriber_lambda_function.cpp Check to ensure that these files exist: @@ -437,7 +437,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -456,19 +456,19 @@ Still in the root of your workspace, ``ros2_ws``, build your new package: .. code-block:: console - colcon build --packages-select cpp_pubsub + $ colcon build --packages-select cpp_pubsub .. group-tab:: macOS .. code-block:: console - colcon build --packages-select cpp_pubsub + $ colcon build --packages-select cpp_pubsub .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select cpp_pubsub + $ colcon build --merge-install --packages-select cpp_pubsub Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -478,51 +478,43 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat - -Now run the talker node: - -.. code-block:: console - - ros2 run cpp_pubsub talker + $ call install/setup.bat +Now run the talker node. The terminal should start publishing info messages every 0.5 seconds, like so: .. code-block:: console - [INFO] [minimal_publisher]: Publishing: "Hello World: 0" - [INFO] [minimal_publisher]: Publishing: "Hello World: 1" - [INFO] [minimal_publisher]: Publishing: "Hello World: 2" - [INFO] [minimal_publisher]: Publishing: "Hello World: 3" - [INFO] [minimal_publisher]: Publishing: "Hello World: 4" - -Open another terminal, source the setup files from inside ``ros2_ws`` again, and then start the listener node: - -.. code-block:: console - - ros2 run cpp_pubsub listener + $ ros2 run cpp_pubsub talker + [INFO] [minimal_publisher]: Publishing: "Hello World: 0" + [INFO] [minimal_publisher]: Publishing: "Hello World: 1" + [INFO] [minimal_publisher]: Publishing: "Hello World: 2" + [INFO] [minimal_publisher]: Publishing: "Hello World: 3" + [INFO] [minimal_publisher]: Publishing: "Hello World: 4" -The listener will start printing messages to the console, starting at whatever message count the publisher is on at that time, like so: +Open another terminal, source the setup files from inside ``ros2_ws`` again, and then start the listener node. +The listener will start printing messages to the console, starting at whatever message count the publisher is on at that time: .. code-block:: console - [INFO] [minimal_subscriber]: I heard: "Hello World: 10" - [INFO] [minimal_subscriber]: I heard: "Hello World: 11" - [INFO] [minimal_subscriber]: I heard: "Hello World: 12" - [INFO] [minimal_subscriber]: I heard: "Hello World: 13" - [INFO] [minimal_subscriber]: I heard: "Hello World: 14" + $ ros2 run cpp_pubsub listener + [INFO] [minimal_subscriber]: I heard: "Hello World: 10" + [INFO] [minimal_subscriber]: I heard: "Hello World: 11" + [INFO] [minimal_subscriber]: I heard: "Hello World: 12" + [INFO] [minimal_subscriber]: I heard: "Hello World: 13" + [INFO] [minimal_subscriber]: I heard: "Hello World: 14" Enter ``Ctrl+C`` in each terminal to stop the nodes from spinning. diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.rst index fdd256f6656..bdece7f5be4 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.rst @@ -46,14 +46,14 @@ 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_srvcli --dependencies rclcpp example_interfaces + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_srvcli --dependencies rclcpp example_interfaces Your terminal will return a message verifying the creation of your package ``cpp_srvcli`` and all its necessary files and folders. The ``--dependencies`` argument will automatically add the necessary dependency lines to ``package.xml`` and ``CMakeLists.txt``. ``example_interfaces`` is the package that includes `the .srv file `__ you will need to structure your requests and responses: -.. code-block:: console +.. code-block:: bash int64 a int64 b @@ -308,7 +308,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -327,19 +327,19 @@ Navigate back to the root of your workspace, ``ros2_ws``, and build your new pac .. code-block:: console - colcon build --packages-select cpp_srvcli + $ colcon build --packages-select cpp_srvcli .. group-tab:: macOS .. code-block:: console - colcon build --packages-select cpp_srvcli + $ colcon build --packages-select cpp_srvcli .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select cpp_srvcli + $ colcon build --merge-install --packages-select cpp_srvcli Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -349,42 +349,39 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat Now run the service node: .. code-block:: console - ros2 run cpp_srvcli server + $ ros2 run cpp_srvcli server The terminal should wait for incoming requests. Open another terminal, source the setup files from inside ``ros2_ws`` again. -Start the client node, followed by any two integers separated by a space: - -.. code-block:: console - - ros2 run cpp_srvcli client - -The client sends the request to the service, which computes the sum and returns the result. -The client should receive the following response: +Start the client node, followed by any two integers separated by a space. +The client sends the request to the service, which computes the sum and returns the result: .. code-block:: console + $ ros2 run cpp_srvcli client [INFO] [minimal_client]: result of 41 + 1: 42 +The client should receive the response above. + Return to the terminal where your service node is running. You will see that it published log messages when it received the request and the data it received, and the response it sent back: diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.rst index 995b5c6474d..edbcf8921c4 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.rst @@ -48,7 +48,7 @@ So, navigate into ``ros2_ws/src``, and run the package creation command: .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 py_pubsub + $ ros2 pkg create --build-type ament_python --license Apache-2.0 py_pubsub Your terminal will return a message verifying the creation of your package ``py_pubsub`` and all its necessary files and folders. @@ -66,13 +66,13 @@ Download the example talker code by entering the following command: .. code-block:: console - wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py + $ wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py .. group-tab:: macOS .. code-block:: console - wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py + $ wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py .. group-tab:: Windows @@ -80,13 +80,13 @@ Download the example talker code by entering the following command: .. code-block:: console - curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py + $ curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py Or in powershell: .. code-block:: console - curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py + $ curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py Now there will be a new file named ``publisher_member_function.py`` adjacent to ``__init__.py``. @@ -282,13 +282,13 @@ Enter the following code in your terminal: .. code-block:: console - wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py + $ wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py .. group-tab:: macOS .. code-block:: console - wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py + $ wget https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py .. group-tab:: Windows @@ -296,13 +296,13 @@ Enter the following code in your terminal: .. code-block:: console - curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py -o subscriber_member_function.py + $ curl -sk https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py -o subscriber_member_function.py Or in powershell: .. code-block:: console - curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py -o subscriber_member_function.py + $ curl https://raw.githubusercontent.com/ros2/examples/{REPOS_FILE_BRANCH}/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py -o subscriber_member_function.py Now the directory should have these files: @@ -415,7 +415,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -434,19 +434,19 @@ Still in the root of your workspace, ``ros2_ws``, build your new package: .. code-block:: console - colcon build --packages-select py_pubsub + $ colcon build --packages-select py_pubsub .. group-tab:: macOS .. code-block:: console - colcon build --packages-select py_pubsub + $ colcon build --packages-select py_pubsub .. group-tab:: Windows .. code-block:: console - colcon build --merge-install --packages-select py_pubsub + $ colcon build --merge-install --packages-select py_pubsub Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -456,47 +456,39 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat - -Now run the talker node: - -.. code-block:: console - - ros2 run py_pubsub talker + $ call install/setup.bat +Now run the talker node. The terminal should start publishing info messages every 0.5 seconds, like so: .. code-block:: console - [INFO] [minimal_publisher]: Publishing: "Hello World: 0" - [INFO] [minimal_publisher]: Publishing: "Hello World: 1" - [INFO] [minimal_publisher]: Publishing: "Hello World: 2" - [INFO] [minimal_publisher]: Publishing: "Hello World: 3" - [INFO] [minimal_publisher]: Publishing: "Hello World: 4" + $ ros2 run py_pubsub talker + [info] [minimal_publisher]: publishing: "hello world: 0" + [info] [minimal_publisher]: publishing: "hello world: 1" + [info] [minimal_publisher]: publishing: "hello world: 2" + [info] [minimal_publisher]: publishing: "hello world: 3" + [info] [minimal_publisher]: publishing: "hello world: 4" ... -Open another terminal, source the setup files from inside ``ros2_ws`` again, and then start the listener node: - -.. code-block:: console - - ros2 run py_pubsub listener - +Open another terminal, source the setup files from inside ``ros2_ws`` again, and then start the listener node. The listener will start printing messages to the console, starting at whatever message count the publisher is on at that time, like so: .. code-block:: console + $ ros2 run py_pubsub listener [INFO] [minimal_subscriber]: I heard: "Hello World: 10" [INFO] [minimal_subscriber]: I heard: "Hello World: 11" [INFO] [minimal_subscriber]: I heard: "Hello World: 12" diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst index e7ebf1f22d4..b14497f9317 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst @@ -45,14 +45,14 @@ Navigate into ``ros2_ws/src`` and create a new package: .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 py_srvcli --dependencies rclpy example_interfaces + $ ros2 pkg create --build-type ament_python --license Apache-2.0 py_srvcli --dependencies rclpy example_interfaces Your terminal will return a message verifying the creation of your package ``py_srvcli`` and all its necessary files and folders. The ``--dependencies`` argument will automatically add the necessary dependency lines to ``package.xml``. ``example_interfaces`` is the package that includes `the .srv file `__ you will need to structure your requests and responses: -.. code-block:: console +.. code-block:: bash int64 a int64 b @@ -305,7 +305,7 @@ It's good practice to run ``rosdep`` in the root of your workspace (``ros2_ws``) .. code-block:: console - rosdep install -i --from-path src --rosdistro {DISTRO} -y + $ rosdep install -i --from-path src --rosdistro {DISTRO} -y .. group-tab:: macOS @@ -320,7 +320,7 @@ Navigate back to the root of your workspace, ``ros2_ws``, and build your new pac .. code-block:: console - colcon build --packages-select py_srvcli + $ colcon build --packages-select py_srvcli Open a new terminal, navigate to ``ros2_ws``, and source the setup files: @@ -330,40 +330,35 @@ Open a new terminal, navigate to ``ros2_ws``, and source the setup files: .. code-block:: console - source install/setup.bash + $ source install/setup.bash .. group-tab:: macOS .. code-block:: console - . install/setup.bash + $ . install/setup.bash .. group-tab:: Windows .. code-block:: console - call install/setup.bat + $ call install/setup.bat Now run the service node: .. code-block:: console - ros2 run py_srvcli service + $ ros2 run py_srvcli service The node will wait for the client's request. Open another terminal and source the setup files from inside ``ros2_ws`` again. -Start the client node: - -.. code-block:: console - - ros2 run py_srvcli client - -The client sends the request to the service, which computes the sum and returns the result. -The client should receive the following response: +Start the client node. +The client sends the request to the service, which computes the sum and returns the result: .. code-block:: console + $ ros2 run py_srvcli client [INFO] [minimal_client_async]: Result of add_two_ints: for 41 + 1 = 42 Return to the terminal where your service node is running. diff --git a/source/Tutorials/Intermediate/Launch/Creating-Launch-Files.rst b/source/Tutorials/Intermediate/Launch/Creating-Launch-Files.rst index d18fbe9567c..e49cd9cbd5f 100644 --- a/source/Tutorials/Intermediate/Launch/Creating-Launch-Files.rst +++ b/source/Tutorials/Intermediate/Launch/Creating-Launch-Files.rst @@ -48,7 +48,7 @@ Create a new directory to store your launch files: .. code-block:: console - mkdir launch + $ mkdir launch 2 Write the launch file ^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,22 +165,22 @@ To run the launch file created above, enter into the directory you created earli .. code-block:: console - cd launch - ros2 launch turtlesim_mimic_launch.xml + $ cd launch + $ ros2 launch turtlesim_mimic_launch.xml .. group-tab:: YAML .. code-block:: console - cd launch - ros2 launch turtlesim_mimic_launch.yaml + $ cd launch + $ ros2 launch turtlesim_mimic_launch.yaml .. group-tab:: Python .. code-block:: console - cd launch - ros2 launch turtlesim_mimic_launch.py + $ cd launch + $ ros2 launch turtlesim_mimic_launch.py .. note:: @@ -189,7 +189,7 @@ To run the launch file created above, enter into the directory you created earli .. code-block:: console - ros2 launch + $ ros2 launch You learned about creating packages in :doc:`../../Beginner-Client-Libraries/Creating-Your-First-ROS2-Package`. @@ -217,7 +217,7 @@ To see the system in action, open a new terminal and run the ``ros2 topic pub`` .. code-block:: console - ros2 topic pub -r 1 /turtlesim1/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -1.8}}" + $ ros2 topic pub -r 1 /turtlesim1/turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -1.8}}" You will see both turtles following the same path. @@ -232,7 +232,7 @@ Run the command: .. code-block:: console - rqt_graph + $ rqt_graph .. image:: images/mimic_graph.png diff --git a/source/Tutorials/Intermediate/Launch/Launch-system.rst b/source/Tutorials/Intermediate/Launch/Launch-system.rst index 15a6e01902e..a6a88f34e12 100644 --- a/source/Tutorials/Intermediate/Launch/Launch-system.rst +++ b/source/Tutorials/Intermediate/Launch/Launch-system.rst @@ -42,24 +42,24 @@ Create a workspace for the package to live in: .. group-tab:: Linux - .. code-block:: bash + .. code-block:: console - mkdir -p launch_ws/src - cd launch_ws/src + $ mkdir -p launch_ws/src + $ cd launch_ws/src .. group-tab:: macOS - .. code-block:: bash + .. code-block:: console - mkdir -p launch_ws/src - cd launch_ws/src + $ mkdir -p launch_ws/src + $ cd launch_ws/src .. group-tab:: Windows - .. code-block:: bash + .. code-block:: console - md launch_ws\src - cd launch_ws\src + $ md launch_ws\src + $ cd launch_ws\src .. tabs:: @@ -67,13 +67,13 @@ Create a workspace for the package to live in: .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 py_launch_example + $ ros2 pkg create --build-type ament_python --license Apache-2.0 py_launch_example .. group-tab:: C++ package .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_launch_example + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 cpp_launch_example 2 Creating the structure to hold launch files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -174,7 +174,7 @@ Go to the top-level of the workspace, and build it: .. code-block:: console - colcon build + $ colcon build After the ``colcon build`` has been successful and you've sourced the workspace, you should be able to run the launch file as follows: @@ -188,19 +188,19 @@ After the ``colcon build`` has been successful and you've sourced the workspace, .. code-block:: console - ros2 launch py_launch_example my_script_launch.xml + $ ros2 launch py_launch_example my_script_launch.xml .. group-tab:: YAML launch file .. code-block:: console - ros2 launch py_launch_example my_script_launch.yaml + $ ros2 launch py_launch_example my_script_launch.yaml .. group-tab:: Python launch file .. code-block:: console - ros2 launch py_launch_example my_script_launch.py + $ ros2 launch py_launch_example my_script_launch.py .. group-tab:: C++ package @@ -210,19 +210,19 @@ After the ``colcon build`` has been successful and you've sourced the workspace, .. code-block:: console - ros2 launch cpp_launch_example my_script_launch.xml + $ ros2 launch cpp_launch_example my_script_launch.xml .. group-tab:: YAML launch file .. code-block:: console - ros2 launch cpp_launch_example my_script_launch.yaml + $ ros2 launch cpp_launch_example my_script_launch.yaml .. group-tab:: Python launch file .. code-block:: console - ros2 launch cpp_launch_example my_script_launch.py + $ ros2 launch cpp_launch_example my_script_launch.py Documentation diff --git a/source/Tutorials/Intermediate/Launch/Using-Event-Handlers.rst b/source/Tutorials/Intermediate/Launch/Using-Event-Handlers.rst index 63a87ec8be8..a8318f82c0a 100644 --- a/source/Tutorials/Intermediate/Launch/Using-Event-Handlers.rst +++ b/source/Tutorials/Intermediate/Launch/Using-Event-Handlers.rst @@ -92,7 +92,7 @@ Go to the root of the workspace, and build the package: .. code-block:: console - colcon build + $ colcon build Also remember to source the workspace after building. @@ -103,7 +103,7 @@ Now you can launch the ``example_event_handlers_launch.py`` file using the ``ros .. code-block:: console - ros2 launch launch_tutorial example_event_handlers_launch.py turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 + $ ros2 launch launch_tutorial example_event_handlers_launch.py turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 This will do the following: diff --git a/source/Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.rst b/source/Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.rst index 5b61d9afeae..e8ac30a5a26 100644 --- a/source/Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.rst +++ b/source/Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.rst @@ -298,7 +298,7 @@ To finally see the result of our code, build the package and launch the top-leve .. code-block:: console - ros2 launch launch_tutorial launch_turtlesim_launch.py + $ ros2 launch launch_tutorial launch_turtlesim_launch.py You will now see the two turtlesim simulations started. There are two turtles in the first one and one in the second one. @@ -311,7 +311,7 @@ If you want to control the ``turtle1``, run the teleop node. .. code-block:: console - ros2 run turtlesim turtle_teleop_key + $ ros2 run turtlesim turtle_teleop_key As a result, you will see a similar picture: diff --git a/source/Tutorials/Intermediate/Launch/Using-Substitutions.rst b/source/Tutorials/Intermediate/Launch/Using-Substitutions.rst index dda8ca7664e..ab71834038d 100644 --- a/source/Tutorials/Intermediate/Launch/Using-Substitutions.rst +++ b/source/Tutorials/Intermediate/Launch/Using-Substitutions.rst @@ -50,7 +50,7 @@ First, create a new package with the name ``launch_tutorial``: .. code-block:: console - ros2 pkg create --build-type ament_python --license Apache-2.0 launch_tutorial + $ ros2 pkg create --build-type ament_python --license Apache-2.0 launch_tutorial .. group-tab:: C++ package @@ -58,7 +58,7 @@ First, create a new package with the name ``launch_tutorial``: .. code-block:: console - ros2 pkg create --build-type ament_cmake --license Apache-2.0 launch_tutorial + $ ros2 pkg create --build-type ament_cmake --license Apache-2.0 launch_tutorial Inside of that package, create a directory called ``launch``: @@ -66,21 +66,21 @@ Inside of that package, create a directory called ``launch``: .. group-tab:: Linux - .. code-block:: bash + .. code-block:: console - mkdir launch_tutorial/launch + $ mkdir launch_tutorial/launch .. group-tab:: macOS - .. code-block:: bash + .. code-block:: console - mkdir launch_tutorial/launch + $ mkdir launch_tutorial/launch .. group-tab:: Windows - .. code-block:: bash + .. code-block:: console - md launch_tutorial/launch + $ md launch_tutorial/launch Finally, make sure to install the launch files: @@ -187,6 +187,26 @@ To do this, create following file in the ``launch`` folder of the ``launch_tutor :language: python :lines: 16-20 + .. tip:: + + A list of substitutions or strings gets concatenated into a single string. + This generally applies to anything that supports substitutions. + + For example, with ``PathJoinSubstitution``, if the file name prefix depended on a launch argument named ``file``, a list of substitutions and strings could be used to create the file name: + + .. code-block:: python + + # Make sure to import LaunchConfiguration: + # from launch.substitutions import LaunchConfiguration + + PathJoinSubstitution([ + FindPackageShare('launch_tutorial'), + 'launch', + [LaunchConfiguration('file', default='example_substitutions'), '_launch', '.py'] + ]) + + In this case, by default, the last path component provided to ``PathJoinSubstitution`` would resolve to ``example_substitutions_launch.py`` and would then be joined with the other path components. + The ``launch_arguments`` dictionary with ``turtlesim_ns`` and ``use_provided_red`` arguments is passed to the ``IncludeLaunchDescription`` action. The ``TextSubstitution`` substitution is used to define the ``new_background_r`` argument with the value of the ``background_r`` key in the ``colors`` dictionary. @@ -329,7 +349,7 @@ Go to the root of the workspace, and build the package: .. code-block:: console - colcon build + $ colcon build Also remember to source the workspace after building. @@ -344,19 +364,19 @@ Now you can launch using the ``ros2 launch`` command. .. code-block:: console - ros2 launch launch_tutorial example_main_launch.yaml + $ ros2 launch launch_tutorial example_main_launch.yaml .. group-tab:: XML .. code-block:: console - ros2 launch launch_tutorial example_main_launch.xml + $ ros2 launch launch_tutorial example_main_launch.xml .. group-tab:: Python .. code-block:: console - ros2 launch launch_tutorial example_main_launch.py + $ ros2 launch launch_tutorial example_main_launch.py This will do the following: @@ -377,7 +397,7 @@ Modifying launch arguments .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.yaml --show-args + $ ros2 launch launch_tutorial example_substitutions_launch.yaml --show-args .. group-tab:: XML @@ -386,7 +406,7 @@ Modifying launch arguments .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.xml --show-args + $ ros2 launch launch_tutorial example_substitutions_launch.xml --show-args .. group-tab:: Python @@ -395,7 +415,7 @@ Modifying launch arguments .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.py --show-args + $ ros2 launch launch_tutorial example_substitutions_launch.py --show-args This will show the arguments that may be given to the launch file and their default values. @@ -423,19 +443,19 @@ Now you can pass the desired arguments to the launch file as follows: .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.yaml turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 + $ ros2 launch launch_tutorial example_substitutions_launch.yaml turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 .. group-tab:: XML .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.xml turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 + $ ros2 launch launch_tutorial example_substitutions_launch.xml turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 .. group-tab:: Python .. code-block:: console - ros2 launch launch_tutorial example_substitutions_launch.py turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 + $ ros2 launch launch_tutorial example_substitutions_launch.py turtlesim_ns:='turtlesim3' use_provided_red:='True' new_background_r:=200 Documentation ------------- From 39faa2699b3d5bb64203d38a5a28772555e77889 Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke Date: Tue, 22 Apr 2025 20:24:26 +0200 Subject: [PATCH 4/6] fix --- .../Contributing/Contributing-To-ROS-2-Documentation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst index 449bc318e95..0a07c82bac2 100644 --- a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst +++ b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst @@ -148,7 +148,7 @@ This will open a menu on the right, where you can click on "Upload document arti Pinned versions ^^^^^^^^^^^^^^^ -For development we currently use Noble as our build platform. +For development we currently use Jammy (Ubuntu 22.04) as our build platform. And all python versions are pinned in the constraints file to make sure that things are reproducible. To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade. From c3e3884f3bf96d36f537a21f74df50bc7e948fe4 Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke Date: Tue, 22 Apr 2025 20:26:11 +0200 Subject: [PATCH 5/6] reposition Pinned version --- .../Contributing-To-ROS-2-Documentation.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst index 0a07c82bac2..34dfef7ac52 100644 --- a/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst +++ b/source/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.rst @@ -83,6 +83,14 @@ In order for Sphinx to be able to generate diagrams, the ``dot`` command must be Download an installer from `the Graphviz Download page `__ and install it. Make sure to allow the installer to add it to the Windows ``%PATH%``, otherwise Sphinx will not be able to find it. +Pinned versions +^^^^^^^^^^^^^^^ + +For development we currently use Jammy (Ubuntu 22.04) as our build platform. +And all python versions are pinned in the constraints file to make sure that things are reproducible. +To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade. + + Building the site for one branch ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,14 +153,6 @@ This will open a menu on the right, where you can click on "Upload document arti :width: 100% :alt: Steps to find rendered HTML files on ROS Github action -Pinned versions -^^^^^^^^^^^^^^^ - -For development we currently use Jammy (Ubuntu 22.04) as our build platform. -And all python versions are pinned in the constraints file to make sure that things are reproducible. -To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade. - - Building the site for all branches ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 6a1e960bac07fd16008394f02e2b0a431a51b41e Mon Sep 17 00:00:00 2001 From: Nils-Christian Iseke <48475933+Nils-ChristianIseke@users.noreply.github.com> Date: Thu, 24 Apr 2025 03:53:43 +0200 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 622532c4760..18772ab624f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The sources from this repository are built and uploaded to the site nightly by a ## Contributing to the documentation Contributions to this site are most welcome. -Please see the [Contributing to ROS 2 Documentation](https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html) page to learn how to contribute. +Please see the [Contributing to ROS 2 Documentation](https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html) page to learn how to build and contribute. ## Contributing to ROS 2