ROS For Absolute Beginners (Robot Operating System) : Lentin Joseph
ROS For Absolute Beginners (Robot Operating System) : Lentin Joseph
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?
http://robocademy.com
Agenda
http://robocademy.com
What is a ROS Package ?
• http://wiki.ros.org/Packages
• $ 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
http://robocademy.com
roscpp client library
• http://wiki.ros.org/roscpp
http://robocademy.com
rospy client library
• rospy is a pure Python client library for
ROS.
• http://wiki.ros.org/rospy
http://robocademy.com
Other ros client libraries !!!
• roslisp – Client of Lisp
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
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
http://robocademy.com
Structure of ROS Package
CMakeLists.txt
package.xml talker.py
talker.cpp
tistener.py
listener.cpp
http://robocademy.com
Conclusion
• Discussed ROS Client libraries
http://robocademy.com