### Launch Webots ROS 2 Universal Robot Example
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu
Executes the ROS 2 launch command to start the `multirobot_launch.py` file from the `webots_ros2_universal_robot` package. This command initiates the Webots simulation example, bringing up the robot and its environment.
```bash
ros2 launch webots_ros2_universal_robot multirobot_launch.py
```
--------------------------------
### Launch Webots ROS 2 Universal Robot Example
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Windows
Uses the ROS 2 launch command to start the `multirobot_launch.py` file from the `webots_ros2_universal_robot` package, initiating a demo simulation.
```bash
ros2 launch webots_ros2_universal_robot multirobot_launch.py
```
--------------------------------
### Add Data Files to setup() Call in setup.py
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
The `setup()` call in `setup.py` must tell `setuptools` how to install the `package.xml` and the package marker file. This snippet shows how to add the `data_files` argument to the `setup()` call.
```Python
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
```
--------------------------------
### Launch webots_ros2_universal_robot Example
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Launches the `multirobot_launch.py` example from the `webots_ros2_universal_robot` package using the ROS 2 launch command within the VM.
```bash
$ ros2 launch webots_ros2_universal_robot multirobot_launch.py
```
--------------------------------
### Run ROS 2 Node
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-CPP-Package-Example
Commands to source the ROS 2 environment setup file and then execute the `talker` node using `ros2 run` from the install tree.
```Shell
. ~/ros2_ws/install/setup.bash
ros2 run talker talker
```
--------------------------------
### Migrate setup() Call Arguments in setup.py
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
This snippet shows the initial migration of the `setup()` call in `setup.py`, moving arguments from `generate_distutils_setup()` and adding `install_requires` and `zip_safe` for ROS 2 compatibility.
```Python
setup(
packages=['talker_py'],
package_dir={'': 'src'},
install_requires=['setuptools'],
zip_safe=True,
)
```
--------------------------------
### Run ROS 2 Python Listener Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/RHEL-Install-Binary
Demonstrates how to source the ROS 2 setup file and execute the Python 'demo_nodes_py listener' application to listen for messages, verifying the Python API.
```bash
$ . ~/ros2_humble/ros2-linux/setup.bash
$ ros2 run demo_nodes_py listener
```
--------------------------------
### Start ROS2 Component Container for Server/Client Demo
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Composition
In the first shell, start a new component container instance for the server and client run-time composition example.
```bash
$ ros2 run rclcpp_components component_container
```
--------------------------------
### Complete setup() Call with Metadata in setup.py
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
This snippet shows the `setup()` call in `setup.py` with all required metadata copied from `package.xml`, including name, version, maintainer, description, and license, for a ROS 2 Python package.
```Python
setup(
name=package_name,
version='1.0.0',
install_requires=['setuptools'],
zip_safe=True,
packages=['talker_py'],
package_dir={'': 'src'},
maintainer='Brian Gerkey',
maintainer_email='gerkey@example.com',
description='The talker_py package',
license='BSD',
)
```
--------------------------------
### Run ROS 2 Python Listener Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Windows-Install-Binary
Executes the Python `listener` demo node, which subscribes to and receives messages. This verifies the functionality of the Python API and the ROS 2 environment setup.
```bash
ros2 run demo_nodes_py listener
```
--------------------------------
### Source ROS 2 Setup File from Binary Archive
Source: https://docs.ros.org/en/humble/index.html/Installation/Testing
Commands to source the `setup.*` file located in the root of a downloaded and extracted ROS 2 binary archive, which sets up the environment variables required to use the ROS 2 installation.
```bash
$ source path/to/extracted/archive/setup.bash
```
```batch
$ call path\to\extracted\archive\setup.bat
```
--------------------------------
### Install Git
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Installs Git version control system, required for cloning `webots_ros2` sources from GitHub.
```bash
$ sudo apt-get install git
```
--------------------------------
### Download ROS 2 C++ Minimal Publisher Example Code
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber
Commands to download the `publisher_member_function.cpp` example file from the ROS 2 examples GitHub repository. Separate commands are provided for Linux/macOS using `wget` and Windows using `curl` in both command prompt and PowerShell.
```Shell
$ wget -O publisher_member_function.cpp https://raw.githubusercontent.com/ros2/examples/humble/rclcpp/topics/minimal_publisher/member_function.cpp
```
```Shell
$ curl -sk https://raw.githubusercontent.com/ros2/examples/humble/rclcpp/topics/minimal_publisher/member_function.cpp -o publisher_member_function.cpp
```
```Shell
$ curl https://raw.githubusercontent.com/ros2/examples/humble/rclcpp/topics/minimal_publisher/member_function.cpp -o publisher_member_function.cpp
```
--------------------------------
### Run ROS 2 security deployment example with Docker Compose
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Security/Deployment-Guidelines
Starts the Docker containers defined in the 'compose.deployment.yaml' file. This command initializes the keystore and simulates secure interaction between the listener and talker devices.
```bash
$ docker compose -f compose.deployment.yaml up
```
--------------------------------
### Run ROS 2 C++ Talker Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/RHEL-Install-Binary
Demonstrates how to source the ROS 2 setup file and execute the C++ 'demo_nodes_cpp talker' application to publish messages, verifying the C++ API.
```bash
$ . ~/ros2_humble/ros2-linux/setup.bash
$ ros2 run demo_nodes_cpp talker
```
--------------------------------
### Run ROS 2 C++ Talker Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Windows-Install-Binary
Executes the C++ `talker` demo node, which publishes messages. This verifies the functionality of the C++ API and the ROS 2 environment setup.
```bash
ros2 run demo_nodes_cpp talker
```
--------------------------------
### Run ROS 2 C++ Talker Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/RHEL-Development-Setup
This snippet shows how to run the C++ `talker` demo node after sourcing the ROS 2 setup script. The `talker` node publishes messages, demonstrating the functionality of the C++ API in ROS 2.
```bash
$ . ~/ros2_humble/install/local_setup.bash
$ ros2 run demo_nodes_cpp talker
```
--------------------------------
### Run ROS 2 C++ Talker and Python Listener Demo Nodes
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
These commands demonstrate basic inter-process communication within ROS 2 by launching two example nodes. The first command runs a C++ `talker` node, which publishes messages. The second command, run in a separate terminal after sourcing the setup file, launches a Python `listener` node that subscribes to and prints these messages, verifying the proper functioning of both C++ and Python APIs.
```Shell
$ ros2 run demo_nodes_cpp talker
```
```Shell
$ ros2 run demo_nodes_py listener
```
--------------------------------
### Source ROS 2 Humble Environment
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Sources the ROS 2 Humble environment setup script, making ROS 2 commands and packages available in the current terminal session.
```bash
$ source /opt/ros/humble/setup.bash
```
--------------------------------
### Source webots_ros2 workspace setup
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu
After building, source the local setup script of your workspace to make the newly built `webots_ros2` packages available in your current shell session.
```bash
$ source install/local_setup.bash
```
--------------------------------
### Source ROS 2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber
After building, source the workspace's setup files in each new terminal session. This makes the ROS 2 packages and executables available in your environment.
```Bash
. install/setup.bash
```
```Windows Command Prompt
call install/setup.bat
```
--------------------------------
### Source ROS 2 Humble environment
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu
Source the default ROS 2 Humble environment setup script to ensure all necessary ROS 2 tools and paths are available for building.
```bash
$ source /opt/ros/humble/setup.bash
```
--------------------------------
### Setup ROS 2 Turtlesim Nodes
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services
Commands to start the `/turtlesim` and `/teleop_turtle` nodes, which are prerequisites for interacting with ROS 2 services. These nodes provide services that will be explored in the tutorial.
```bash
ros2 run turtlesim turtlesim_node
```
```bash
ros2 run turtlesim turtle_teleop_key
```
--------------------------------
### Source ROS 2 Workspace Setup (Source Installation)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu
Navigates to the user's ROS 2 workspace directory and sources its local setup script. This step is necessary if ROS 2 was installed from sources, integrating the workspace's custom packages and executables into the ROS 2 environment.
```bash
cd ~/ros2_ws
source install/local_setup.bash
```
--------------------------------
### Source webots_ros2 workspace setup
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Windows
Sources the local workspace setup script to make the newly built `webots_ros2` package and its executables available in the current terminal session.
```bash
source install/local_setup.bash
```
--------------------------------
### Install ROS 2 Package Directories and Libraries (CMake)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Advanced
This CMakeLists.txt snippet defines installation rules for directories like launch, resource, and worlds, and exports include directories and libraries for a ROS 2 package, ensuring proper package setup and discoverability.
```CMake
install(DIRECTORY
launch
resource
worlds
DESTINATION share/${PROJECT_NAME}/
)
ament_export_include_directories(
include
)
ament_export_libraries(
${PROJECT_NAME}
)
ament_package()
```
--------------------------------
### ROS 2 Launch File Example: Common Actions in XML and YAML
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Launch-file-different-formats
This example demonstrates a ROS 2 launch file that performs several common actions, including setting command-line arguments with defaults, including other launch files (with and without namespaces), starting nodes with specific namespaces, setting node parameters using arguments, and remapping messages between topics. The functionality is shown across XML and YAML launch file formats.
```XML
```
```YAML
%YAML 1.2
---
launch:
# args that can be set from the command line or a default will be used
- arg:
name: "background_r"
default: "0"
- arg:
name: "background_g"
default: "255"
- arg:
name: "background_b"
default: "0"
- arg:
name: "chatter_ns"
default: "my/chatter/ns"
# include another launch file
- include:
file: "$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener.launch.py"
# include another launch file in the chatter_ns namespace
- group:
- push_ros_namespace:
namespace: "$(var chatter_ns)"
- include:
file: "$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener.launch.py"
# start a turtlesim_node in the turtlesim1 namespace
- node:
pkg: "turtlesim"
exec: "turtlesim_node"
name: "sim"
namespace: "turtlesim1"
# start another turtlesim_node in the turtlesim2 namespace and use args to set parameters
- node:
pkg: "turtlesim"
exec: "turtlesim_node"
name: "sim"
namespace: "turtlesim2"
param:
- name: "background_r"
value: "$(var background_r)"
- name: "background_g"
value: "$(var background_g)"
- name: "background_b"
value: "$(var background_b)"
```
--------------------------------
### Source ROS 2 Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp
Sources the ROS 2 setup files to configure the environment for the current workspace. Examples are provided for Linux/macOS (bash), Windows Command Prompt, and Windows PowerShell.
```shell
$ . install/setup.bash
```
```shell
$ call install\setup.bat
```
```shell
$.\install\setup.ps1
```
--------------------------------
### Source ROS 2 Workspace from Sources
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Windows
Navigates to the ROS 2 workspace directory and sources its local setup script, essential for using packages built from source.
```bash
cd ~/ros2_ws
source install/local_setup.bash
```
--------------------------------
### Create and navigate to ROS 2 security tutorial workspace
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Security/Deployment-Guidelines
Initializes a new workspace folder named 'security_gd_tutorial' and navigates into it. This directory will be used for all subsequent tutorial steps.
```bash
$ mkdir ~/security_gd_tutorial
$ cd ~/security_gd_tutorial
```
--------------------------------
### Install ROS 2 Build Prerequisites with Homebrew
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
Installs a comprehensive list of libraries and tools using Homebrew, essential for building ROS 2 from source. These packages include compilers, build systems, and various dependencies like OpenCV and Qt.
```bash
$ brew install asio assimp bison bullet cmake console_bridge cppcheck \
cunit eigen freetype graphviz opencv openssl orocos-kdl pcre poco \
pyqt@5 python qt@5 sip spdlog osrf/simulation/tinyxml1 tinyxml2
```
--------------------------------
### Start ROS 2 Tracing Session and List Events
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
This snippet navigates to the tracing workspace, sources the setup, and then initiates a ROS 2 tracing session named `perf-test`. The `--list` flag prints a list of available ROS 2 userspace events, and the command also indicates the output directory for the trace data.
```bash
$ cd ~/tracing_ws
$ source install/setup.bash
$ ros2 trace --session-name perf-test --list
```
--------------------------------
### Install webots_ros2 Package Dependencies
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Installs Python dependencies, initializes and updates `rosdep`, then installs all remaining ROS package dependencies specified in the `src` directory for the Humble distribution.
```bash
$ sudo apt install python3-pip python3-rosdep python3-colcon-common-extensions
$ sudo rosdep init && rosdep update
$ rosdep install --from-paths src --ignore-src --rosdistro humble
```
--------------------------------
### Source ROS 2 Humble Environment
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Windows
Sources the ROS 2 Humble setup script to make ROS 2 commands available in the current shell session within WSL.
```bash
source /opt/ros/humble/setup.bash
```
--------------------------------
### Examine listener container's keystore directory
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Security/Deployment-Guidelines
Attaches to the running 'tutorial-listener-1' container and navigates to its 'keystore' directory. The 'tree' command then displays the hierarchical structure of the security artifacts within the shared volume.
```bash
$ docker exec -it tutorial-listener-1 bash
$ cd keystore
$ tree
```
--------------------------------
### Run ROS2 Launch File (Initial Example)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Miscellaneous/Deploying-ROS-2-on-IBM-Cloud
This Dockerfile command executes a ROS2 launch file, specifically `talker_listener.launch.py` from the `demo_nodes_cpp` package, to start a ROS2 application. It's presented as an initial example of the desired outcome.
```Dockerfile
# run launch file
CMD ["ros2", "launch", "demo_nodes_cpp", "talker_listener.launch.py"]
```
--------------------------------
### Source ROS 2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Pluginlib
These commands source the ROS 2 workspace setup files, making the installed packages available in the current shell environment. Different commands are provided for Linux, macOS, and Windows to ensure proper environment configuration.
```bash
$ source install/setup.bash
```
```bash
$ . install/setup.bash
```
```batch
$ call install/setup.bat
```
--------------------------------
### Run ROS 2 demo listener node to test GurumDDS
Source: https://docs.ros.org/en/humble/index.html/Installation/RMW-Implementations/DDS-Implementations/Working-with-GurumNetworks-GurumDDS
Source the ROS 2 Humble setup script and then run the `demo_nodes_cpp listener` node to subscribe to messages, verifying the `rmw_gurumdds_cpp` installation by receiving messages from the talker.
```Bash
$ source /opt/ros/humble/setup.bash
$ ros2 run demo_nodes_cpp listener
```
--------------------------------
### Install webots_ros2 ROS Package (Debian)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Installs the `webots_ros2` package for ROS Humble distribution using `apt-get` within the VM.
```bash
$ sudo apt-get install ros-humble-webots-ros2
```
--------------------------------
### Example ROS 2 Workspace Directory Structure
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container
Illustrates the recommended directory structure for a ROS 2 workspace, including the .devcontainer folder for VS Code and example package locations.
```text
ws
├── .devcontainer
│ ├── devcontainer.json
│ └── Dockerfile
├── src
├── package1
└── package2
```
--------------------------------
### Run ROS 2 demo talker node to test GurumDDS
Source: https://docs.ros.org/en/humble/index.html/Installation/RMW-Implementations/DDS-Implementations/Working-with-GurumNetworks-GurumDDS
Source the ROS 2 Humble setup script and then run the `demo_nodes_cpp talker` node to publish messages, verifying the `rmw_gurumdds_cpp` installation.
```Bash
$ source /opt/ros/humble/setup.bash
$ ros2 run demo_nodes_cpp talker
```
--------------------------------
### Source ROS2 Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Recording-A-Bag-From-Your-Own-Node-Py
Commands to source the ROS2 setup files, which are necessary to set up the environment variables and paths required to run ROS2 executables and use installed packages in the current terminal session.
```shell
$ source install/setup.bash
```
```shell
$ source install/setup.bash
```
```shell
$ call install/setup.bat
```
--------------------------------
### Install ROS 2 Workspace Dependencies with rosdep
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
These commands update the `rosdep` database and then install all necessary dependencies for the ROS 2 Humble workspace. It skips specific keys like `fastcdr`, `rti-connext-dds-6.0.1`, and `urdfdom_headers` to avoid potential conflicts or unneeded packages.
```bash
$ rosdep update
$ rosdep install --rosdistro humble --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
```
--------------------------------
### Inspect ROS 2 Workspace Directories After Build
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace
After a successful `colcon build`, new directories (`build`, `install`, `log`) are created alongside the `src` directory. This command lists these directories, with `install` containing the workspace's setup files for overlay sourcing.
```bash
$ ls
build install log src
```
```cmd
$ dir
build install log src
```
--------------------------------
### Examine talker container's keystore directory
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Security/Deployment-Guidelines
Attaches to the running 'tutorial-talker-1' container and navigates to its 'keystore' directory. The 'tree' command then displays the hierarchical structure of the security artifacts within the shared volume.
```bash
$ docker exec -it tutorial-talker-1 bash
$ cd keystore
$ tree
```
--------------------------------
### Source ROS 2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client
These commands source the ROS 2 setup files to make the installed packages and environment variables available in the current terminal session. Different commands are provided for Linux, macOS, and Windows.
```bash
$ source install/setup.bash
```
```bash
$ . install/setup.bash
```
```cmd
$ call install/setup.bat
```
--------------------------------
### Setup Webots Local Simulation Server (macOS Bash)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Advanced
Commands to specify the Webots installation folder and start the local simulation server on the host machine for macOS, which runs independently of the ROS 2 nodes.
```Bash
$ export WEBOTS_HOME=/Applications/Webots.app
$ python3 local_simulation_server.py
```
--------------------------------
### Install SLAM Toolbox and Launch Tiago Robot with RViz
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-Windows
Installs the `ros-humble-slam-toolbox` package and then launches the `webots_ros2_tiago` robot with RViz and SLAM enabled for visualization and mapping.
```bash
sudo apt install ros-humble-slam-toolbox
ros2 launch webots_ros2_tiago robot_launch.py rviz:=true slam:=true
```
--------------------------------
### Install Python 3.8.3 on Windows via Chocolatey
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
This command installs Python version 3.8.3 using the Chocolatey package manager. Python is typically installed to C:\Python38, which is the expected location for subsequent ROS 2 setup steps.
```Batch
choco install -y python --version 3.8.3
```
--------------------------------
### Define console_scripts Entry Point in setup.py for ROS 2
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
This snippet demonstrates how to add the `console_scripts` entry point to the `setup()` function in `setup.py`. This defines executables for the package, mapping an `executable_name` to a `module:function` call, enabling tools like `ros2 run` to execute Python scripts.
```Python
entry_points={
'console_scripts': [
'talker_py_node = talker_py:main',
],
},
```
--------------------------------
### Install Bokeh and Open Jupyter Notebook for Trace Analysis
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
This command sequence installs the Bokeh plotting library, a dependency for visualizing trace data, and then launches the specified sample Jupyter notebook. The notebook is designed to analyze subscription callback durations from ROS 2 traces.
```bash
$ pip3 install bokeh
$ jupyter notebook ~/tracing_ws/src/tracetools_analysis/tracetools_analysis/analysis/callback_duration.ipynb
```
--------------------------------
### Run Webots Local Simulation Server on Host
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Sets the `WEBOTS_HOME` environment variable to the Webots installation path and then runs the `local_simulation_server.py` script on the host machine. This server facilitates communication between Webots on the host and the ROS 2 package in the VM.
```bash
$ export WEBOTS_HOME=/Applications/Webots.app
$ python3 local_simulation_server.py
```
--------------------------------
### Complete CMakeLists.txt for ROS 2 C++ Service and Client
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client
This complete `CMakeLists.txt` file configures a ROS 2 package, defines both 'server' and 'client' executables, links them to necessary ROS 2 libraries, and sets up their installation targets. It's the final CMake configuration for the service/client example.
```CMake
cmake_minimum_required(VERSION 3.5)
project(cpp_srvcli)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(example_interfaces REQUIRED)
add_executable(server src/add_two_ints_server.cpp)
ament_target_dependencies(server rclcpp example_interfaces)
add_executable(client src/add_two_ints_client.cpp)
ament_target_dependencies(client rclcpp example_interfaces)
install(TARGETS
server
client
DESTINATION lib/${PROJECT_NAME})
ament_package()
```
--------------------------------
### Complete setup.py Configuration for ROS 2 Python Package
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
This snippet presents the complete and final `setup.py` file for a ROS 2 Python package. It includes package metadata, installation requirements, data files, and the crucial `console_scripts` entry point for defining executables.
```Python
from setuptools import setup
package_name = 'talker_py'
setup(
name=package_name,
version='1.0.0',
packages=['talker_py'],
package_dir={'': 'src'},
install_requires=['setuptools'],
zip_safe=True,
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
maintainer='Brian Gerkey',
maintainer_email='gerkey@example.com',
description='The talker_py package',
license='BSD',
entry_points={
'console_scripts': [
'talker_py_node = talker_py:main',
],
},
)
```
--------------------------------
### Re-run rosdep install after Qt5 fix
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Installation-Troubleshooting
Command to re-execute `rosdep install` after applying the symbolic link fix for Qt5, expecting a successful dependency installation.
```shell
$ rosdep install -i --from-path src --rosdistro humble -y
```
--------------------------------
### Create setup.cfg for ROS 2 Python Packages
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
This snippet shows how to create a `setup.cfg` file and add content to it. This file is crucial for `setuptools` to install Python scripts as executables in a package-specific directory, allowing `ros2 run` to find them.
```Shell
$ touch setup.cfg
```
```Windows Command Prompt
$ type nul > touch setup.cfg
```
```INI
[develop]
script_dir=$base/lib/talker_py
[install]
install_scripts=$base/lib/talker_py
```
--------------------------------
### Source ROS 2 Humble Environment Setup File
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
This command sources the ROS 2 setup file, typically `setup.zsh` for Zsh shells, to configure the current shell environment. Sourcing this file automatically sets up necessary environment variables, such as `ROS_DISTRO` and `AMENT_PREFIX_PATH`, making ROS 2 commands and packages available for use in the terminal session. It also configures support for any built DDS vendors.
```Shell
$. ~/ros2_humble/install/setup.zsh
```
--------------------------------
### Build and Launch ROS 2 Webots Simulation (Bash)
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Advanced
Commands to build the ROS 2 workspace and launch the `robot_launch.py` file to start the Webots simulation with the obstacle avoidance node, tailored for Linux, Windows (WSL), and macOS environments.
```Bash
$ colcon build
$ source install/local_setup.bash
$ ros2 launch my_package robot_launch.py
```
```Bash
$ colcon build
$ export WEBOTS_HOME=/mnt/c/Program\\ Files/Webots
$ source install/local_setup.bash
$ ros2 launch my_package robot_launch.py
```
```Bash
$ cd ~/ros2_ws
$ colcon build
$ source install/local_setup.bash
$ ros2 launch my_package robot_launch.py
```
--------------------------------
### ROS 2 Python Service Entry Point in setup.py
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client
This line defines an entry point in the `setup.py` file, allowing the `ros2 run` command to execute the `main` function within the `service_member_function` module of the `py_srvcli` package, thereby launching the ROS 2 service node.
```Python
'service = py_srvcli.service_member_function:main',
```
--------------------------------
### Install Executable to Project-Specific Directory
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-CPP-Package-Example
Modifies the `install()` command to place the `talker` executable into a project-specific directory (`lib/${PROJECT_NAME}`), ensuring proper installation within the ROS 2 environment.
```CMake
install(TARGETS talker
DESTINATION lib/${PROJECT_NAME})
```
--------------------------------
### Start Docker Daemon
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container
Command to manually start the Docker daemon if it's not running automatically.
```bash
$ sudo systemctl start docker
```
--------------------------------
### Verifying ROS2 setup.cfg Configuration
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber
Confirms the `setup.cfg` file correctly specifies the installation directories for scripts, ensuring `ros2 run` can locate the executables.
```INI
[develop]
script_dir=$base/lib/py_pubsub
[install]
install_scripts=$base/lib/py_pubsub
```
--------------------------------
### Run ROS 2 Python Listener Example
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/RHEL-Development-Setup
This snippet demonstrates how to run the Python `listener` demo node in a separate terminal after sourcing the ROS 2 setup script. The `listener` node subscribes to messages published by the `talker`, verifying the proper functioning of the Python API in ROS 2.
```bash
$ . ~/ros2_humble/install/local_setup.bash
$ ros2 run demo_nodes_py listener
```
--------------------------------
### Install Individual ROS 2 Packages from Testing Repository
Source: https://docs.ros.org/en/humble/index.html/Installation/Testing
Example command to install a specific ROS 2 package, `ros-humble-my-just-released-package`, from the `ros-testing` repository after it has been configured and the APT index updated.
```shell
$ sudo apt install ros-humble-my-just-released-package
```
--------------------------------
### Check Homebrew System Configuration
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
Runs `brew doctor` to check for potential issues or misconfigurations in the Homebrew installation. It identifies and suggests fixes for problems that might affect package installations.
```bash
$ brew doctor
```
--------------------------------
### rosdep install Qt5 failure output
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Installation-Troubleshooting
Displays the error message when `rosdep` fails to install Qt5 via Homebrew, indicating that Qt5 is already installed but not successfully detected due to a linking issue.
```shell
$ rosdep install -i --from-path src --rosdistro humble -y
executing command [brew install qt5]
Warning: qt 5.15.0 is already installed and up-to-date
To reinstall 5.15.0, run `brew reinstall qt`
ERROR: the following rosdeps failed to install
homebrew: Failed to detect successful installation of [qt5]
```
--------------------------------
### Install SVN and Mercurial with Chocolatey
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Installs SVN and Mercurial using Chocolatey, as some Python source-build dependencies require them.
```cmd
choco install -y svn hg
```
--------------------------------
### Install RQt Packages for ROS 2 Humble
Source: https://docs.ros.org/en/humble/index.html/Concepts/Intermediate/About-RQt
Install all RQt-related packages and common plugins for the ROS 2 Humble distribution using the system's package manager.
```bash
$ sudo apt install ros-humble-rqt*
```
--------------------------------
### Install PeaZip with Chocolatey
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Installs PeaZip using Chocolatey, a Windows package manager, to extract Python source tarballs.
```cmd
choco install -y peazip
```
--------------------------------
### Successful rosdep install output
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Installation-Troubleshooting
The expected output message confirming that all required ROS dependencies have been successfully installed after resolving previous issues.
```text
#All required rosdeps installed successfully
```
--------------------------------
### Launch ROS 2 Components using Launch Actions
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Composition
Automate the startup of ROS 2 components by executing a launch file. This command simplifies the process of starting multiple components simultaneously for debugging or deployment.
```bash
$ ros2 launch composition composition_demo.launch.py
```
--------------------------------
### ROS 2 CMake: Install Executable Target
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber
Configures the installation of the `talker` executable to `lib/${PROJECT_NAME}` within the ROS 2 install space, allowing it to be found and run using `ros2 run`.
```CMake
install(TARGETS
talker
DESTINATION lib/${PROJECT_NAME})
```
--------------------------------
### Create Header and Pluginlib XML for ROS 2 C++ Package
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Basic
Commands to create essential files for a ROS 2 C++ package: a header file for `MyRobotDriver` and an XML description file for pluginlib.
```Shell
$ touch my_robot_driver.xml
$ touch include/my_package/MyRobotDriver.hpp
```
--------------------------------
### Upgrade Python pip and setuptools
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Upgrades the `pip` package installer and sets `setuptools` to a specific version. This is a prerequisite for installing additional Python dependencies.
```cmd
python -m pip install -U pip setuptools==59.6.0
```
--------------------------------
### ROS 1 `setup.py` for Python Package with Catkin
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
The `setup.py` file for a ROS 1 Python package, using `setuptools` and `catkin_pkg.python_setup` to generate the necessary arguments for `distutils` setup, defining the package and its source directory.
```Python
from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup
setup_args = generate_distutils_setup(
packages=['talker_py'],
package_dir={'': 'src'}
)
setup(**setup_args)
```
--------------------------------
### Install ROS 2 Python Dependencies with pip
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
Upgrades pip and installs a wide array of Python packages required for ROS 2 development and testing. This includes build tools like `colcon`, linters, and other utilities necessary for the ROS 2 ecosystem.
```bash
$ python3 -m pip install --upgrade pip
$ python3 -m pip install -U \
--config-settings="--global-option=build_ext" \
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
argcomplete catkin_pkg colcon-common-extensions coverage \
cryptography empy flake8 flake8-blind-except==0.1.1 flake8-builtins \
flake8-class-newline flake8-comprehensions flake8-deprecated \
flake8-docstrings flake8-import-order flake8-quotes \
importlib-metadata lark==1.1.1 lxml matplotlib mock mypy==0.931 netifaces \
nose pep8 psutil pydocstyle pydot pygraphviz pyparsing==2.4.7 \
pytest-mock rosdep rosdistro setuptools==59.6.0 vcstool
```
--------------------------------
### Launch RQt GUI Framework
Source: https://docs.ros.org/en/humble/index.html/Concepts/Intermediate/About-RQt
Execute the main RQt graphical user interface, which provides a central hub to select and manage various available plugins.
```bash
$ rqt
```
--------------------------------
### Install Xcode Command Line Tools on macOS
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
Installs the necessary Xcode Command Line Tools on macOS. This step is crucial for compiling various software components, including ROS 2. It also switches the active developer directory to the Xcode application.
```bash
$ xcode-select --install
$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
```
--------------------------------
### Source ROS 2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber
After building, source the setup files in a new terminal to make the ROS 2 environment and your new package available. The command varies depending on your operating system (Linux, macOS, or Windows).
```Shell
$ source install/setup.bash
```
```Shell
$ . install/setup.bash
```
```Shell
$ call install/setup.bat
```
--------------------------------
### Install ROS2 Package Dependencies with rosdep
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Miscellaneous/Deploying-ROS-2-on-IBM-Cloud
This Dockerfile snippet installs the necessary dependencies for the custom ROS2 packages using `rosdep`. It updates `apt-get`, sources the ROS2 setup script, and then runs `rosdep install` for the specified demo packages, ignoring source packages.
```Dockerfile
# install overlay dependencies
ARG OVERLAY_WS
WORKDIR $OVERLAY_WS
COPY --from=cacher /tmp/$OVERLAY_WS/src ./src
RUN . /opt/ros/$ROS_DISTRO/setup.sh && \\
apt-get update && rosdep install -y \\
--from-paths \\
src/ros2/demos/demo_nodes_cpp \\
src/ros2/demos/demo_nodes_py \\
--ignore-src \\
&& rm -rf /var/lib/apt/lists/*
```
--------------------------------
### Source ROS2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Py
Sources the ROS2 workspace setup files to make the installed packages and environment variables available in the current terminal session.
```Shell
$ . install/setup.bash
```
```Batch
$ call install\setup.bat
```
```PowerShell
$.\install\setup.ps1
```
--------------------------------
### Start the turtlesim simulator node
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim
Command to launch the main turtlesim simulator node. This opens the graphical turtlesim window and initializes the default turtle, displaying informational messages in the terminal.
```bash
$ ros2 run turtlesim turtlesim_node
[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim
[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
```
--------------------------------
### Install ROS Humble URDF Simulation Tutorial Package
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/URDF/Using-a-URDF-in-Gazebo
Instructions to install the `urdf_sim_tutorial` demo package and its dependencies using different methods: Ubuntu apt, RHEL dnf, or cloning from source.
```bash
sudo apt install ros-humble-urdf-sim-tutorial
```
```bash
sudo dnf install ros-humble-urdf-sim-tutorial
```
```bash
git clone https://github.com/ros/urdf_sim_tutorial.git -b ros2
```
--------------------------------
### ROS 2 Launch Output Messages
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Launch/Creating-Launch-Files
Example of informational messages displayed in the terminal after successfully launching a ROS 2 system, indicating the processes started by the launch file.
```Bash
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [turtlesim_node-1]: process started with pid [11714]
[INFO] [turtlesim_node-2]: process started with pid [11715]
[INFO] [mimic-3]: process started with pid [11716]
```
--------------------------------
### Clone rmw_gurumdds source repository for ROS 2 Humble
Source: https://docs.ros.org/en/humble/index.html/Installation/RMW-Implementations/DDS-Implementations/Working-with-GurumNetworks-GurumDDS
Navigate to the ROS 2 workspace source directory and clone the `rmw_gurumdds` repository for the Humble branch to prepare for building from source.
```Bash
$ cd ros2_ws/src
$ git clone https://github.com/ros2/rmw_gurumdds -b humble ros2/rmw_gurumdds
```
--------------------------------
### Accept Xcode License Agreement
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/macOS-Development-Setup
Accepts the Xcode license agreement from the command line. This is required if Xcode was installed manually and the license has not yet been accepted, preventing build issues.
```bash
$ sudo xcodebuild -license
```
--------------------------------
### Upgrade Installed Colcon Packages
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Installation-Troubleshooting
Upgrades all installed `colcon` packages to their latest available versions using `apt`. This action can resolve issues with sourcing `setup.bash` by ensuring you have the most up-to-date `colcon` tools.
```bash
$ sudo apt install python3-colcon* --only-upgrade
```
--------------------------------
### Install turtlesim package on Linux
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim
Commands to update the package list and install the `ros-humble-turtlesim` package for your ROS 2 distribution on Linux. This ensures the turtlesim simulator is available for use.
```bash
$ sudo apt update
$ sudo apt install ros-humble-turtlesim
```
--------------------------------
### Source ROS2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Cpp
Sources the ROS2 workspace setup files to make the installed packages and executables available in the current terminal session. This is required before running ROS2 commands.
```Shell
$ . install/setup.bash
```
```Shell
$ call install\setup.bat
```
```Shell
.\install\setup.ps1
```
--------------------------------
### Install OpenSSL 1.1.1.2100 on Windows via Chocolatey
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Installs OpenSSL version 1.1.1.2100 using Chocolatey. OpenSSL is a critical dependency for secure communication within the ROS 2 ecosystem.
```Batch
choco install -y openssl --version 1.1.1.2100
```
--------------------------------
### Setup ROS 2 Turtlesim Nodes
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics
These commands launch the `turtlesim_node` and `turtle_teleop_key` nodes. The `turtlesim_node` provides a visual turtle simulation, while `turtle_teleop_key` allows controlling the turtle via keyboard input, both interacting through ROS 2 topics.
```bash
ros2 run turtlesim turtlesim_node
```
```bash
ros2 run turtlesim turtle_teleop_key
```
--------------------------------
### Source ROS 2 Workspace
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Sources the local setup script of the ROS 2 workspace, making the newly built `webots_ros2` package available in the current terminal session.
```bash
$ source install/local_setup.bash
```
--------------------------------
### Download Docker Compose configuration file
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Security/Deployment-Guidelines
Downloads the 'compose.deployment.yaml' file, which defines the Docker services for the deployment scenario. This includes 'keystore-creator', 'listener', and 'talker' services.
```bash
$ wget https://raw.githubusercontent.com/ros2/ros2_documentation/humble/source/Tutorials/Advanced/Security/resources/deployment_gd/compose.deployment.yaml
```
--------------------------------
### Set Qt5 Environment Variables (Windows)
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Sets system environment variables `Qt5_DIR` and `QT_QPA_PLATFORM_PLUGIN_PATH` for Qt5. These variables point to the Qt installation directory and its platform plugins, respectively. The paths may vary based on the installed MSVC version, Qt installation location, and Qt version.
```cmd
setx /m Qt5_DIR C:\Qt\Qt5.12.12\5.12.12\msvc2017_64
```
```cmd
setx /m QT_QPA_PLATFORM_PLUGIN_PATH C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\plugins\platforms
```
--------------------------------
### Launch Gazebo Simulation with `ign gazebo`
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Gazebo/Gazebo
Execute this command in a terminal to start a simple diff drive robot simulation using the `visualize_lidar.sdf` world in Gazebo.
```bash
$ ign gazebo -v 4 -r visualize_lidar.sdf
```
--------------------------------
### Download ROS 2 Python Publisher Example Code
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber
These commands download the 'publisher_member_function.py' example file from the ROS 2 examples GitHub repository. Choose the command appropriate for your operating system (Linux/macOS for wget, Windows Command Prompt or PowerShell for curl).
```bash
wget https://raw.githubusercontent.com/ros2/examples/humble/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py
```
```cmd
curl -sk https://raw.githubusercontent.com/ros2/examples/humble/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py
```
```powershell
curl https://raw.githubusercontent.com/ros2/examples/humble/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -o publisher_member_function.py
```
--------------------------------
### Bash/Batch: Sourcing ROS 2 Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Monitoring-For-Parameter-Changes-CPP
Commands to source the ROS 2 setup files after building, making the installed packages and executables available in the current terminal session. This is required for running ROS 2 commands and nodes.
```Bash
$ . install/setup.bash
```
```Batch
$ call install/setup.bat
```
--------------------------------
### Create ROS 2 Tracing Workspace and Import Repositories
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
This sequence of commands sets up a new workspace named `tracing_ws`, imports the ROS 2 Humble source code using `vcs import`, and then clones the `performance_test` and `tracetools_analysis` repositories, which are essential for performance testing and trace analysis in ROS 2.
```bash
$ cd ~/
$ mkdir -p tracing_ws/src
$ cd tracing_ws/
$ vcs import src/ --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos
$ cd src/
$ git clone https://gitlab.com/ApexAI/performance_test.git
$ git clone https://github.com/ros-tracing/tracetools_analysis.git -b humble
$ cd ..
```
--------------------------------
### Install ROS 2 Package Dependencies with rosdep
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber
Before building a ROS 2 workspace, run `rosdep` to check for and install any missing system dependencies. This command is primarily for Linux environments.
```Bash
$ rosdep install -i --from-path src --rosdistro humble -y
```
--------------------------------
### Run ROS 2 Launch File
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Launch/Creating-Launch-Files
Demonstrates how to execute a ROS 2 launch file created in XML, YAML, or Python format from the command line.
```Bash
$ cd launch
$ ros2 launch turtlesim_mimic_launch.xml
```
```Bash
$ cd launch
$ ros2 launch turtlesim_mimic_launch.yaml
```
```Bash
$ cd launch
$ ros2 launch turtlesim_mimic_launch.py
```
--------------------------------
### Source ROS 2 Workspace Setup for Application Execution
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
This command block changes the directory to the `tracing_ws` and sources the `install/setup.bash` script. This prepares the terminal environment by making the ROS 2 packages and executables available for running the `performance_test` application or any other ROS 2 application.
```bash
$ cd ~/tracing_ws
$ source install/setup.bash
```
--------------------------------
### Clone ROS 2 examples into workspace
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial
Command to clone the ROS 2 examples repository into the 'src' directory of the newly created workspace. This provides sample packages to build and work with.
```bash
$ git clone https://github.com/ros2/examples src/examples -b humble
```
--------------------------------
### Mount VM Shared Folder to Host
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Installation-MacOS
Mounts the VM's shared folder to the host machine using 9p filesystem, enabling data exchange. Ensure the path is correct for your setup.
```bash
$ sudo mount -t 9p -o trans=virtio share /home/ubuntu/shared -oversion=9p2000.L
```
--------------------------------
### Launch a single-link URDF model in Rviz
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/URDF/Building-a-Visual-Robot-Model-with-URDF-from-Scratch
This shell command launches the `display.launch.py` file from the `urdf_tutorial` package, loading the specified URDF model (`01-myfirst.urdf`). It initializes the `robot_state_publisher` node, publishes joint states and transforms, and starts Rviz with a pre-configured setup to visualize the robot model.
```Shell
$ ros2 launch urdf_tutorial display.launch.py model:=urdf/01-myfirst.urdf
```
--------------------------------
### Source ROS2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter
Sources the ROS2 workspace setup files to make the installed packages and executables available in the current terminal session. This is shown for Linux/macOS (bash), Windows Command Prompt, and PowerShell.
```Bash
. install/setup.bash
```
```Bash
call install\setup.bat
```
```Bash
.\install\setup.ps1
```
--------------------------------
### Start RViz Visualizer
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/RViz/RViz-User-Guide/RViz-User-Guide
Once the ROS 2 environment is set up, this command launches the RViz2 visualizer application. RViz provides a graphical interface for visualizing sensor data, robot models, and other information within the ROS ecosystem.
```bash
$ ros2 run rviz2 rviz2
```
--------------------------------
### Build ROS 2 Python Package Workspace
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
Provides commands to navigate to the workspace directory, source the ROS 2 Humble setup, and build the `talker_py` package using `colcon build` across Linux, macOS, and Windows environments.
```Bash
$ cd ~/ros2_talker_py
$ . /opt/ros/humble/setup.bash
$ colcon build
```
```Batch
$ cd \ros2_talker_py
$ call C:\dev\ros2\local_setup.bat
$ colcon build
```
--------------------------------
### Echo ROS 2 `/chatter` Topic Messages
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
Commands to source the ROS 2 Humble setup and subscribe to the `/chatter` topic using `ros2 topic echo` to display messages published by the `talker_py_node` on Linux, macOS, and Windows.
```Bash
$ . /opt/ros/humble/setup.bash
$ ros2 topic echo /chatter
```
```Batch
$ call C:\dev\ros2\local_setup.bat
$ ros2 topic echo /chatter
```
--------------------------------
### Install CMake via Chocolatey
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Windows-Development-Setup
Installs CMake using Chocolatey. CMake is a build system dependency for many Chocolatey packages. Users will also need to append `C:\Program Files\CMake\bin` to their system PATH.
```cmd
choco install -y cmake
```
--------------------------------
### Instantiate WebotsLauncher for Simulation Startup
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Basic
This snippet demonstrates the instantiation of the `WebotsLauncher` object, a custom action used to start a Webots simulation. The `world` parameter specifies the path to the `.wbt` file that the simulator will open, ensuring the correct environment is loaded.
```Python
webots = WebotsLauncher(
world=os.path.join(package_dir, 'worlds', 'my_world.wbt')
)
```
--------------------------------
### Source ROS 2 Setup and Verify Tracing Status
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Advanced/ROS2-Tracing-Trace-and-Analyze
These commands source the ROS 2 workspace setup script to make the installed packages available in the current shell. It then runs `tracetools status` to verify that LTTng is properly detected and ROS 2 core instrumentation is enabled, confirming tracing functionality.
```bash
$ source install/setup.bash
$ ros2 run tracetools status
```
--------------------------------
### ROS 1 `CMakeLists.txt` for Python Package with Catkin
Source: https://docs.ros.org/en/humble/index.html/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Package-Example
The `CMakeLists.txt` file for a ROS 1 Python package, using `catkin` to build and install Python programs. It defines the project, finds `catkin`, sets up Python, and installs the `talker_py_node` script.
```CMake
cmake_minimum_required(VERSION 3.0.2)
project(talker_py)
find_package(catkin REQUIRED)
catkin_python_setup()
catkin_package()
catkin_install_python(PROGRAMS
scripts/talker_py_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
```
--------------------------------
### Check General ROS 2 Setup with ros2 doctor
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor
Execute `ros2 doctor` to perform a comprehensive check of your ROS 2 environment. This command scans all setup modules and reports any warnings or errors, indicating the overall health of your installation.
```bash
$ ros2 doctor
All checks passed
```
--------------------------------
### Source ROS 2 Humble Environment Setup Script
Source: https://docs.ros.org/en/humble/index.html/Installation/Alternatives/Ubuntu-Install-Binary
This command initializes the ROS 2 Humble environment in the current shell session. Users should replace `.bash` with their specific shell extension if not using bash (e.g., `.sh` for sh/dash, `.zsh` for zsh).
```bash
. ~/ros2_humble/ros2-linux/setup.bash
```
--------------------------------
### Source ROS 2 Workspace Setup Files
Source: https://docs.ros.org/en/humble/index.html/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py
These commands source the ROS 2 setup files to make the workspace packages available in the current terminal session. Examples are provided for Linux/macOS (bash) and Windows (cmd and PowerShell).
```Shell
$ . install/setup.bash
```
```Shell
$ call install\setup.bat
```
```Shell
$ .\install\setup.ps1
```