Sunteți pe pagina 1din 59

ROS For Absolute Beginners

(Robot Operating System)

Lentin Joseph
http://robocademy.com Founder/Instructor of Robocademy
Founder of Qbotics Labs
Day 3

ROS Concepts

http://robocademy.com
Agenda
• What is ROS Build System?

• Setting a ROS workspace

• ROS File System Level

• ROS Computation Graph Level

http://robocademy.com
Agenda

• ROS Community Level

• ROS Command Tools

• Learning ROS concepts using Turtlesim Demo

http://robocademy.com
Build System in ROS
• What is a build system in ROS?

• A build system is responsible for generating 'targets' from


raw source code that can be used by an end user.

• These targets may be in the form of libraries, executable


programs, generated scripts, exported interfaces (e.g. C++
header files) or anything else that is not static code.

• In ROS terminology, source code is organized into


'packages' where each package typically consists of one or
more targets when built.

http://robocademy.com
Which ROS build system are we
using now ??
• What is catkin build system ?
• http://wiki.ros.org/catkin/conceptual_overview
• A CMake(Cross Platform Make) based +
Python scripted system
• Helps to build source code in cross platform
• Better distribution of package
• Better than rosbuild build system used till
ROS- groovy

http://robocademy.com
Task 1
• Install Terminal tool called Terminator
• $ sudo apt-get install terminator

http://robocademy.com
How to create a workspace for
ROS?
• What is a workspace ?
• How to create a catkin based workspace ?
• http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguring
ROSEnvironment

• $ mkdir -p ~/ros_catkin_ws/src

• $ cd ~/ros_catkin_ws/src

• $ catkin_init_workspace

http://robocademy.com
How to create a workspace for
ROS?
• $ cd ~/ros_catkin_ws/

• $ catkin_make

• $ echo "source
~/ros_catkin_ws/devel/setup.bash"
>> ~/.bashrc

http://robocademy.com
How to create a workspace in
ROS?

http://robocademy.com
Creating a ROS Workspace: Demo

http://robocademy.com
ROS Levels of Concepts

• ROS File System Level

• ROS Computational Level

• ROS Community Level

http://robocademy.com
ROS File System

http://robocademy.com
ROS File System
• Packages
• Metapackages
• Package Manifest
• Repositories
• Message (msg) types
• Service (srv) types

http://robocademy.com
What is a ROS Package ?
• http://wiki.ros.org/Packages

• Software in ROS is organized in packages.

• A package might contain ROS nodes, a ROS-


independent library, a dataset, configuration files, a third-
party piece of software, or anything else that logically
constitutes a useful module.

• The goal of these packages it to provide this useful


functionality in an easy-to-consume manner so that
software can be easily reused.
http://robocademy.com
How to create a hello_world ROS
package inside ROS workspace?
• Goto src folder of ros_catkin_ws
• $ cd ~/ros_catkin_ws/src

• $ catkin_create_pkg hello_world
std_msgs rospy roscpp

http://robocademy.com
Inside hello_world package

http://robocademy.com
The CMakeFile.txt

http://robocademy.com
The package Manifest

http://robocademy.com
How to build hello_world package
• Switch to ROS workspace
– $ cd ~/ros_catkin_ws
• Build the packages inside workspace
– $ catkin_make
– $ catkin_make install
• Check package is installed
– $ roscd hello_world

http://robocademy.com
How to create/build a hello_world
ROS package?
• Creating and Building a Package Demo

http://robocademy.com
Structure of ROS Package
CMakeLists.txt
package.xml talker.py
talker.cpp
tistener.py
listener.cpp

config include scripts src

launch msg srv action

http://robocademy.com
ROS Computation Graph Level

http://robocademy.com
ROS Computation Graph Level

• Nodes

• Master

• Parameter Server

http://robocademy.com
ROS Computation Graph Level
• Message

• Topics

• Services

• Bags

http://robocademy.com
ROS Nodes

http://robocademy.com
What is a ROS Node ??
• Nodes: Nodes are processes that perform
computation.
• A robot control system usually comprises many nodes.
For example, one node controls a laser range-finder,
one node controls the wheel motors, one node
performs localization, one node performs path
planning, one Node provides a graphical view of the
system, and so on.

• A ROS node is creating with the help of ROS client


libraries, such as roscpp or rospy.

