You are on page 1of 57

BASIC ROS FOR

ROBOTICS
(SESSION-1)
MUHAMMAD ABDUL JALIL
Session Outline

ROS INTRODUCTION SETTING UP ROS FAMILIARIZATION


ENVIRONMENT ROS COMMAND
PART 1 –
INTRODUCTION TO ROS
PART 1 – INTRODUCTION TO ROS
What is ROS?
Why ROS?
How ROS work?
Is ROS for me?

www.ros.org
PART 1 – INTRODUCTION TO ROS
What is ROS?
Robot Operating System (ROS) is a framework for writing robot software.
It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex
and robust robot behavior across a wide variety of robotic platforms.
Also known as Meta-operating System
Meta-operating system that runs on the existing operating system (i.e windows, Linux, macOS)
PART 1 – INTRODUCTION TO ROS
What is ROS?
ROS Components
PART 1 – INTRODUCTION TO ROS
What is ROS?
ROS Terminology
Nodes
Topics and Messages
Services
Actions
ROS Master
Parameters
Packages, stacks, repository
Launch files
PART 1 – INTRODUCTION TO ROS
Nodes
Single-purposed executable programs
e.g. sensor driver(s), actuator driver(s), mapper, planner, UI, etc.
Individually compiled, executed, and managed
Nodes are written using a ROS client library
roscpp – C++ client library
rospy – python client library
Nodes can publish or subscribe to a Topic
Nodes can also provide or use a Service
PART 1 – INTRODUCTION TO ROS
Topic
A topic is a name for a stream of messages with a defined type
•e.g., data from a laser range-finder might be sent on a topic called scan, with a
message type of LaserScan
Nodes communicate with each other by publishing messages to topics
Publish/Subscribe model: 1-to-N broadcasting
PART 1 – INTRODUCTION TO ROS
Message
Strictly-typed data structures for inter-node communication
For example, geometry_msgs/Twist is used to express velocity commands:
PART 1 – INTRODUCTION TO ROS
Services
Synchronous inter-node transactions / RPC
Service/Client model: 1-to-1 request-response
Service roles:
carry out remote computation
trigger functionality / behavior
Example:
map_server/static_map – retrieves the current grid map used by the robot for
navigation
PART 1 – INTRODUCTION TO ROS
Services
PART 1 – INTRODUCTION TO ROS
Action
Communication on action is used when a
requested goal takes a long time to be
completed, therefore progress feedback is
necessary.
PART 1 – INTRODUCTION TO ROS
ROS Master
Provides connection information to nodes so that they can transmit messages to each
other
Every node connects to a master at startup to register details of the message streams
they publish, and the streams to which that they to subscribe
When a new node appears, the master provides it with the information that it needs to
form a direct peer-to-peer connection with other nodes publishing and subscribing to
the same message topics
PART 1 – INTRODUCTION TO ROS
ROS Master
PART 1 – INTRODUCTION TO ROS
ROS Master
PART 1 – INTRODUCTION TO ROS
ROS Master
PART 1 – INTRODUCTION TO ROS
Why ROS?
A Distributed, Modular Design
Package management
API
A Vibrant Community
Permissive Licensing
A Collaborative Environment
PART 1 – INTRODUCTION TO ROS
How ROS work?
ROS Topology

ROS Ma ste r

Re g istra tion Re g istra tion


Re g istra tion

ROS No d e 1 Ma ssa g e s ROS No d e 2 Ma ssa g e s ROS No d e n

Ma ssa g e s

Sin g le C o m p u te r
PART 1 – INTRODUCTION TO ROS
How ROS work?
ROS Topology

ROS Ma ste r

Re g istra tion Re g istra tion


Re g istra tion

ROS No d e 1 Ma ssa g e s ROS No d e 2 Ma ssa g e s ROS No d e n

Ro b o t C o m p u t e r C o m p u t e r / La p t o p
PART 1 – INTRODUCTION TO ROS
How ROS work?
ROS Topology

ROS Ma ste r

Re g istra tion Re g istra tion


Re g istra tion

ROS No d e 1 Ma ssa g e s ROS No d e 2 Ma ssa g e s ROS No d e n

Ma ssa g e s

Ro b o t C o m p u te r C o m p u te r
PART 1 – INTRODUCTION TO ROS
How ROS work?
ROS Topology

ROS Ma ste r

Re g istra tion Re g istra tion


Re g istra tion

ROS No d e 1 Ma ssa g e s ROS No d e 2 Ma ssa g e s ROS No d e n

Ma ssa g e s

Ro b o t C o m p u te r
PART 1 – CONCLUSION
Ironman.py
“Tony stark”

captain.py
“Steve hulk.py
Rogers” “Bruce
Banner”
Ironman.py
a n” “Tony stark”
“sc

c a n”
“s

captain.py
“Steve hulk.py
Rogers” “Bruce
Banner”
Ironman.py
“Tony stark”

“sm
ash

captain.py
“Steve “sm
ash hulk.py
Rogers” ” “Bruce
Banner”
Ironman.py
“Tony stark”

captain.py
“Steve hulk.py
Rogers” “Bruce
Banner”
Ironman.py ROS node
“Tony stark”

