Page tree
Skip to end of metadata
Go to start of metadata


References and Prerequisites

ROS: We will be using a number of new ROS packages to implement, mapping, navigation and path-planning.  Below are the main references for those capabilities.  You are not expected to work though these tutorials, but a quick review of the documentation for each package will help you understand how things are connected.

MATLAB: The move_base package provides an ROS action interface (similar to a ROS service) for providing goals to the robot which are executed by the system.  The move_base Action API will act as a server and MATLAB will act as the client

Git Repository / ROS Package

Your submission for this assignment will be a Git repository that contains a ROS package.  The name of the repository on the server should be mrc_hw6 and it should be a ROS package (catkin_create_pkg).

Update ROS Software

  1. Use git to update to the most recent code for out custom NPS turtlebot ROS package.  (The turtlebot3_nps repository is on github.)

    cd ~/catkin_ws/src/turtlebot3_nps
    git pull origin master

Exercise 1: Achieving Goals via MATLAB

In the previous assignment we used the RVIZ interface to interact with the navigation and path planning parts of the system. In particular we used the "2D Pose Estimate" and "2D Nav Goal" buttons to interact with the AMCL localization and the move_base path planning/

In this exercise we will develop MATLAB functions to be able to interact with the system in a more deliberate way.

MATLAB Functions

Develop the following MATLAB functions - each of which should be in your repository in a folder named matlab

  1. set_initialpose.m
    1. This function should have three input arguments - x, y and yaw - to define the initial pose of the TurtleBot. 
    2. It should publish a ROS message to the amcl node to (re-)initialize the robot's localization at the pose given by x, y and yaw.  The position (x and y) should be in meters and the yaw angle should be in degrees.
      This takes the place of the RVIZ "2D Pose Estimate" GUI interface.
    3. Getting the syntax of the ROS message can be a little tricky.  This example illustrate one way to explore the ROS message structure:
    4. The pose message includes a covariance to quantify the uncertainty in the provided estimate of vehicle state.  This 6,6 matrix is included as a 36 element array.  The values of the array should be: [0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06853891945200942]
  2. turtlebot_goals.m
    1. This script should use the MATLAB ROS action client functionality (ROS Actions Overview) to send goals to the move_base system for the TurtleBot to explore the areas A, B and C - returning to the origin.
    2. The Move a Turtlebot Robot Using ROS Actions example from the Mathworks gives you a basic idea of how this can be done.  The example is written for a different action interface - where the goal is a relative movement (distance and turn) rather than a new waypoint - however, the mechanics should give you a good example for addressing this challenge.  Also note that this example only uses the most basic functionality of the action interface.  It doesn't make use of the status feedback or cancellation functionality of ROS actions.
    3. An example of interacting with the move_base action server is supplied at

Setting Goals Programmatically

