/AutoDRIVE-F1TENTH-Sim-Racing

F1TENTH Sim Racing League using AutoDRIVE Ecosystem

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

AutoDRIVE-F1TENTH Sim-Racing

Github Stars Github Forks Github Downloads Sim Docker Stars Sim Docker Pulls API Docker Stars API Docker Pulls

AutoDRIVE-F1TENTH Sim-Racing

F1TENTH Digital Twin Autonomous Sim-Racing League using AutoDRIVE Ecosystem

Note

  • The setup has been only tested on the Ubuntu operating system.
  • It is assumed that Docker is installed.
  • It is assumed that if the Docker container is to take advantage of an NVIDIA GPU, the host machine has been properly configured by installing the necessary NVIDIA GPU drivers and the NVIDIA Container Toolkit.

AutoDRIVE Simulator Container

Note

The simulator executable must be placed inside /autodrive_simulator directory. This repository ships with an examplar working simulator executable, which can be updated as necessary.

Build:

docker build --tag autodriveecosystem/autodrive_f1tenth_sim:<TAG> -f autodrive_simulator.Dockerfile .

Run:

xhost local:root
docker run --name autodrive_f1tenth_sim --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all autodriveecosystem/autodrive_f1tenth_sim:<TAG>

Push:

  1. Run the image you created in the previous step inside a container:
xhost local:root
docker run --name autodrive_f1tenth_sim --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all autodriveecosystem/autodrive_f1tenth_sim:<TAG>
  1. In a new terminal window, list all containers and make a note of the desired CONTAINER ID:
docker ps -a
  1. Commit changes to Docker Hub:
docker commit -m "AutoDRIVE-F1TENTH-Sim-Racing" -a "AutoDRIVE Ecosystem" <CONTAINER ID> autodriveecosystem/autodrive_f1tenth_sim:<TAG>
  1. Login to Docker Hub:
docker login
  1. Push the container to Docker Hub, once done, you should be able to see your repository on Docker Hub:
docker push autodriveecosystem/autodrive_f1tenth_sim:<TAG>

AutoDRIVE Devkit Container

Note

The devkit package(s) must be placed inside /autodrive_devkit directory. This repository ships with an examplar working devkit package, which can be updated as necessary.

Build:

docker build --tag autodriveecosystem/autodrive_f1tenth_api:<TAG> -f autodrive_devkit.Dockerfile .

Run:

xhost local:root
docker run --name autodrive_f1tenth_api --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all autodriveecosystem/autodrive_f1tenth_api:<TAG>

Push:

  1. Run the image you created in the previous step inside a container:
xhost local:root
docker run --name autodrive_f1tenth_api --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all autodriveecosystem/autodrive_f1tenth_api:<TAG>
  1. In a new terminal window, list all containers and make a note of the desired CONTAINER ID:
docker ps -a
  1. Commit changes to Docker Hub:
docker commit -m "AutoDRIVE-F1TENTH-Sim-Racing" -a "AutoDRIVE Ecosystem" <CONTAINER ID> autodriveecosystem/autodrive_f1tenth_api:<TAG>
  1. Login to Docker Hub:
docker login
  1. Push the container to Docker Hub, once done, you should be able to see your repository on Docker Hub:
docker push autodriveecosystem/autodrive_f1tenth_api:<TAG>

Competition Execution

  1. Pull the team's image:
docker pull <TEAM_USERNAME>/<IMAGE_NAME>:<TAG>
  1. Run the team's image you pulled in the previous step inside a container:
xhost local:root
docker run --name autodrive_f1tenth_api --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all <TEAM_USERNAME>/<IMAGE_NAME>:<TAG>
  1. Run the simulator image inside a container, set graphics to Ultra quality and vehicle in Autonomous mode:
