Note: This tutorial assumes that you have completed the previous tutorials: rc_visard/Tutorials/CreateOctomapWithSLAM. |
Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Navigation with TurtleBot
Description: This tutorial describes how to use the rc_visard for navigation with the TurtleBotKeywords: rc_visard, TurtleBot, navigation, SLAM
Tutorial Level: BEGINNER
Next Tutorial: rc_visard/Tutorials/PickModule-MoveItTutorial
Contents
Goal
This tutorial shows how to use rc_visard for navigation with the TurtleBot - as demonstrated in the second half of the following "fruitful" video:
(If the video doesn't show up, click here)
Overview
The tutorial makes use of the rc_visard_turtlebot_tutorial demo application to showcase Roboception's rc_visard in a mobile robot scenario utilizing TurtleBot and rc_visard's on-board SLAM module to autonomously navigate in a pre-built map.
Execute
Make sure the octomap has already been captured as explained in rc_visard/Tutorials/CreateOctomapWithSLAM. The package rc_visard_turtlebot_tutorial needs to be installed and the TurtleBot Installation has to be executed before executing this tutorial. The proper setup of the Kobuki Base is indicated if it outputs a sound after it has been started.
Preparation
For time synchronization a PTP master (ptpd) needs to be installed and enabled in the network with
To start the ptpd server you need to know which ethernet_interface you are using. If you do not know your ethernet interface use ip link or ifconfig. Start this server on the turtlebot.
$ ip link
$ sudo apt-get install ptpd
$ sudo ptpd --masteronly --foreground -i <ethernet_interface>
For more information about the time synchronization via PTP refer to the Roboception rc_visard User Manual - PTP.
Export the octomap file location as environment variable. If you followed the previous tutorial, the command looks like this:
$ export TURTLEBOT_MAP_FILE=$(pwd)/map/mapfile.ot
Should your octomap have a different name replace map/mapfile.ot with the path to and the name of your octomap. If you are no longer in the directory where you created the map folder, execute this command:
$ export TURTLEBOT_MAP_FILE=</absolute/path/to/your/map/mapfile.ot>
The demo application launch file rc_visard_turtlebot_tutorial.launch takes the environment variable TURTLEBOT_MAP_FILE as default value for the launch argument mapfile. Alternatively the octomap file can be specified via the mapfile argument when calling roslaunch as well.
Launch the application on the TurtleBot
In case only one rc_visard is connected to the network launch the navigation demo application on the TurtleBot with
$ roslaunch rc_visard_turtlebot_tutorial rc_visard_turtlebot_tutorial.launch
In case the octomap has not been declared via the environment variable TURTLEBOT_MAP_FILE before the argument mapfile has to be set accordingly.
$ roslaunch rc_visard_turtlebot_tutorial rc_visard_turtlebot_tutorial.launch mapfile:=<location-of-the-octomap-file-generated-in-previous-tutorial>
In case the default hostname of the rc_visard (rc_visard) has been changed or several rc_visards are in the network launch the application with the serial number. The argument mapfile needs to be considered like described above if applicable. In case you don't know the serial number of your rc_visard, use rcdiscover:
$ rcdiscover
$ roslaunch rc_visard_turtlebot_tutorial rc_visard_turtlebot_tutorial.launch device:=:<serial_number_of_your_rc_visard>
Start rviz with:
$ rviz -d $(rospack find rc_visard_turtlebot_tutorial)/cfg/navigation_app.rviz
If you are using a SSH-connection use your hostmachine. To connect your hostmachine to the ROS-network on the Turtlebot use this:
$ export ROS_MASTER_URI=http://<ip_address_of_your_turtlebot>:11311
For more information about ROS-variables see this.
Start rviz with the configuration-file provided by this tutorial. If you have it installed on the machine, where you are using rviz:
$ rviz -d $(rospack find rc_visard_turtlebot_tutorial)/cfg/navigation_app.rviz
If you have not installed the tutorial there:
$ rviz -d <path/to/rc_visard_turtlebot_tutorial/cfg/navigation_app.rviz>
RViz should display a map. The TurtleBot should be located and orientated in the map according to its real life location and orientation.
Select a navigation location in RViz
To send a goal in the map click on the "2D Nav Goal" button in the top area of RViz, click on the map where you want the TurtleBot to drive and drag in the direction the TurtleBot should be pointing at the end. The TurtleBot will drive to the selected location and points into the direction dragged.
Teleoperation of the TurtleBot
Alternatively to autonomous navigation one can use teleoperation to navigate the TurtleBot e.g. using a PS3 Joystick like described in the tutorial Teleoperate a Turtlebot with the PS3 Joystick. But use the following command to have L1 instead of the ps3-button as the deadman switch.
$ roslaunch rc_visard_turtlebot_tutorial ps3_teleop.launch