ROS For Absolute Beginners
(Robot Operating System)
Lentin Joseph
http://robocademy.com Founder/Instructor of Robocademy
Founder of Qbotics Labs
Day 4
Programming in ROS
http://robocademy.com
Agenda
• What is a ROS Package?
• Creating a ROS package?
• What are ROS Client libraries?
• roscpp and rospy
http://robocademy.com
Agenda
• Writing first ROS program using roscpp & rospy
• How to create a launch file?
• What is a ROS bag file?
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?
• Go to 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
ROS Client Libraries
http://robocademy.com
What are ROS client libraries ??
• ROS client libraries provide API’s to
access ROS functionalities
• roscpp and rospy
http://robocademy.com
roscpp client library
• roscpp is a C++ implementation of ROS.
• It provides a client library that enables C++
programmers to quickly interface with
ROS functionalities.
• http://wiki.ros.org/roscpp
http://robocademy.com
rospy client library
• rospy is a pure Python client library for
ROS.
• The rospy client API enables Python
programmers to quickly interface with
ROS
• http://wiki.ros.org/rospy
http://robocademy.com
Other ros client libraries !!!
• roslisp – Client of Lisp
• rosgo - Client implementation of Go
• rosjava – Java implementation
• rosruby – Ruby implementation
http://robocademy.com
Writing ROS Nodes using
roscpp client library
http://robocademy.com
Exercise - 1
• Write a ros node for sending “Hello_World”
message to a topic called chatter using
roscpp
http://robocademy.com
talker.cpp
http://robocademy.com
listener.cpp
http://robocademy.com
CMakeLists.txt
http://robocademy.com
Building nodes using catkin_make
http://robocademy.com
How to run ROS nodes
• rosrun command : Run a ros node
• $ roscore
• $ rosrun hello_world talker
• $rosrun hello_world listener
http://robocademy.com
ROS Launch files
• roslaunch is a tool for easily launching
multiple ROS nodes locally and remotely
via SSH, as well as setting parameters on
the Parameter Server.
http://robocademy.com
How to run both nodes together ??
• roslaunch command : roslaunch is a tool
for easily launching multiple
ROS nodes locally and remotely via SSH,
as well as setting parameters on
the Parameter Server.
• $ roscore
• $ roslaunch hello_world
talker_listener.launch
http://robocademy.com
talker_listener.launch
http://robocademy.com
Writing ROS Nodes using rospy
client library
http://robocademy.com
Exercise - 2
• Write a ros node for sending “Hello_World”
message to a topic called chatter using
rospy
http://robocademy.com
talker.py
http://robocademy.com
listener.py
http://robocademy.com
How to run ROS nodes
• rosrun command : Run a ros node
• $ roscore
• $ rosrun hello_world talker.py
• $rosrun hello_world listener.py
http://robocademy.com
How to run both nodes together ??
• roslaunch command : roslaunch is a tool
for easily launching multiple
ROS nodes locally and remotely via SSH,
as well as setting parameters on
the Parameter Server.
• $ roscore
• $ roslaunch hello_world
talker_listener_python.launch
http://robocademy.com
talker_listener_python.launch
http://robocademy.com
Command : rosbag
• Tool for Record /Playback ROS topics
• http://wiki.ros.org/rosbag
• $ rosbag record <topics>
• $ rosbag play <file_name>.bag
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
Conclusion
• Discussed ROS Client libraries
• Created a new ROS package and written
ROS nodes for publishing and subscribing
a string data using roscpp and rospy
• Discussed roslaunch files and rosbag
http://robocademy.com