> For the complete documentation index, see [llms.txt](https://www.learnros2.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.learnros2.com/ros/cookbook/useful-commands.md).

# Useful Commands

## Create Workspace

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

```
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?

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 [Remapping Names](https://design.ros2.org/articles/static_remapping.html). The command below shows the syntax:

```
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>
```
