This Docker container contains ROS 2 Humble, Gazebo Fortress, and the TurtleBot 4 simulation. The Docker container has been configured to work well on commodity hardware without a graphics card. Most reasonably configured hardware should be able to run the simulation with a real time factor of at least 0.2.
This Docker container is meant to be used with this example code for a toy TB4 node and the associated PyCon 2024 talk or ROSCon 2024 Workshop
This Docker also includes a full ROS 2 Humble install. If you would like to brush up on your ROS skills you can work through the ROS 2 tutorials. We suggest you start with the CLI Tutorials.
This workshop let's you choose your own adventure. You have two big decisions to make:
But wait, there's more! Do you just want to try out some of the great tutorials on docs.ros.org we also have instructions on how to do that too!
sudo apt install docker.io
sudo usermod -aG docker $(whoami)
source .//bin/activate
before starting your container.If you wish to build the Docker container from scratch:
git clone [email protected]:kscottz/turtlebot4_docker.git
docker build . -t tb4
If you wish to use the pre-built Docker image run:
docker pull osrf/icra2023_ros2_gz_tutorial:roscon2024_tutorial_humble_turtlebot4
Let's start by talking about how to start your container. We've provided a couple of options to run through the workshop. Take a look below but do not start the container yet! You have a few more options to decide on!
rocker --x11 --devices=/dev/dri osrf/icra2023_ros2_gz_tutorial:roscon2024_tutorial_humble_turtlebot4 bash
rocker --x11 --devices=/dev/dri tb4 bash
Note that all that changed here is the name of the container, which is the second to last parameter!
Now you must decided where you want to save your work. You have two options, start from scratch and build everything yourself, or follow along from a finished project. There is also a third option, where you just start the container but use Docker's internal tools to save your work. While this is certainly possible we don't recommend it.
If you want to work from scratch, our preferred workflow, then all you do is create a directory:
mkdir tb4_toy
rocker --x11 --devices=/dev/dri --volume=:/opt/ros/overlay_ws/src/tb4_toy bash
where the directory has been replaced by your new directory, and container is the container you want to use.rocker --x11 --devices=/dev/dri --volume=/home/kscottz/Code/tb4_toy/:/opt/ros/overlay_ws/src/tb4_toy tb4 bash
If you want to work from a finished code example, please do the following
git clone [email protected]:kscottz/tb4_toy.git
-- here's the code if you just want to peek.rocker --x11 --devices=/dev/dri --volume=:/opt/ros/overlay_ws/src/tb4_toy bash
where the directory has been replaced by your new directory, and container is the container you want to use.rocker --x11 --devices=/dev/dri --volume=/home/kscottz/Code/tb4_toy/:/opt/ros/overlay_ws/src/tb4_toy tb4 bash
Note that this tutorial will require you to work inside the container at all times and should leave your host system untouched. *If you happen to change the Docker container's internal configuration and want to save it, you will need to use [docker commit](https://docs.docker.com/reference/cli/docker/container/commit/)
to save your work.
If your laptop has a fancy graphics card you can enable it by omitting the line: --devices=/dev/dri
when you start your container. If you have a discrete graphics card we recommend you use it! If you don't have a graphics card, don't worry! We've specifically configured this workshop to work on older laptops.
The container for this workshop contains most of the common terminal editors found on Linux systems. You are more than welcome to use them. If you mounted your filesystem into Docker you can also use any editor on your host systems to edit files. If you have never used a terminal editor before this may be the easier approach.
We have a comprehensive guide to using this container without Rocker available here. This guide includes a number of Bash scripts that make starting an appropriate Docker container easy! This guide also provides some alternative approaches to performing ROS development inside of a container.
Once you have started your container you can launch ROS and Gazebo by running the following commands:
ros2 launch turtlebot4_ignition_bringup turtlebot4_ignition.launch.py world:=maze
source ./install/setup.bash
colcon build
ros2 launch turtlebot4_ignition_bringup turtlebot4_ignition.launch.py world:=maze
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 30.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}"
ros2 run teleop_twist_keyboard teleop_twist_keyboard
ros2 run tb4_toy toy_node
ros2 service call /do_loopy std_srvs/Trigger '{}'