Skip to content

kscottz/turtlebot4_docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The TurtleBot 4 Simulator in a Docker Container

Turtlebot4 Docker

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.

Choose Your Own Adventure

This workshop let's you choose your own adventure. You have two big decisions to make:

  • Build the container yourself -or- pull down the container from DockerHub.
    • In a classroom setting we recommend pulling the container down from DockerHub.
    • If you are home we recommend you build the container yourself. It will allow you to build a ROS + Gazebo Docker container that fits your particular needs.
  • Write the code yourself from scratch -or- follow along from a finished repository.
    • We recommend you write the code yourself! It will give you experience with the ROS APIs and development process. You can always peek at the finished project for some help.
    • If you want to follow along from the finished project you can clone the following repository into your working directory.

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!

Setup Instructions

  • Install Docker with sudo apt install docker.io
  • You may need to add yourself to the Docker group with the command sudo usermod -aG docker $(whoami)
  • Install Rocker (see instructions). Make sure to setup and use a Python virtual environment.
  • Note your virtual environment's name and location. You'll need to call source ./<venv>/bin/activate before starting your container.

If you wish to build the Docker container from scratch:

  • Clone this repository git clone git@github.com:kscottz/turtlebot4_docker.git
  • Build the container using: docker build . -t tb4
  • REMEMBER tb4 is the name of your image in this case

If you wish to use the pre-built Docker image run:

  • docker pull osrf/icra2023_ros2_gz_tutorial:roscon2024_tutorial_humble_turtlebot4
  • DockerHub link
  • REMEMBER that osrf:roscon2024_tutorial_humble_turtlebot4 is the name of your container

How to Start Your Container

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!

  • If you downloaded your Docker container you can start it using:
    • rocker --x11 --devices=/dev/dri osrf/icra2023_ros2_gz_tutorial:roscon2024_tutorial_humble_turtlebot4 bash
  • If you built your Docker container you can start it using:
    • 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
    • Now run, rocker --x11 --devices=/dev/dri --volume=<full path to your directory>:/opt/ros/overlay_ws/src/tb4_toy <container name> bash where the directory has been replaced by your new directory, and container is the container you want to use.
    • Here's an example from my system: 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 git@github.com:kscottz/tb4_toy.git -- here's the code if you just want to peek.
    • Now run, rocker --x11 --devices=/dev/dri --volume=<full path to your directory>:/opt/ros/overlay_ws/src/tb4_toy <container name> bash where the directory has been replaced by your new directory, and container is the container you want to use.
    • Here's an example from my system: 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.

A Note on Graphics Cards

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.

A Note on Editors

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.

Want to use just Docker?

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.

Running ROS and Gazebo

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

How to Start Gazebo and ROS

source ./install/setup.bash
colcon build
  • Now start the Maze simulator
ros2 launch turtlebot4_ignition_bringup turtlebot4_ignition.launch.py world:=maze

Other useful commands:

  • Send a velocity command: 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}}"
  • Control the robot via keyboard: ros2 run teleop_twist_keyboard teleop_twist_keyboard
  • Run the toy node: ros2 run tb4_toy toy_node
  • Trigger the toy node service: ros2 service call /do_loopy std_srvs/Trigger '{}'

NEED HELP?!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 100.0%