captain.py
“Steve hulk.py
Rogers” “Bruce
Banner”
Operating System

ROS master
ROS
PART 2 – SETTING UP
ROS ENVIRONMENT
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Ubuntu Installation
◦ Standalone / primary OS on laptop / PC
◦ Dual boot with Windows or MAC OS
RO S
In st a lla tio n
◦ Using Virtual Machine (Virtualbox, etc)

RO S
Enviro n m e nt
Se tup Dislike ubuntu??? Don’t worry… there are plenty of OS instead of UBUNTU that can
be used…..
RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Ubuntu Installation Guides:
◦ Standalone / primary OS on laptop / PC
https://ubuntu.com/tutorials/install-ubuntu-desktop#1-overview
RO S
In st a lla tio n

◦ Along with Windows


RO S https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/
Enviro n m e nt
Se tup

◦ Using Virtual Machine


RO S Su p p o rt
So ftw a re
https://brb.nci.nih.gov/seqtools/installUbuntu.html
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n
◦ Ubuntu Installation File
◦ Ubuntu ISO file
RO S
https://releases.ubuntu.com/16.04.7/?_ga=2.48268197.222170929.1598819050-832983989.1579873761
In st a lla tio n

◦ Virtual Machine File:


RO S
Enviro n m e nt
https://s3.amazonaws.com/CPR_PUBLIC/LEARN_ROS/ROS_Edu.zip
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Checking your OS-ROS distro

RO S
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
http://wiki.ros.org/Distributions
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Installation steps
http://wiki.ros.org/kinetic/Installation

RO S
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ ROS environment setup
◦ Added ROS environment variables automatically to ‘bash’ file
~$echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
RO S
In st a lla tio n
~$source ~/.bashrc

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Other software that can be use
◦ Terminator
https://blog.arturofm.com/install-terminator-terminal-emulator-in-ubuntu/
RO S
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Other software that can be use
◦ ATOM
https://tipsonubuntu.com/2016/08/05/install-atom-text-editor-ubuntu-16-04/
RO S
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Other software that can be use
◦ Cloud storage
https://itsfoss.com/cloud-services-linux/
RO S
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Creating ROS working Space
◦ Folder where you modify, build, and install ROS packages.
RO S
◦ Use catkin version instead of rosbuild
In st a lla tio n

RO S
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 2 – Setting up ROS
OS Insta lla tio n ◦ Creating ROS working Space
◦ Several ways to create working space
RO S
◦ from terminal:
In st a lla tio n

$mkdir –p ~/name_of_working_space/src
$cd ~/name_of_working_space/
RO S
$catkin_make
Enviro n m e nt
Se tup

RO S Su p p o rt
So ftw a re
In st a lla tio n

C re a ting ROS
Wo rking
Sp a c e
PART 3 – ROS
COMMAND
ROS She ll PART 3 – ROS COMMAND
 Command in shell environment is to perform ROS task
ROS Exe c utio n
 Task such as file system, editing, building, debugging source codes, package
management, etc.

ROS Info rm a tio n


 Generally there is 5 categories of ROS command

ROS Ca tkin

ROS Pa c ka g e

https://w3.cs.jmu.edu/spragunr/CS354_S19/handouts/ROSCheatsheet.pdf
ROS She ll PART 3 – ROS SHELL
 Also called ‘rosbash’
ROS Exe c utio n
 Allow to used the bash shell command commonly used in Linux for ROS
environment.

ROS Info rm a tio n


 ‘ros’ prefixes are used along with Linux command such as ‘cd, pd, d, ls, cp, run’

Command Description

ROS Ca tkin
roscd Move to the directory of the designated ROS package
rosls Check file list of ROS package
rosed Edit file of ROS package
ROS Pa c ka g e roscp Copy file of ROS package
rospd Add directory to the ROS directory index
rosd Check the ROS directory index
ROS She ll PART 3 – ROS EXCUTION
 Control the execution of ROS nodes
ROS Exe c utio n

Command Description
roscore Run ROS master + rosout (record log) + parameter server
ROS Info rm a tio n
rosrun Run specific ROS node
roslaunch Run ROS master + Launch multiple nodes and configuration
rosclean Delete ROS log file
ROS Ca tkin

ROS Pa c ka g e
ROS She ll PART 3 – ROS EXCUTION (ROSCORE)
 roscore is a collection of nodes and programs that are pre-requisites of a ROS-based
ROS Exe c utio n system.
 roscore will start up:
 a ROS Master
ROS Info rm a tio n  a ROS Parameter Server
 a rosout logging node
 Syntax:
ROS Ca tkin

$ roscore

ROS Pa c ka g e
ROS She ll PART 3 – ROS EXCUTION (ROSRUN)
 rosrun allow user to run executable script / file.
ROS Exe c utio n  Required ‘roscore’ to be executable first
 Syntax:
$ rosrun <package> <executable file/script
ROS Info rm a tio n

 Example:
ROS Ca tkin $ rosrun turtlesim turtlesim_node

ROS Pa c ka g e
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

