# Execute AIM 2024 (Automation Setup)

## Download the automation setup

Download the following package:

{% file src="/files/DxzqsYSPNYE1IiTq6yN3" %}
sample obstacles
{% endfile %}

Extract this package at location: ***\~/cognipilot/cranium/***. After extraction your directories should look like the following:

![](/files/r5c2Hq81pWCpkMnctHUt)

![](/files/gYNVaOl55wzIjA8BR61p)

## What does this launcher does?

This launcher will take care of the following steps to execute the AIM 2024 simulation setup:

* Preparation for clean build: deleting previous build's log, build and install folders
* Clean Build: colcon build
* Sourcing the setup.bash: source \~/cognipilot/cranium/install/setup.bash
* Updating the Raceway\_1.sdf world file to include the obstacles, before the build
* Launching the simulation: ros2 launch b3rb\_gz\_bringup sil.launch.py world:=Raceway\_1
* Auto firing of command: ros2 run b3rb\_ros\_line\_follower vectors
* Auto firing of command: ros2 run b3rb\_ros\_line\_follower detect
* Auto firing of command: ros2 run b3rb\_ros\_line\_follower runner

{% hint style="info" %}
This launcher will do all the pre-requiste manual work to run the buggy in the simulation by default i.e. user doesn't need to manually run above said commands.
{% endhint %}

{% hint style="info" %}
The launcher will automatically always clean build the setup before execution, i.e. all changes will be automatically included. No need to separately run build/update commands.
{% endhint %}

## Updating obstacles using the launcher in Raceway\_1.sdf file

To add/remove the obstacle and track models in simulation, using this launcher one doesn't need to manually update the **Raceway\_1.sdf** world file present at ***\~/cognipilot/cranium/src/dream\_world/worlds***. To add obstacles using the launcher, one need to open and edit the ***models\_config.json*** file present inside the launcher directory (***\~/cognipilot/cranium/AIM\_2024\_launcher***), in the following manner:

![](/files/a8MyVVQAozQNmOniMq5O)

#### Explanation of code:

{% hint style="info" %}
Please make sure to save the file before running the launch command and follow proper JSON syntax in the file
{% endhint %}

```
"embed_model_1": {
	"pose": "0.2 -0.45 0.09 0 0 0",
	"type": "start_point"
}
```

* **"embed\_model\_1":** 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 *"embed\_model\_1"* key 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.**
* **"type":** 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 *"type"* parameter must be case sensitive as well as present in the mentioned folder.
{% endhint %}

{% hint style="info" %}
Please make sure to save the file before running the launch command and follow proper JSON syntax in the file
{% endhint %}

## Executing the launcher

To execute the launcher, open a new terminal in directory: ***\~/cognipilot/cranium/AIM\_2024\_launcher***.

There are two modes of executing the launcher: start and stop

### Start mode

This mode will do the following steps in mentioned order: - Close the previous running simulation instance - Update the world file in dream\_worlds folder - Perform clean build of stack - Sourcing of bash file - Launch the simulation - Execute commands to make buggy move autonomously in simulation

{% hint style="info" %}
This will automatically include all the changes done by user in **b3rb\_ros\_line\_follower** module/folder.
{% endhint %}

To execute the launcher in start mode, run the following command on terminal:

```
$ python launch_sim.py start
```

On executing the above command you will get output similar to:

![](/files/nn4yA501dfDxclBceNsL)

![](/files/2pbKsQtzmieOLpn1EhQi)

![](/files/6VQElQq5PelO2nkG99zY)

### Stop mode

This mode will only close the running simulation instance

To execute the launcher in stop mode, run the following command on terminal:

```
$ python launch_sim.py stop
```

On executing the above command you will get output similar to below image and simulation instance will terminate, killing all background process needed by simulation to run and communication between ros2 and gazebo:

![](/files/sMQ87vsJxQN3sf14Jvdm)


---

# Agent Instructions: 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:

```
GET https://nxp.gitbook.io/nxp-aim/start-aim-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
