🤖
Introduction to ROS2 and Robotics
  • Introduction
  • ROS2
    • Index
    • IDE and CMake Setup
      • How to add additional include search path
    • ROS2 Building Blocks
      • ROS Workspace and Package Layout
      • Launch File
      • tf2
      • Quality of Service
      • Configurations
        • Rviz Configuration
      • Built-in Types
        • Built-in Message Type
    • ROS Architecture
      • Intra-process Communication
    • Navigation and Planning
      • Navigation Stack and Concepts
      • Navigation2 Implementation Overview
        • 🏗️Cost Map
        • Obstacle Avoidance and DWB Controller
      • DWB Controller
      • Page 5
    • How to launch the Nav2 stack
    • ROS2 Control
      • Online Resources
      • Overview of Codebase
    • 🍳Cookbook
      • Useful Commands
      • How to specify parameters
      • How to build the workspace
      • 🏗️How to publish message to a topic from command line?
      • How to inspect service and make a service call
      • How to properly terminate ROS and Gazebo
      • How to add and remove models in Gazebo simulation dynamically
      • 🚧How to spin nodes
    • 🛒Tutorials
      • Services and Communication between ROS2 and Gazebo
      • Subscription and Message Filters Demo
      • Executor and Spin Explained
      • Lifecycle Node Demo
      • Robotic Arm Demo
      • ⚒️Multiple Robotic Arms Simulation Demo
      • 🚧Introduction to xacro
    • Page
    • 🍺Tech Blog
      • Difference between URDF and SDF and how to convert
  • Gazebo
    • Index
    • Terminology
    • GUI
    • World Frame and Axis
    • Cookbook
    • Page 1
  • Programming in Robotics
    • C++
      • CMake
    • Python
    • Rust
  • Mathematics in Robotics
    • Linear Algebra
    • Matrix Properties
    • Probability
      • Expectation-Maximization Algorithm
    • Multivariable Function and Derivatives
  • Physics in Robotics
  • Control of Dynamic Systems
    • Dynamic Response and Transfer Function
    • Block Diagram
    • PID Controller
  • Robot Modeling and Control
    • Rotation and Homogeneous Transformation
  • Probabilistic Robotics
    • Bayes Filter
    • Kalman Filter
    • Particle Filter
    • Discrete Bayes Filter
    • Motion Model
    • Perception Model
    • Localization
    • SLAM
  • Miscellany
  • Concept Index
    • Quaternions
Powered by GitBook
On this page
  • Create Workspace
  • Create C++ Package
  • Create Python Package
  • Build Workspace
  • How to specify the namespace and node name in the command line?
  • How to check URDF file
  • How to turn on the debug info when launch the stack?
  1. ROS2
  2. Cookbook

Useful Commands

Create Workspace

A ROS2 project workspace has a standard structure. First, we create the root directory of the workspace

mkdir MyRosWorkspace

Then, we go to the workspace directory and create a build directory

cd MyRosWorkspace
mkdir build

Create C++ Package

Go to the workspace root directory and use the pkg create command. For instance

cd MyRosWorkspace
ros2 pkg create MyFirstProject --build-type ament_cmake

Create Python Package

Go to the workspace root directory and use the pkg create command. For instance

cd MyRosWorkspace
ros2 pkg create MyPythonProject --build-type ament_python

Build Workspace

To build the workspace, we use the following command:

rosdep install -i --from-path src --rosdistro humble -y
colcon build --symlink-install

The first command checks missing dependencies and the second command build the whole workspace. To build a specific package, use the following command:

colcon build --packages-select <package name>

How to specify the namespace and node name in the command line?

ros2 run <package> <executable> --ros-arg -r __ns:=/MyNamespace -r __name:=MyNodeName

How to check URDF file

To validate a URDF, you can use the following command:

check_urdf <urdf-file-path>

How to turn on the debug info when launch the stack?

Use the -d option. For example:

ros2 launch -d <package> <launch-filename>
PreviousCookbookNextHow to specify parameters

Last updated 1 year ago

In ROS2, the namespace and node name can be specified in the command line through the remap. For more information, please refer to the design doc . The command below shows the syntax:

🍳
Remapping Names