0% found this document useful (0 votes)
58 views49 pages

Robot Operating System Tuesday, December 5, 2017 Bahria University Islamabad Ammar Ajmal & Tahir Mehmood

ROS is a meta-operating system for robots that provides hardware abstraction, device drivers, libraries, visualizers, message-passing capabilities, and more. It uses a distributed component architecture that allows processes to be distributed across multiple machines. ROS is very popular in robotics research and has an active open-source community.

Uploaded by

Fahad Ibrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views49 pages

Robot Operating System Tuesday, December 5, 2017 Bahria University Islamabad Ammar Ajmal & Tahir Mehmood

ROS is a meta-operating system for robots that provides hardware abstraction, device drivers, libraries, visualizers, message-passing capabilities, and more. It uses a distributed component architecture that allows processes to be distributed across multiple machines. ROS is very popular in robotics research and has an active open-source community.

Uploaded by

Fahad Ibrar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Robot Operating System

Tuesday, December 5, 2017


Bahria University Islamabad
Ammar Ajmal & Tahir Mehmood
Introduction to ROS
A meta-operating system for robots
Bridging the gap from
simple to complex robotics
What is ROS?
• A “Meta” Operating System.
• Open source
• Runs in Linux (esp. Ubuntu)
• Ongoing Windows implementation
• Agent based (nodes)
• Message passing
• Publish
• Subscribe
• Services via remote invocation
• Supports numerous programming languages (C++, Python, Lisp, Java)
What is ROS?
• Low level device abstraction Application
• Joystick building
• GPS blocks
• Camera
• Controllers ROS
• Laser Scanners
• …
System
• Application building blocks software
• Coordinate system transforms
• Visualization tools
• Debugging tools
• Robust navigation stack (SLAM with loop closure)
• Arm path planning
• Object recognition
• ...
What is ROS?
• Software management (compiling, packaging)
• Remote communication and control
What is ROS?
• Founded by Willow Garage
• Exponential adoption
• Countless commercial, hobby, and academic robots use ROS
(http://wiki.ros.org/Robots)
What is ROS?
• Software basis of Willow Labs’s PR2
ROS Philosophical goals
• “Hardware agnosticism”
• Peer to peer
• Tools based software design
• Multiple language support (C++/Java/Python)
• Lightweight: runs only at the edge of your modules
• Free
• Open source
• Suitable for large scale research and industry
ROS software development
Conceptual levels of design
(A) ROS Community: ROS Distributions, Repositories

Carnegie Mellon

Node 4 Node 5 (B) Computation Graph: Peer-to-Peer Network of


ROS nodes (processes).
Node 1 Node 2:
Laser Scanning Map Building

Node 3:
Planning
Node7
Node 6

(C) File-system level: ROS Tools for managing source code,


build instructions, and message definitions. 14
Tools-based software design
Tools for:

• Building ROS nodes


• Running ROS nodes
• Viewing network topology
• Monitoring network traffic

Many cooperating processes, instead of a single monolithic program.


Multiple language support
• ROS is implemented
natively in each C++ Node : Python Node:
Map Building Laser Scanner
language.
• Quickly define
messages in language-
independent format. Topic:
“LaserData”
File-system level
File: PointCloud.msg
Header header
Points32[] pointsXYZ
int32 numPoints
Lightweight
• Encourages standalone libraries with no ROS dependencies:
Don’t put ROS dependencies in the core of your algorithm!

• Use ROS only at the edges of your interconnected software modules: Downstream/Upstream
interface

• ROS re-uses code from a variety of projects:


ROS Community
• OpenCV : Computer Vision Library

• Point Cloud Library (PCL) : 3D Data Processing

• OpenRAVE : Motion Planning Carnegie


Mellon
Peer to Peer Messaging

• No Central Server through which all messages are routed.


• “Master” service run on 1 machine for name registration +
lookup
• Messaging Types:
• Topics : Asynchronous data streaming
• Parameter Server Computation Graph
Peer to Peer Messaging

• Master: Lookup information, think DNS


roscore command  starts master, parameter server, logging
• Publish: Will not block until receipt, messages get queued.
• Delivery Guarantees: Specify a queue size for publishers: If publishing too
quickly, will buffer a maximum of X messages before throwing away old
ones
Computation Graph
• Transport Mechanism: TCPROS, uses TCP/IP
• Bandwidth: Consider where your data’s going, and how
Free & Open Source
• BSD License : Can develop commercial applications
• Drivers (Kinect and others)
• Perception, Planning, Control libraries
• MIT ROS Packages : Kinect Demos, etc
• Interfaces to other libraries: OpenCV, etc
Some Basic Commands
• Ls (lists all directories and files in current folder)
• Cd (change directory to a path specified)
• Mkdir (makes a folder in the current directory)
• Cd (will go back to home directory)
• Cd .. (one folder back)
Master
• Roscore
• It starts
• a ROS master
• a ROS Para meter Server
• a rosout logging node
• All nodes communicate with master
• If you use roslaunch it will automatically run roscore if the instance is
not running
Parameter Server
• Shared multivariable dictionary
• Accessible via a network
• Nodes uses this to save and retrieve data at runtime
• Data types stored in Parameter Server are
• 32 bit Integers
• Boolean
• String
• Doubles
• ISO 8601 dates
• Lists
• Base 64 encoded binary data
Parameter Server Cont.
• Rosparam is a tool to view and analyze Parameter Server
• Rosparam list
• Rosparam info
• Rosparam set, get
• Rosparam delete
• Rosparam dump
• Rosparam load
/rosout
• Logging node
• Log Messages
• Similar to STD::cout
• For console output
• Rqt_console for visualization
A Simple Program
• Starting turtlesim In three separate terminals, execute these three
commands:
• Roscore
• rosrun turtlesim turtlesim_node
• rosrun turtlesim turtle_teleop_key
• Rospack list (Packages installed)
• Rospack find pkg_name
ROS Nodes
• A running instance of a ROS program is called a node
• Running instance is most important. We can not run different copies of same node Why!
• How to start a node……..
• Nodes are loosely coupled
• Rosrun pkg_name executable_name
• Some useful commands
• Ronode list
• Rosnode info
• Rosnode kill
• rosrun package_name executable_name __name:=node_name
ROS Messages
• Data published by ROS nodes is called a Message
• A lot of Standard message types i.e. string, int, bool etc
• Message desprictions are stored in
my_package/msg/MyMessageType.msg
• 2 parts of .msg file
a. Field
This is the Data that is sent inside a message
b. Constant
Constatns define useful values that are used to interpret those fields
ROSMSG cont.
• Message types uses package resource names like
geometry_msgs/msg/twist.msg is commonly referred to as
geometry_msgs/Twist
• Rosmsg show (-r for raw message definition) (-b for a bag file)
• Rosmsg list
• rostopic type /topic_name | rosmsg show (this will show type
information about a topic )
• Rosmsg package (All messages in a package) (-s for single line display)
ROS Topics
• Each ROS message is published under a subject called Topic
• A Node publishes messages depending upon a topic and another node subscribe to this
topic
• If multiple nodes are publishing on a single topic than a node who needs info on that
specific topic to this single topic will subscribe to all these nodes WHY!
• rostopic list
• rostpoic info
• Rostopic echo
• Rostpoic bw, hz
• rostopic pub -r rate-in-hz topic-name message-type message-content
rostopic pub -r 1 /turtle1/cmd_vel geometry_msgs/Twist ’[0, 0, 0]’ ’[0, 0, 1]’
Same Topic Multiple Nodes
• In three separate terminals type these four commands
• rosrun turtlesim turtlesim_node __name:=A
• rosrun turtlesim turtlesim_node __name:=B
• rosrun turtlesim turtle_teleop_key __name:=C
• rosrun turtlesim turtle_teleop_key __name:=D
Creating Packages in ROS
• Workspace
• Ros build
• Catkin
• mkdir -p caktin_ws/src
• cd caktin_ws/src/
• catkin_init_workspace
• catkin_create_pkg package_name
• It will two files
• Package.xml
• Cmake.txt
A minimal Example

• Hello World Program ! (.cpp file)


• Editing Manifest (Package.xml)
• Declaring an Executable (Cmake.txt)
.CPP File

// This is a ROS version of the standard " hello , world"


2 // program .
34
// This header defines the standard ROS c l a s s e s .
5 #include <ros / ros . h>
67
int main( int argc , char ∗∗ argv ) {
8 // I n i t i a l i z e the ROS system .
9 ros : : i n i t ( argc , argv , " hello_ros ") ;
10
11 // Establish t h i s program as a ROS node .
12 ros : : NodeHandle nh ;
13
14 // Send some output as a log message .
15 ROS_INFO_STREAM("Hello , ␣ROS! ") ;
16 }
Package.xml
<?xml version ="1.0"?>
<package>
<name>Package name </name>
<version >0.0.1</ version>
<description >
Examples
</description >
<maintainer email=“[email protected]">
Name
</maintainer>
<license >TODO</license >
<buildtool_depend>catkin </buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<run_depend>geometry_msgs</run_depend>
<build_depend>turtlesim </build_depend>
<run_depend>turtlesim </run_depend>
</package>
Cmake.txt
• To list dependencies, edit the CMakeLists.txt in your package
directory. The default version of this file has this line:
find_package(catkin REQUIRED)
Dependencies on other catkin packages can be added in a
COMPONENTS section on this line:
find_package(catkin REQUIRED COMPONENTS package-names)
find_package(catkin REQUIRED COMPONENTS roscpp)
We should also list dependencies in the package manifest
(package.xml), using the build_depend and run_depend elements:
<build_depend>package-name</build_depend>
<run_depend>package-name</run_depend>
<build_depend>roscpp</build_depend>
<run_depend>roscpp</run_depend>
• Catkin_make
ROS Debugging
• Shutdown “Object” node  re-compile  restart : won’t disturb system

• Logging (VIDEO)

Kinect Driver Laser Scanner


Object
Recognition

Logger

• Playback (VIDEO)

Object
Logger Playback
Recognition 39
Useful ROS Debugging Tools
• Rqt_graph : This will show a graph showing all of the nodes with
their subscriptions and publications
• Rqt_plot : Plot data from one or more ROS topic fields using
matplotlib.
rqt_plot /turtle1/pose/x,/turtle1/pose/y  graph data from 2 topics in 1
plot
Useful ROS Debugging Tools
Rqt_graph
ROS Bag
• Record and playback data after or during a simulation
• Rqt_bag
• rosbag record -O xyz.bag topic_names
• Rosbag record –a
• Rosbag info
• Rosbag play
• Rosbag check
ROS Visualization
Visualize:

• Sensor data
• Robot joint states
• Coordinate frames
• Maps being built
• Debugging 3D markers

VIDEO
ROS Visualization Cont.
• Rviz
• Rosrun rviz rviz
• Add frames
• Fixed frames
• Refernce frames
• Fixed frame is dynamic ?
• 3D view
• Types of camera
Packages
• Perception

• Point Cloud Library (PCL)

• OpenCV

• Kinect/OpenNI
ROS Resources
• http://www.ros.org
• http://wiki.ros.org
• http://answers.ros.org

• ROS Cheatsheet:
http://www.tedusar.eu/files/summerschool2013/ROScheatsheet.pdf
Thank you!

You might also like