Now repeat Exercise 2 using your new MATLAB functionality in place of the RVIZ GUI interface.  You should be able to use MATLAB to initialize the pose of the TurtleBot and then send sequential goal poses to the move_base node to have the robot explore the areas A, B and C, returning to the origin.

  1. Once you have a working system, do a trial while logging data to a ROS bag file, visiting each of the regions. 
  2. Post-process the bag file to generate the a figure to summarize the mission.  As you did in the previous assignment, this figure should include
    1. The map image as a background
    2. A graph of the odometry x/y path from the Odometry messages on the /odom topic (type: nav_msgs/Odometry Message
    3. A graph of the acml x/y path from the Post messages on the the /acml_pose topic. (type: geometry_msgs/PoseWithCovarianceStamped )
    4. The goal pose messages from the /move_base/goal topic (type: move_base_msgs/MoveBaseGoal )
  3. Save the figure as images/matlab_goals.png


  • You may find that your costmap gets cluttered after awhile of use - due to people moving around in the space or other robots.  The move_base node has a service to allow you to clear the costmaps

    rosservice call /move_base/clear_costmaps
  • We also discovered that creating and destroying the ROS publisher with the set_initialpose function can be problematic.  In particular, it appears that if the the publisher object is destroyed, by exiting the function, before the ROS message is actually sent, it can cause intermittent problem.  One fix for this is to have the function return the publisher so that it is not destroyed, e.g.,

    function mypub = set_initialpose(x,y,yaw)
    mypub = rospublisher(TOPIC,MSGTYPE);

Exercise 2: Multiple TurtleBot Teleop

For this exercise you will use the namespace concept to operate two TurtleBot3 robots. 

Setup Two Independent Turtlebots

You will need to have two robots setup to use the same ROS master (on your laptop).  This will require that you set the appropriate environmental variables to configure the ROS network.

Verify that you can teleoperate (joystick) two robots independently - that is, make sure you can operate one robot and then the other using the instructions from previous assignments.

Setup Two Simultaneous TurtleBots with Teleoperation

To simultaneously operate two turtlebots we need to specify a unique namespace and tf_prefix so that the systems (messages, services, coordinate transforms, etc.) are independent of each other. We will use "tb3_0" for one robot and "tb3_1" for the other.  This label will be used for both the namespace (nodes, topics, etc.) and the tf_prefix (tf coordinate frames.)

(We are following the general instructions from the Turtebot3 e-Manual.)

  1. Laptop: Start the ROS master.

  2. Turtlebot0.  Place the robot at the origin of our map-based coordinate frame.  Launch the robot nodes with the "tb3_0" namespace and tf_prefix.

    ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_0" set_lidar_frame_id:="tb3_0/base_scan"
  3. Turtlebot1.  Place the robot at a position of roughly (1.0, 0.0) in the map-based coordinate frame with 0 radian yaw.  Launch the robot nodes with the "tb3_1" namespace and tf_prefix.

    ROS_NAMESPACE=tb3_1 roslaunch turtlebot3_bringup turtlebot3_robot.launch multi_robot_name:="tb3_1" set_lidar_frame_id:="tb3_1/base_scan"
  4. Laptop
    1.  Start the transform publisher for Turtlebot0

      ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_remote.launch multi_robot_name:=tb3_0
    2. Start the transform publisher for Turtlebot1

      $ ROS_NAMESPACE=tb3_1 roslaunch turtlebot3_bringup turtlebot3_remote.launch multi_robot_name:=tb3_1
    3. We will use the teleop_multi.launch  file from the turtlebot3_nps ROS package.  Take a look at the launch file and note the use of the <group> tags to run the same nodes in two different name spaces.  This will come in handy later in the assignment.
    4. Connect two USB gamepads run the following launch file to generate the ROS nodes for teleoperation.

      roslaunch turtlebot3_nps teleop_multi.launch 
    5. Use rqt_graph to create an image of the ROS graph and save it to your assignment as images/rosgraph_two.png
      Note the way the tb3_0 and tb3_1 namespaces are shown in the graph.
    6. Use rqt_tf_tree to create the transform tree and save the image to your assignment repository as images/frames_two.png
      Note the way the tb3_0 and tb3_1 tf_prefixes are shown in the tree.
    7. Once things are working, start a ROS bag log file, recording all of the ROS message data.  It is not recommended to put this file in your Git repository.
    8. With two operators, drive the robots around the lab.  Use Turtlebot1 (the one starting at (1,0,0)) as the leader and have Turtlebot0 attempt to follow.  Drive a significant distance so that the log file contains a discernible pattern.
  5. Once you are done driving the robots, you can stop the log file and shutdown the ROS system.


Using MATLAB to read the bag file, generate a plot to illustrate the experiment.  The figure should contain...

  1. The map image from the previous assignment as a background.
  2. The Odometry path of Turtlebot0
  3. The Odometry path of Turtlebot1, with an offset of x=1.0 and y=0 to reflect the known initial position of the robot

Save the figure as an image within your assignment repository as images/teleop_odom_two.png

Exercise 3: Two Robot AMCL Localization

In the previous exercise the only source of localization is the odometry frame - which is purely relative.  Furthermore, the odometry frames for tb3_0 is independent of the odometry frame for tb3_1.   In this exercise we will use the AMCL package to localize each robot relative to the occupancy grid map we generated in the previous assignment.  To accomplish this you will need to do the following.

In the previous assignment we used the turtlebot3_navigation.launch file in the turtlebot3_navigation ROS package.  Take a look at this file to understand what nodes where being started and how they were configured.

Within the turtlebot3_navigation.launch the amcl.launch file in the turtlebot3_navigation ROS package was used to setup the AMCL node and configure the pertinent parameters.

For this exercise you will create two new launch files.  Each launch file will (1) start the map_server node and use the occupancy grid map from the previous assignment and (2) start the amcl node.

  1. Create a launch file in your assignment repository launch/amcl_tb0.launch for the Turtlebot0 with an initial starting position of 0,0,0
    The nodes should be within a "tb3_0" namespace and all frames should use the "tb3_0" tf_prefix.
  2. Create a launch file in your assignment repository launch/amcl_tb1.launch for the Turtlebot1 with an initial starting position of 1,0,0
    The nodes should be within a "tb3_1" namespace and all frames should use the "tb3_1" tf_prefix.

When completed your rosgraph should look something like this...

Save the graph as images/rosgraph_amcl_two.png 

and your tf tree should look something like this...

Save the tree as images/frames_amcl_two.png 

To help with debugging, an RVIZ configuration is provided in the turtlebot3_nps ROS package. 

roslaunch turtlebot3_nps rviz_two.launch

You should be able to...

  1. Bringup the system as you did in Exercise 2
  2. Start launch the map_server and amcl nodes using your two new launch files
  3. Start RVIZ with the configuration above and see something like this...


When you have completed the exercises, your mrc_hw6 repository should look something like...

  • No labels