Install docker-based TurtleBot3 simulator
Some systems may have difficulties running Gazebo inside Docker
As part of this guide, we run the Gazebo-based TurtleBot3 simulator inside a Docker container.
Consider running the ROS-based turtlebot natively by following the instructions here and installing the Formant agent natively as described here if you are running into difficulties using Docker.
Some users have reported success using Rocker to resolve issues running Gazebo simulations inside Docker.
Overview
This tutorial provides a step-by-step walkthrough of setting up and driving a turtlebot based simulator on a Linux machine.
Requirements
We will be using docker containers to run the TurtleBot3 simulator in Gazebo. Please install docker before continuing.
The turtlebot container is only available for Linux systems with x86_64 architecture.
To run this simulator, we recommend launching a Linux cloud VM with at least 4 cores and 16GB of RAM. You can run this locally if your system meets those requirements.
Step 1: Install a ROS-compatible Formant agent using a docker installation
Follow this guide to install the agent:
Installing the Formant agent using Docker
Make sure to follow the instructions for ROS users, setting ROS_MASTER_URI to http://localhost:11311
, and verify successful installation.
Step 2: Install turtlebot simulator as standalone docker container
The TurtleBot3 simulator container runs a ROS core
Make sure no ROS core (including ROS launch) is running prior to following the instructions in this guide.
The next step is to setup the simulator. This can be done with a single command:
sudo docker run -it --net host --rm --name formant-turtlebot formant/turtlebot
Note: we use --net=host
as a default network so the agent, turtlebot, and any extensions can communicate. It is also possible to create your own Docker network, but that is outside the scope of this guide.
We aren't running this in detached mode (-d option) so we can check for errors and ensure things are working smoothly, and restart quickly if needed.
If data is flowing correctly, you should see the following:
[ INFO] [1610997557.299617213, 1.949000000]: odom received!
If you would like to leave the turtlebot as a long-running container, kill the previous command using CTRL+C or equivalent on your system and run:
sudo docker run -it --net host -d --name formant-turtlebot formant/turtlebot
Which will run in detached mode. You can check the logs with:
sudo docker logs formant-turtlebot
Note: you can optionally add --device /device/snd to fix these warnings, however it is not required (and your machine may not have a soundcard, the AWS VM does not):
[ WARN] [1610997554.214580653]: Request for map failed; trying again...
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
[ INFO] [1610997554.535005762]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1610997554.559267119]: Physics dynamic reconfigure ready.
Step 3: Configure teleoperation
The next step is to import the configuration for the simulation into Formant using the web app.
config.yaml for this simulator:
tags: {}
teleop:
views:
- streamName: /camera/rgb/image_raw
- streamName: localization
- streamName: $.host.network
armSwitch: false
joysticks:
- x:
expo: 2
scale: -1
dimension: angular-z
gamepadAxis: 2
'y':
expo: 2
scale: 0.5
dimension: linear-x
gamepadAxis: 3
position: left
rosStreams:
- mode: observe
topicName: /camera/rgb/image_raw
topicType: formant/H264VideoFrame
- mode: command
topicName: /cmd_vel
topicType: geometry_msgs/Twist
- mode: command
topicName: /cancel
topicType: std_msgs/Bool
- mode: command
topicName: /goal_one
topicType: std_msgs/Bool
- mode: command
topicName: /goal_two
topicType: std_msgs/Bool
- mode: command
topicName: /goal_three
topicType: std_msgs/Bool
- mode: observe
topicName: /statusOne
topicType: std_msgs/Bool
- mode: observe
topicName: /statusTwo
topicType: std_msgs/Bool
- mode: command
topicName: /goal
topicType: geometry_msgs/PoseStamped
- mode: command
topicName: /move_base/cancel
topicType: actionlib_msgs/GoalID
customStreams:
- mode: command
name: slider
rtcStreamType: numeric
telemetry:
streams:
- name: localization
configuration:
type: ros-localization
mapTopic: /map
goalTopic: /move_base_simple/goal
odomTopic: /odom
pathTopic: /move_base/DWAPlannerROS/global_plan
pointCloudTopics:
- /scan
baseReferenceFrame: map
- Save the contents of config.yaml on your desktop.
- Navigate to Settings -> Devices -> (your device) -> General in the Formant web app.
- At the bottom of the General settings page, select Import from YAML and choose config.json.
This will setup the teleoperation (as well as observability streams, if your plan supports it). If things are configured properly you will be dropped into a real-time view through the robot:
Step 4: Teleoperate the Turtlebot simulator
You can use your keyboard arrow keys to control the simulation and drive the robot around the house. Additionally you can click the goal buttons to have it navigate to different parts of the house. (Note some features displayed are part of our Starter and Premium offerings). For more information on teleoperation, see our Teleoperation Guide.
Updated 12 months ago