This tutorial should help you get started with simulating robot navigation in a predefined environment. We will also have other mooving objects in the enviroment that the robot can track. This tutorial assumes some familiarity ROS (i.e. setting up a workspace etc.) and commands are provided for Ubuntu 20.04 (ROS noetic). For other distrbutions simply replace noetic
with whatever your distro corresponds to e.g. melodic
for Ubuntu 18.04.
The first step is to have the full installation of ROS by running:
$ sudo apt install ros-noetic-desktop-full
This will install - among other things - ROS and Gazebo. Gazebo gives provides a configurable environment to simulate the robot navigation. You can confirm the installation of gazebo by running:
$ gazebo
If everything works fine, you should see an empty world (enviroment) like below:
Great! The next step is to add a robot to our Gazebo world. While it possible to configure a robot from scratch, there are lots of open-source alternatives available here. We will be using Turtlebot3 so install the following ROS packages:
$ sudo apt-get install ros-$ROS_DISTRO-joy ros-$ROS_DISTRO-teleop-twist-joy \
ros-$ROS_DISTRO-teleop-twist-keyboard ros-$ROS_DISTRO-laser-proc \
ros-$ROS_DISTRO-rgbd-launch ros-$ROS_DISTRO-rosserial-arduino \
ros-$ROS_DISTRO-rosserial-python ros-$ROS_DISTRO-rosserial-client \
ros-$ROS_DISTRO-rosserial-msgs ros-$ROS_DISTRO-amcl ros-$ROS_DISTRO-map-server \
ros-$ROS_DISTRO-move-base ros-$ROS_DISTRO-urdf ros-$ROS_DISTRO-xacro \
ros-$ROS_DISTRO-compressed-image-transport ros-$ROS_DISTRO-rqt* ros-$ROS_DISTRO-rviz \
ros-$ROS_DISTRO-gmapping ros-$ROS_DISTRO-navigation ros-$ROS_DISTRO-interactive-markers
and Turtlebot3
$ sudo apt install ros-$ROS_DISTRO-dynamixel-sdk
$ sudo apt install ros-$ROS_DISTRO-turtlebot3-msgs
$ sudo apt install ros-$ROS_DISTRO-turtlebot3
Next we update .bashrc
to use the burger
model:
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc
source ~/.bashrc
Finally, install Turtlebot3 simulation packages by running:
$ cd ~/catkin_ws/src/
$ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ cd ~/catkin_ws && catkin_make
Three worlds are provided by in the turtle3_simulations
package. Launch the empty world by running:
$ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
You should see a static robot in the world:
You can control the robot with a teleoperation node by running (in another terminal):
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
With this, you should be able to move the robot to a new position:
Next, we want to add an actor to the scene. Tdo this we need to edit the turtlebot3_empty_world.launch
file to add actor. Navigate to the folder
$ cd ~/catkin_ws/src/turtlebot3_simulations/turtlebot3_gazebo/worlds
First we want to make a backup of the empty.world
file:
$ cp empty.world empty_backup.world
Next open the empty.world
file and add the following after the closing </physics>
(before </world>
):
<actor name="actor">
<skin>
<filename>walk.dae</filename>
</skin>
</actor>
You should get a world with the robot and a moving person:
Finally, if you were successful until now, you will notice that sequence of the moving person is short. If you want to extend (to test your tracking for example), you can modify the world file to add transitions and new poses over time. Here is an example:
<script>
<loop>true</loop>
<trajectory id="0" type="walking">
<waypoint>
<time>0</time>
<pose>0.5 0 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>10</time>
<pose>0.5 0 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>18</time>
<pose>3 0 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>28</time>
<pose>3 0 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>41</time>
<pose>-3 -1.5 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>50</time>
<pose>-3 -1.5 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>64</time>
<pose>3 -1.5 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>73</time>
<pose>3 -1.5 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>86</time>
<pose>-3 1 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>93</time>
<pose>-3 1 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>105</time>
<pose>2.5 1.5 0 0 0 0</pose>
</waypoint>
<waypoint>
<time>117</time>
<pose>2.5 1.5 0 0 0 0</pose>
</waypoint>
</trajectory>
</script>
Add that between the closing </script>
tag and the closing </actor>
tag. You should see the actor move to several postions in the world and restart from the origin when the sequence ends.
With this you should be ready to track the moving person in simulation.