Simulation Tools
Simulation is useful for testing and validating models in a controlled environment. It can also be used for training learned models. This document provides setup instructions for the Autonomous Driving Simulator. It also allows you to run ROS2 on your computer for testing. A further advantage of setting up the simulator is to enable you to connect from RVIZ on your local computer to the car.
Setup
There are two main steps required to setup the simulator:
First we will setup the docker container to run ROS2. Then, we will install the Unity game engine and load the simulator project.
Setup ROS2 in Docker
We'll use the docker container to run ROS2 commands. In order to allow graphical programs to run inside the container, we'll use a TurboVNC server inside the container.
./container shell
- Install Docker on your computer, if you haven't already.
NOTE: Verify docker is working in your terminal by running
docker --version. If you get an error, ensure docker is installed, and if using MacOS or Windows, ensure that the Docker Desktop app is running.
- Clone the roboracer_ws repository. To your home directory:
cd ~
git clone https://github.com/ut-av/roboracer_ws.git
- Check out the child git projects inside the roboracer_ws directory:
cd ~/roboracer_ws
./scripts/checkout.sh
Note: this will checkout the latest ROS code and download a copy of the simulator binary that will run inside the docker container.
- Build the docker container:
./container build
- Test the docker container:
./container shell
- Launch the turbovnc server inside the container:
vnc
-
Download and install the TurboVNC viewer on your computer.
-
Open TurboVNC and connect to the vnc server running locally on your computer, inside the docker container at
localhost:5909. -
Now launch
rviz2from inside the container.
rviz2
Build the ROS workspace
Enter the container and build the ROS workspace:
./container shell
make
Launch the Simulator
Run the simulator tmux config:
Note: install tmuxinator first, if you haven't already.
cd ~/roboracer_ws/tmux/sim_teleop
tmuxinator
(Optional) Setup Unity
If you want to modify the simulator, you will need to setup Unity.
-
Install Unity Hub
-
Create a free Unity account if you do not already have one. Login to Unity Hub
-
Clone the simulator repo into the
~/roboracer_wsdirectory.
cd ~/roboracer_ws
git clone https://github.com/ut-av/simulator.git
-
Open the simulator project in Unity Hub
-
Click "Add", "Add project from disk", then choose the directory "~/simulator/simulator/unity"
-
When prompted, Install the latest LTS version of Unity.
-
Wait for the the unity editor to download and install.
-
Open the simulator project in Unity Hub by double clicking the project named "unity" in the "Projects" tab of the Unity editor.