> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/ml-rl/rl-frameworks/gazebo-setup.md).

# Gazebo Setup

With ROS 2 Humble setup, run

```bash
sudo apt install ros-humble-gazebo-ros-pkgs
```

## Workspace Setup

{% embed url="<https://automaticaddison.com/how-to-create-a-workspace-ros-2-foxy-fitzroy/>" %}

Create workspace folder

```bash
mkdir -p ~/Desktop/test_ws/src
cd ~/Desktop/test_ws/src/
```

Add pre-existing packages into this folder. We will add the ros\_tutorials repository to our workspace. It contains the following packages: roscpp\_tutorials, rospy\_tutorials, ros\_tutorials, and turtlesim.

```bash
git clone https://github.com/ros/ros_tutorials.git -b humble-devel
```

Resolve dependencies

```bash
cd ~/Desktop/test_ws/
rosdep install -i --from-path src --rosdistro humble -y
```

### Build the workspace

```bash
colcon build
```

<figure><img src="/files/VfJaEopuye3wyCL2PFYd" alt=""><figcaption></figcaption></figure>

If the above error occurs when building turtlesim, run

```bash
pip install empy
pip install lark
```

and then rebuild

```bash
rm -rf ~/Desktop/test_ws/build/
rm -rf ~/Desktop/test_ws/install/
colcon build
```

> *The fix method above is found* [*here*](https://stackoverflow.com/questions/72752937/ros2-importerror-cannot-import-name-generate-py-from-rosidl-generator-py/74159022#74159022)*.*

<figure><img src="/files/epJkZ9TVIpm42Et87hrE" alt=""><figcaption></figcaption></figure>

### Source the workspace

```bash
source ~/Desktop/test_ws/install/setup.bash
```

## RVIZ Setup

{% embed url="<https://automaticaddison.com/how-to-load-a-urdf-file-into-rviz-ros-2/>" %}

```bash
sudo apt install ros-humble-joint-state-publisher-gui
sudo apt install ros-humble-xacro
```

### Create a ROS 2 Package

Move to the src (source) folder of your workspace and create the package using the following command.

```bash
cd ~/Desktop/test_ws/src/
ros2 pkg create --build-type ament_cmake two_wheeled_robot
```

Create some extra folders

```bash
cd ~/Desktop/test_ws/src/two_wheeled_robot/
mkdir config launch maps meshes models params rviz urdf worlds
```

Build the package

```bash
cd ~/Desktop/test_ws/
colcon build
```

```bash
colcon_cd two_wheeled_robot
```

## URDF


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tk233.gitbook.io/notes/ml-rl/rl-frameworks/gazebo-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
