Lab 1: Run in Gazebo and RViz
Due: Monday, January 27
Overview
In this lab, we are going to create a ROS workspace, a ROS package, launch a Turtlebot and play with it. We also investigate the reasons for using coordinate systems in nowadays robotic systems, and introduce the ROS frames and the integrated tf library. Having that, we will demonstrate the existing coordinate systems on our Turtlebot inside the simulated world of Gazebo, we will create a new static transform and will try to spatially georeference each LiDAR measurement with respect to the newly created ROS frame.
ROS Basics
From now on, we assume that you have already installed Ubuntu 20.04 and ROS Noetic.
Please open a new terminal, and create a new ROS workspace by the following commands (run them line by line).
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/catkin_ws/devel/setup.bash
Take a look at catkin_ws directory and see what happens. You can use ls command to see the files in this directory, or use ls -a to see all files including hidden files. Alternatively, you can open File Explorer and navigate to this folder, and use Ctrl + H to see hidden files. The file .catkin_workspace was created to tell the system that this current directory is a ROS workspace.
Note: If you are fresh new to Linux, the instructions might be a bit hard to understand at this moment. No worries. Please just try it for the time being and you will have a better understanding as we move on. You can always ask us any question you want during lab sessions to help you better understand lab materials. (Remember that there is no stupid question; even for those “too simple to ask” questions, We are always happy to answer.)
Next let’s create a new ROS package.
cd ~/catkin_ws/src
catkin_create_pkg ee144w25 std_msgs rospy
Take a look at your new package ee144w25 and see what happens. You should be able to see a package.xml file and a CMakeLists.txt file. Open them and take a quick look. You may use Google to help you build up a high-level understanding.
After creating a new package, we can go back to our workspace and build this package. This is to tell ROS that “Hey, we have a new package here. Please register it into the system.”
cd ~/catkin_ws
catkin_make
Now the system knows this ROS package, so that you can have access to it anywhere. Try navigating to different directories first, and then go back to this ROS package by roscd command. See what happens when running the following commands.
cd
roscd ee144w25
cd ~/catkin_ws
roscd ee144w25
cd ~/Documents
roscd ee144w25
Congratulations! You have completed the basic ROS tutorials. Take some time to think about how the above steps work.
Set up Turtlebot3 in Gazebo
First let’s upgrade existing packages and install some dependencies for Turtlebot.
sudo apt-get update
sudo apt-get upgrade
Clone and install the turtlebot3 ROS packages in our ROS workspace,
cd ~/catkin_ws/src/
git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ../
Gazebo and Turtlebot3 Simulation
In order to spawn the Gazebo inside the simulated world, first we define the type of its model (burger, waffle, waffle_pi), and then we execute the ROS launch script,
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
The turtlebot3 supports teleoperation through geometry_msgs/Twist commands, via the corresponding ROS topic. To use a developed teleoperation script you can execute in a separate terminal,
rosrun turtlebot3_teleop turtlebot3_teleop_key
Note: we will use Turtlebot2 in later labs that involve physical robots. We DO NOT use Turtlebot 3!
Note: If you get this error message /usr/bin/env: ‘python’: No such file or directory, follow these commands.
cd ~/catkin_ws/src/turtlebot3/turtlebot3_teleop/nodes
gedit turtlebot3_teleop_key
# edit line 1 to be #!/usr/bin/env python3
Save and exit.
RViz and TF Visualisation
Initially, we start the Gazebo simulator with the simulated Turtlebot 3 robot. For Turtlebot 3 in rviz, in a separate terminal execute,
roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
ROS Frames and TF Listener
ROS frames are fundamental entities in ROS, as they represent the existing coordinate systems of the robotic setup. Particularly, ROS frames can be assigned on any part of the robot, which can be considered rigid, as well as, on any onboard sensor. Thus, each captured measurement can be spatially described in the corresponding ROS frame of the capturing sensor, while multiple frames can be connected to each other spatially and form the ROS frame tree of the ROS setup.
In rviz, on the upper left select Panels and make sure that Views is checked. The Views panel should show up on the right of the rviz window. For Type, select Orbit (rviz).
For our setup, we set Global Options/Fixed Frame to base_link, as it represents the base coordinate system of the Turtlebot3 robot. Also, we by using the Add button of the bottom left panel of RViz, we add the visualization of the TF.