Containers
Containers are lightweight, portable, and self-sufficient environments that encapsulate an application and its dependencies. They provide a consistent runtime environment across different systems, making it easier to develop, test, and deploy applications.
Why use a container? Typically, when software is developed, it relies on specific versions of libraries, tools, and configurations. This can lead to "it works on my machine" problems when the software is run on different systems. Containers solve this problem by packaging the application along with all its dependencies into a single unit that can run consistently across various environments.
Containers on the Autonomous Driving Platform
The platform uses Docker containers through airfield. Each ROS 2 package gets its own container image with exactly the software that package needs, and each program in a plan runs in its own container. You don't start a container yourself before running things: scripts/build, scripts/up and airfield project up start the ones they need.
Airfield requires a workspace that has been migrated to it. Check for an
airfield.yamlfile and apackages/folder in~/roboracer_ws. If your car has acontainerscript instead, it is still on the older layout; see the box below.
To work inside one package's container:
cd ~/roboracer_ws
airfield package shell ut_automata
Note: editing files with vim and running git commands should be done outside the container. The container shares the package's source with the car, so any changes made outside the container are reflected inside it.
To add software to a package's container, list it in the package's package.xml if the ROS code depends on it, or under dependencies: in that package's airfield.yaml for anything else, then rebuild. See Dependencies.
On the older layout: the ./container script
The older layout provides a simple wrapper on Docker: the ./container script in ~/roboracer_ws. Prior to running any shell command related to the Autonomous Driving Platform, start the container by running:
cd ~/roboracer_ws
./container shell
If you want to update the dependencies for your car, you can install them in the container by modifying the docker/Dockerfile and rebuilding the container with:
./container build
Note: All ros2 commands need to be run inside the container. If something is not working, be sure that you're inside the container by running
./container shellfrom theroboracer_wsdirectory. Once you're in the container, your terminal prompt will change to show:[docker]:orin@orin03:~/roboracer_ws$, whereorin03is the hostname of the car.
Troubleshooting
Docker command not found
Note: lab machines are managed by UTCS, so this troubleshooting step is not relevant to lab machines.
If you see an error like the following, reinstall Docker using the command: sudo apt install -y docker-ce. On an F1TENTH car, running the setup script again also fixes it.
orin@orin12:~/roboracer_ws$ ./container shell
./container: line 56: docker: command not found
./container: line 108: docker: command not found
./container: line 121: docker: command not found