xhost local:root
docker run --name autodrive_f1tenth_sim --rm -it --entrypoint /bin/bash --network=host --ipc=host -v /tmp/.X11-unix:/tmp.X11-umix:rw --env DISPLAY --privileged --gpus all autodriveecosystem/autodrive_f1tenth_sim:<TAG>
  1. Begin screen recording (tested with OBS Studio).

  2. Execute a new bash session within the team's container, launch rqtgraph for inspection and start recording all data streams:

docker exec -it autodrive_f1tenth_api bash
ros2 bag record -a -o qualification.bag
ros2 bag record -a -o competition.bag
rqtgraph
  1. Enable the communication bridge between simulator and devkit to start the race.

  2. After the race completion, kill the rqtgraph, data recording as well as screen recording processes, and copy the rosgraph and rosbag file to the host workstation:

docker cp autodrive_f1tenth_api:/home/autodrive_devkit/qualification.bag /home/<USERNAME>
docker cp autodrive_f1tenth_api:/home/autodrive_devkit/competition.bag /home/<USERNAME>
docker cp autodrive_f1tenth_api:/home/autodrive_devkit/rosgraph.png /home/<USERNAME>

Generally Helpful Docker Tips

  1. To access the container while it is running, execute the following command in a new terminal window to start a new bash session inside the container:
docker exec -it <CONTAINER NAME> bash
  1. To exit the bash session(s), simply execute:
exit
  1. To kill the container, execute the following command:
docker kill <CONTAINER NAME>
  1. To remove the container, simply execute:
docker rm <CONTAINER NAME>
  1. Running or caching multiple docker images, containers, volumes, and networks can quickly consume a lot of disk space. Hence, it is always a good idea to frequently check Docker disk utilization:
docker system df
  1. To avoid utilizing a lot of disk space, it is a good idea to frequently purge docker resources such as images, containers, volumes, and networks that are unused or dangling (i.e. not tagged or associated with a container). There are several ways with many options to achieve this, please refer to appropriate documentation. The easiest way (but a potentially dangerous one) is to use a single command to clean up all the docker resources (dangling or otherwise):
docker system prune -a
  1. After Docker Desktop is installed, Docker CLI commands are by default forwarded to Docker Desktop instead of Docker Engine, and hence you cannot connect to the Docker daemon without running Docker Desktop. In order to avoid this, just switch to the default Docker context:
docker context ls
docker context use default

Note

It is not recommended to use Docker Desktop on the Linux operating system. This is because Docker Desktop creates a virtual machine based on Linux, which is first of all not needed for native (host) Linux OS, and secondly, it sometimes does not expose the necessary access ports for the containers (e.g., trouble with GPU access).

Citation

We encourage you to read and cite the following papers if you use any part of the competition framework for your research:

@article{AutoDRIVE-Ecosystem-2023,
author = {Samak, Tanmay and Samak, Chinmay and Kandhasamy, Sivanathan and Krovi, Venkat and Xie, Ming},
title = {AutoDRIVE: A Comprehensive, Flexible and Integrated Digital Twin Ecosystem for Autonomous Driving Research & Education},
journal = {Robotics},
volume = {12},
year = {2023},
number = {3},
article-number = {77},
url = {https://www.mdpi.com/2218-6581/12/3/77},
issn = {2218-6581},
doi = {10.3390/robotics12030077}
}

This work has been published in MDPI Robotics. The open-access publication can be found on MDPI.

@inproceedings{AutoDRIVE-Simulator-2021,
author = {Samak, Tanmay Vilas and Samak, Chinmay Vilas and Xie, Ming},
title = {AutoDRIVE Simulator: A Simulator for Scaled Autonomous Vehicle Research and Education},
year = {2021},
isbn = {9781450390453},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3483845.3483846},
doi = {10.1145/3483845.3483846},
booktitle = {2021 2nd International Conference on Control, Robotics and Intelligent System},
pages = {1–5},
numpages = {5},
location = {Qingdao, China},
series = {CCRIS'21}
}

This work has been published at 2021 International Conference on Control, Robotics and Intelligent System (CCRIS). The publication can be found on ACM Digital Library.