0% found this document useful (0 votes)
278 views36 pages

ROS For Absolute Beginners (Robot Operating System) : Lentin Joseph

Uploaded by

aayushi gautam
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)
278 views36 pages

ROS For Absolute Beginners (Robot Operating System) : Lentin Joseph

Uploaded by

aayushi gautam
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/ 36

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

You might also like