ECE 5463 Introduction to Robotics
Spring 2018
ROS
TUTORIAL 3
Guillermo Castillo (Wei Zhang)
Department of Electrical and Computer Engineering
Ohio State University
02/2018
ECE5463 (Sp18) Previous Steps
Outline
• Rviz (Ros Visualization)
• Rviz – ROS
• TurtleBot3
• Turtlebot components – laser sensor
• Installing “TurtleBot3” Packages
• Exploring “TurtleBot3” files (launch, world, URDF, XACRO)
• TurtleBot3 simulation
• Running TurtleBot3 simulation (launch files)
• Nodes and topics (current and needed)
• Getting laser data (python script)
• Rviz for laser data visualization
• Goal: Make TurtleBot3 to move around avoiding obstacles 2
ECE5463 (Sp18)
Rviz (Ros Visualization)
• Powerful 3D visualization tool for ROS.
• It allows the user to view the simulated robot model, log sensor information
from the robot's sensors, and replay the logged sensor information.
• If an actual robot is communicating with a workstation that is running rviz, rviz
will display the robot's current configuration on the virtual robot model.
• Command:
rosrun rviz rviz
3
ECE5463 (Sp18) TurtleBot3
TurtleBot3
• Features
• Low-cost, personal robot kit with open-source software and
hardware. Two models available: burger / waffle.
• Modular, compact and customizable.
• World’s most popular ROS platform
• Components (Burger model)
• Single Board Computer (SBC)
• Sensors
• Laser Sensor
• Depth Camera
• Video Camera
• Control Board
• Actuators – Dynamixel Series
4
ECE5463 (Sp18) TurtleBot3
Laser Sensor
360 LASER DISTANCE SENSOR LDS-01 (LIDAR)
• 2D laser scanner that collects a set of data around the robot to use for SLAM
(Simultaneous Localization and Mapping).
• Light source: Semiconductor Laser Diode (λ=785nm)
• Distance Range: 120 ~ 3,500mm
• Angular Range: 360°
• Angular Resolution: 1°
5
ECE5463 (Sp18) TurtleBot3
Installing TurtleBot3 packages
• ROS released packages
sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-
kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-
launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-
arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-
kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl
ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-
kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-
image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-
interactive-markers
• From source code packages
cd ~/catkin_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/catkin_ws && catkin_make
6
ECE5463 (Sp18) TurtleBot3
Exploring TurtleBot3 files
LAUNCH FILES
Directory: ~/catkin_ws/src/turtlebot3_simulations/turtlebot3_gazebo/launch
$ export TURTLEBOT3_MODEL=burger
Command: $ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch 7
ECE5463 (Sp18) TurtleBot3
Exploring TurtleBot3 files
WORLD FILES
Directory: ~/catkin_ws/src/turtlebot3_simulations/turtlebot3_gazebo/models
File: turtlebot3_world.launch
8
ECE5463 (Sp18) TurtleBot3
Exploring TurtleBot3 files
URDF FILES
Directory: ~/catkin_ws/src/turtlebot3/turtlebot3_description/urdf
File: turtlebot3_burger.urdf.xacro
9
ECE5463 (Sp18) TurtleBot3 Simulation
Running TurtleBot3 Simulation
• Moving TurtleBot3 using teleop_key.
$ export TURTLEBOT3_MODEL=burger
$ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
In a separate terminal´s window:
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
• Moving TurtleBot3 using publisher node
• Create your own package (Recall: New packages must be created in
the src folder from catkin_ws).
• Create your own Python script for moving TurtleBot3 (Recall: Give
execution permissions to the file using: chmod +x name_of_the_file.py)
• Use commands rosnode list, rostopic list, rostopic info, rosmsg show.
10
ECE5463 (Sp18) TurtleBot3 Simulation
Python Script for moving TurtleBot3
• Package created: move_turtlebot3
• Python file created: trajectory.py
• You can use as a template the code used for your PA1. (Recall: Give execution
permissions to the file using: chmod +x name_of_the_file.py).
• Run the file using rosrun or roslaunch commands.
11
ECE5463 (Sp18) TurtleBot3 Simulation
Laser sensor application
• Autonomous Navigation Demostration.
$ export TURTLEBOT3_MODEL=burger
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
In a separate terminal´s window
$ export TURTLEBOT3_MODEL=burger
$ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
• Visualizing sensor data using Rviz
$ export TURTLEBOT3_MODEL=burger
$ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
• Laser sensor data is shown as red dots in the Rviz (each dot corresponds
to a laser beam).
12
ECE5463 (Sp18) TurtleBot3 Simulation
Getting laser data using ROS
commands and Python script
• Laser data is published on the topic scan. Therefore, to access this data
we have to subscribe to this topic, obtain the required data and use it for
our desired application.
• Obtain information about the topic (in a separate window):
$ rostopic list
$ rostopic info scan
$ rosmsg show LaserScan
$ rostopic echo scan
• Information of interest of laser scan:
float32 range_min: 0.1199 float32 angle_min: 0.0
float32 range_max: 3.5 float32 angle_max: 6.28000020981
float32[] ranges: [1.3471, 1.3377, ….. , 1.3471, 1.3377 ] – 360 elements
float32[] intensities: [4.05e-08, 4.54+30, …. , 4.54e+30, 4.05e-08] – 360 elements ***
13
ECE5463 (Sp18) TurtleBot3 Simulation
Getting laser data using ROS
commands and Python script
• Create a new node to subscribe to the topic scan and get the information
from the laser sensor.
gedit laser_data.py
14
ECE5463 (Sp18) TurtleBot3 Simulation
Turtlebot3 - Obstacle avoidance
• Now it’s time to put everything together: Subscriber, Publisher,
Messages. You will need to use all of this concepts in order to succeed!
• Goal: Make robot avoid obstacles in front of him.
• Baby step: Make the robot to stop when an obstacle in front of the robot
is closer than 0.5 m.
• Hints:
• Create a node which is a publisher and subscriber at the same time.
• The node should subscribe to the topic scan and publish on the topic cmd_vel
• Use the code implemented in the previous scripts and put everything together.
• Use conditionals to make the robot behave as you want.
15
ECE5463 (Sp18) TurtleBot3 Simulation
Turtlebot3 - Obstacle avoidance
• Create node:
$ gedit avoid_obstacle.py
$ chmod +x avoid_obstacle.py
16
ECE5463 (Sp18)
Thanks for your
attention
17