http://robocademy.com
ROS Topics
• Topics are named buses over
which nodes exchange messages.

Topic : /talker
Message : std_msgs/String

Publish data
Topic : /talker listener node
talker node
Subscribe data
Message : std_msgs/String
ros node 1 ros node 2

http://robocademy.com
ROS Message
• Nodes communicate with each other by
publishing messages through topics.
• A message is a simple data structure,
comprising typed fields.
• Standard primitive types (integer, floating
point, Boolean, etc.) are supported, as are
arrays of primitive types.

http://robocademy.com
ROS Message
• Example :
• std_msgs , eg : std_msgs/String
• sensor_msgs , eg: sensor_msgs/Image
• geometry_msgs ,eg:
geometry_msgs/Twist
• Custom Message definitions stored in
msg folder inside a ROS package

http://robocademy.com
ROS Master
• The ROS Master provides naming and registration services
to the rest of the nodes in the ROS system.

• It tracks publishers and subscribers to topics as well


as services.

• The role of the Master is to enable individual ROS nodes to


locate one another. Once these nodes have located each
other they communicate with each other peer-to-peer.
• The Master also provides the Parameter Server.

• The Master is most commonly run using


the roscore command, which loads the ROS Master along
with other essential components.

http://robocademy.com
How ROS inter process
communication works ?
Publish String Message

Topic : /talker

Message : std_msgs/String ROS Master

listener
talker
node
node

http://robocademy.com
How ROS inter process
communication works ?
Subscribe String Message
Publish String Message
Topic : /talker
Topic : /talker
Message : std_msgs/String
Message : std_msgs/String ROS Master

listener
talker
node
node

http://robocademy.com
How ROS inter process
communication works ?
Publish String Message Subscribe String Message

Topic : /talker ROS Master Topic : /talker

Message : std_msgs/String Message : std_msgs/String

listener
talker
node
node
/talker

“Hello World”

http://robocademy.com
Block Diagram of ROS Master
• Naming and Registration of Nodes
• Parameter Server
– Stores various parameters of nodes in a
centralized location

Naming and Registration


Parameter Server
Services

http://robocademy.com
ROS Community Level

• Distributions: Distribution are collection of


versioned stacks that you can install
• Repositories:
• The ROS Wiki
• Mailing List
• ROS Answers
• Blog

http://robocademy.com
ROS Command tools

http://robocademy.com
Command : roscore
• roscore is a collection of nodes and programs
that are pre-requisites of a ROS-based
system.

• You must have a roscore running in order


for ROS nodes to communicate. It is
launched using the roscore command.

• roscore = rosmaster + parameter server +


rosout logging node

http://robocademy.com
Try roscore in your terminal

http://robocademy.com
Command : rostopic

http://robocademy.com
Command : rosnode

http://robocademy.com
Command : rosparam

http://robocademy.com
Command : rosrun

http://robocademy.com
roscpp tutorials: talker & listener

http://robocademy.com
roscpp tutorials: talker & listener
• $ roscore

[Publisher]
• $ rosrun roscpp_tutorials talker

[Subscriber]
• $ rosrun roscpp_tutorials listener

http://robocademy.com
roscpp tutorials: talker & listener

http://robocademy.com
Playing with ROS command tools

http://robocademy.com
Turtlesim Demo

http://robocademy.com
Learn ROS using Turtlesim
• http://wiki.ros.org/turtlesim

http://robocademy.com
Launching turtlesim

• $ roscore [In first terminal]

• $ rosrun turtlesim turtlesim_node [In


second terminal]

http://robocademy.com
Launching turtlesim

http://robocademy.com
Moving turtle

• $ rosrun turtlesim turtle_teleop_key

http://robocademy.com
Moving turtle

http://robocademy.com
Inspecting ROS Topic

http://robocademy.com
Inspecting ROS Parameter

http://robocademy.com
Communication graph

http://robocademy.com
Turtlesim Demo: Draw Square

• $ roscore [In first terminal]

• $ rosrun turtlesim turtlesim_node [In


second terminal]

• rosrun turtlesim draw_square

http://robocademy.com
Turtlesim Demo: Draw Square

http://robocademy.com
Conclusion
• Discussed ROS Build system, ROS File
system level, computation level and
Community level

• Discussed ROS commands tools

• Worked with ROS concepts using


Turtlesim demo
http://robocademy.com

S-ar putea să vă placă și