# Adding Obstacles in simulation

## Get all models to be used in Regional Finale

Below zip file contains all the gazebo models to be used in Regional Finale:

{% file src="https://1677675178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWeiLnwrIKZJWLFsXhf%2Fuploads%2Fgit-blob-1af4021e770edfb4b63a716c4b8cf601e01ff691%2Fmodels_w_collision_sensor.zip?alt=media" %}
Gazebo obstacles (updated)
{% endfile %}

{% hint style="danger" %}
Please make sure you have latest obstacles, which are uploaded on 17th July,2024 (2 PM IST)
{% endhint %}

Download and extract the obstacles in the following folder: _**\~/cognipilot/cranium/src/dream\_world/models**_

{% hint style="info" %}
Make sure to delete all previous models of same name while extracting new updated models for the same
{% endhint %}

After extraction your folder should look like this:

![](https://1677675178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWeiLnwrIKZJWLFsXhf%2Fuploads%2Fgit-blob-f2b26d479dcee95ef7ee10a2bf323bb776d83038%2Fmodel_dir.png?alt=media)

## Adding Obstacles in Simulation World

To add obstacles to appear at start of simulation, you need to add model information to be included in the world file. To do this navigate to folder: _**\~/cognipilot/cranium/src/dream\_world/worlds**_ And open the _**Raceway\_1.sdf**_ file to include the information of various obstacles to be included in the simulation world at the start.

![](https://1677675178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWeiLnwrIKZJWLFsXhf%2Fuploads%2Fgit-blob-7a609dcb43e694b7d4decfc7e9ef13e8ac2496d5%2Fworld_dir.png?alt=media)

After the last tag at the end of world file, we will add the information related to the models/obstacles to be spawned at the start. Refer to below image for more information:

{% hint style="info" %}
Only models that are present in \_\_\*\*\~/cognipilot/cranium/src/dream\_world/models\*\*\_ directory can be included into the simulation by this method.
{% endhint %}

![](https://1677675178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWeiLnwrIKZJWLFsXhf%2Fuploads%2Fgit-blob-afded19678dec635105ef6f077a584658de89085%2Fworld_file.png?alt=media)

#### Explanation of code:

```
<include>
  <uri>models://Raceway_1</uri>
  <name>track</name>
  <pose>0 2.245 0 0 0 1.55</pose>
</include>
```

* **"include":** This tag will contain information about one unique instance of any model spawned in simulation. Make sure to always have end tag as well, when using this (_"include"_).
* **"uri":** This tag will contain name/type of the model to be spawned into the simulation. This represents the name of the desired model that has to be spawned and is stored either in _**\~/cognipilot/cranium/src/dream\_world/models**\*_ .

{% hint style="info" %}
Please make sure the name of the model passed to the _"URI tag"_ parameter must be case sensitive as well as present in the mentioned folder.
{% endhint %}

* **"name":** It is a custom unique identifier given to each entity which allows Gazebo to keep track of each model spawned into the simulation.

{% hint style="info" %}
Use unique string values for the _"name"_ parameter for each obstacle to be added. As same value will not spawn the obstacles into simulation
{% endhint %}

* **"pose":** This parameter defines the position and orientation of models in simulation. rIt is represented by "x y z R P Y" where: **x is x-coordinate, y is y-coordinate, z is z-coordinate, R is roll, P is pitch and Y is yaw.**

{% hint style="danger" %}
Please make sure to run all the update commands mentioned to re-build the stack, in order to see the changes in next simulation run.
{% endhint %}
