This repo provides multiple containers to work with Turtlebot4 Robots in DiscoveryServer Mode.
This pacakge provides and utilizes following containers
-
Turtlebot4-Discovery
Provides the discovery service for the simulation -
Turtlebot4-Simulation
Provides the Gazebo based simulation environment -
Turtlebot4-Rviz
Provides rviz tools to interact with both simulation and physical robots -
Turtlebot4-workspace
Provides a workspace that can be used to test code on both simulation and physical robots
This packages contains two compose files that handles environmental variable configurations for Discovery Server on behalf of the user, so the user can focus on development without configuration worries
compose.yamlfor simulated robotcompose.physicalfor physical robot (assumes Nav2 & Slamtoolbox is running natively on the robot)
Read more information on following documents
Follow the official instructions here
On the terminal run the following command to clone the repo
git clone https://github.com/CollaborativeRoboticsLab/turtlebot4-docker.gitEnter the folder
cd turtlebot4-dockerPull the latest docker containers
docker compose pullRequired environmental variable need to be in a .env file. An example.env file is available. Rename that file to .env and update the values as required.
When the stack is up, the workspace container serves a web VS Code at http://127.0.0.1:8080.
- Default password:
student(set viaPASSWORDin compose) - Workspace folder:
/workspace(mounted from./turtlebot4-workspace/workspace) - Settings/extensions persist to:
./turtlebot4-workspace/code-server/config→/root/.config/code-server./turtlebot4-workspace/code-server/data→/root/.local/share/code-server
To change the password, edit the PASSWORD env in compose.yaml under the turtlebot4-workspace service.
On the compose.yaml file, Change the following line to select mapping or localization.
command: ["ros2", "launch", "turtlebot4_gz_bringup", "turtlebot4_gz.launch.py", "nav2:=true", "localization:=true", "slam:=false", "use_sim_time:=true"]slam:=truewill allow the simulated robot to map the room. use gazebo joystick option to move the robotnav2:=truealong withlocalization:=trueto navigate the robot. Default is warehouse
Start the docker containers
docker compose upFor GUI containers (simulation, rviz), allow X11 access on the host if needed:
# Allow local-root X11 access for GUI apps in containers
xhost +local:rootOn the robot run following command to run the mapping process. Use a name like office to save the file
ros2 launch turtlebot4_navigation slam.launch.pyMove the robot using joystick to map the room.
On the robot run following command to run the localization process with a created map
ros2 launch turtlebot4_navigation localization.launch.py map:=office.yamlAnd on another terminal run nav2
ros2 launch turtlebot4_navigation nav2.launch.pyThen use the 2D pose Estimate tool to align the robot's laser scan with the map. Finally give a Navigation goal via Nav2 Goal tool
Export following commands on the remote pc terminal. Make sure the ROS_DOMAIN_ID and ROS_DISCOVERY_SERVER matches the robot's configuration.
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export ROS_SUPER_CLIENT=True
export ROS_DOMAIN_ID=10
export ROS_DISCOVERY_SERVER="10.42.0.1:11811;"And then run the following command to open rviz
ros2 launch turtlebot4_viz view_navigation.launch.pyUpdate the compose-physical.yaml file with correct configuration on following parameters
- ROS_DOMAIN_ID=10
- RMW_IMPLEMENTATION=rmw_fastrtps_cpp
- ROS_DISCOVERY_SERVER=10.42.0.1:11811
- ROS_SUPER_CLIENT=1Allow permission for UI interfaces from docker containers
# Allow local-root X11 access for GUI apps in containers
xhost +local:rootStart the docker containers
docker compose -f compose-physical.yaml upUse code-server to edit files under /workspace (mounted from ./turtlebot4-workspace/workspace). We recommend creating a ROS 2 colcon workspace inside /workspace:
# In the code-server terminal (already sourced via ros entrypoint)
mkdir -p /workspace/turtle_ws/src
cd /workspace
colcon build --merge-install
# Use the overlay
source /workspace/install/setup.bash
ros2 pkg listPlace your packages in /workspace/turtle_ws/src, build with colcon, and run as usual. The code-server terminal is ROS-ready (environment is sourced by the container entrypoint).