ROS She ll PART 3 – ROS EXCUTION (ROSLAUNCH)


 ‘roslaunch’ allow user to run multiple ‘rosnode’ and setting.
ROS Exe c utio n  Doesn’t need ‘roscore’ to be executable first
 If ‘roscore’doesn’t ‘run’ system will run it first
 Syntax:
ROS Info rm a tio n

$ roslaunch <package> <file.launch>

ROS Ca tkin
 Example:
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

ROS Pa c ka g e
ROS She ll PART 3 – ROS Information
 Check information regarding topics, services, nodes, parameter, etc.
ROS Exe c utio n

Command Description
rostopic Check ROS topic information
ROS Info rm a tio n
rosservice Check ROS service information
rosnode Check ROS node information
rosparam Check and edit ROS parameter information
ROS Ca tkin

rosbag Record and play ROS message


rosmsg Check ROS message service

ROS Pa c ka g e rossrv Check ROS service information


rosversion Check ROS package and release version information
roswtf Examine ROS system
ROS She ll PART 3 – ROS Information (ROSTOPIC)
 The ‘rostopic’ displays information about ROS topics.
ROS Exe c utio n
 It can display a list of active topics, the publishers and subscribers of a specific
topic, the publishing rate of a topic, the bandwidth of a topic, and messages
published to a topic.
ROS Info rm a tio n
 The display of messages is configurable to output in a plotting-friendly format.

ROS Ca tkin

ROS Pa c ka g e
ROS She ll PART 3 – ROS Information (ROSTOPIC)
 Let’s do:
ROS Exe c utio n
 Open terminal
$ roscore

ROS Info rm a tio n


 Open new terminal
$ rostopic list
 Open new terminal
ROS Ca tkin

$ rosrun turtlesim turtlesim_node


 Run again ‘rostopic list’command
ROS Pa c ka g e
ROS She ll PART 3 – ROS Information (ROSNODE)
 ‘rosnode’ is a command-line tool for displaying debug information about ROS
ROS Exe c utio n Nodes, including publications, subscriptions and connections.

ROS Info rm a tio n

ROS Ca tkin

ROS Pa c ka g e
ROS She ll PART 3 – ROS Information (ROSNODE)
 Example of usage:
ROS Exe c utio n
 Open terminal
$ roscore

ROS Info rm a tio n  Open new terminal


$ rosnode list

ROS Ca tkin
 Open new terminal
$ rosrun turtlesim turtlesim_node

 Run again ‘rostopic list’command


ROS Pa c ka g e

 Do it in other way……
ROS She ll PART 3 – ROS Information (ROSNODE)
 Example of usage:
ROS Exe c utio n
 Open terminal
$ roscore

ROS Info rm a tio n  Open new terminal


$ rosrun rqt_graph rqt_graph

ROS Ca tkin
 Open new terminal
$ rosrun turtlesim turtlesim_node

 Refresh rqt_graph
ROS Pa c ka g e

 Do it in other way……
ROS She ll PART 3 – ROS CATKIN
 Used when building a package using the catkin build system.
ROS Exe c utio n

Command Description

ROS Info rm a tio n


catkin_create_pkg Automatic creation of package
catkin_make Build based on catkin build system
catkin_eclipse Modify package created by catkin build system so that it can be used in
Eclipse
ROS Ca tkin
catkin_prepare_release Cleanup log and tag version during release
catkin_generate_changelog Create or update ‘CHANGELOG.srt’ file during release
catkin_init_workspace Initialize workspace of the catkin build system
ROS Pa c ka g e
catkin_find Search catkin
ROS She ll PART 3 – ROS CATKIN (catkin_create_pkg)
 Creating ros package
ROS Exe c utio n

catkin_create_pkg [PACKAGE_NAME] [DEPENDENCY_PACKAGE1] …….

 ‘catkin_create_pkg’ is a command that creates and empty package containing


ROS Info rm a tio n
‘CMakeLists.txt’ and ‘package.xml’

ROS Ca tkin

ROS Pa c ka g e
ROS She ll PART 3 – ROS CATKIN (catkin_make)
 ‘catkin_make’ is a command to build a package created by user or a downloaded
ROS Exe c utio n package

$ cd ~/working_space
ROS Info rm a tio n $ catkin_make

ROS Ca tkin

ROS Pa c ka g e
ROS She ll PART 3 – ROS PACKAGE
 Used to manage ROS packages
ROS Exe c utio n
Command Description
rospack View information regarding a specific ROS package
rosinstall Install additional ROS packages
ROS Info rm a tio n
rosdep Install dependency package of the ROS corresponding package
roslocate Show information of ROS package
roscreate-pkg Automatic creation of ROS package (similar with ‘catkin_create_pkg’ but for
ROS Ca tkin
‘rosbuild’ system
rosmake Build ros package (similar with ‘catkin_make’)

ROS Pa c ka g e
ROS She ll PART 3 – PLAY AROUND WITH ROS
 Run ‘roscore’
ROS Exe c utio n
 Run ‘rqt_graph’
 Run turtlesim node
ROS Info rm a tio n
 Run turtlesim teleop node

ROS Ca tkin

ROS Pa c ka g e

You might also like