Concepts and Command-Line
Based on ROS 0.7, July 2009
Questions/feedback:
kwc@willowgarage.com
This Presentation
Please use this presentation as a reference guide. This
presentation attempts to cover all of the main ROS concepts
and their related tools. It is probably too much to learn in one
sitting. As you go through these slides, you may wish to consult
the ROS Wiki at:
http://pr.willowgarage.com/wiki/ROS
You will find more tutorials and documentation there that go
over each of these topics in greater detail.
ROS Overview
What is ROS?
Meta operating system for robotics
System for obtaining, building, writing and running code
across multiple computers
Not realtime, but it can communicate with realtime
processes
Architecture
distributed processes
network-based, peer-to-peer transport of data
synchronous Services and asynchronous Topics that
transport Message data
ROS Concepts
ROS concepts can be divided into three layers:
computation graph : how programs run
file system : how program files are organized and built
repositories : how files are distributed online
ROS is designed for sharing code, which affects its design at
each of these levels.
community
Repositories
We wish to support a diverse ecosystem of code
Federated model
Many repositories (Stanford, CMU, MIT, Wash-U,
Georgia Tech, Bosch, Brown)
Easier to contribute and control your code
Open Source, mostly BSD
Currently all Subversion (SVN)
Wikis
ROS wiki: http://pr.willowgarage.com/wiki
OpenCV wiki: http://opencv.willowgarage.com/wiki/
ros.org: coming soon!
community tools
roslocate
Command-line tool to search for and download source
code for ROS packages
$ roslocate describe package-name
$ roslocate svn package-name
$ roslocate repo package-name
$ roslocate search keyword
$ svn co `roslocate svn package-name`
checks out source code for package
More coming soon
e.g.: http://stair.stanford.edu/ros/list.php
Lets try roslocate
$ roslocate search irobot
irobot_create
$ roslocate svn irobot_create
http://brown-ros-pkg.googlecode.com/svn/trunk/rlab/irobot_create
$ svn co `roslocate svn irobot_create`
packages, stacks and apps
Packages
Can contain anything: libraries, Nodes, Messages, tools
Goldilocks principal: enough functionality to be useful,
but not so much as to be heavyweight
Many packages = smaller, easier-to-use code, but...
... many packages = MANY (300+)
packages, stacks and apps
Stacks
Release with version numbers
Collect similar packages that work together
ROS
2D nav
manipulation
controllers
Apps
Coming soon
Similar to Stacks, but are runnable
Stacks = libraries, Apps = applications
packages, stacks, and apps
common/ A stack is a directory with a stack.
stack.xml xml file.
tf/
manifest.xml
robot_msgs/ An app is a directory with a app.
manifest.xml xml file.
msg/
... A package is a directory with a
nav/ manifest.xml file.
stack.xml A package inside of a stack/app's
amcl/
directory is part of that stack/app.
manifest.xml
move_base/
manifest.xml
...
package tools
roscreate-pkg package-name dependency1...N
Create a new ROS package
$ roscreate-pkg foo roscpp tf
rospack
Find and get information about ROS packages
$ rospack list
$ rospack find package-name
$ rospack depends package-name (also depends1)
$ rospack depends-on package-name (also depends-on1)
$ rospack langs
roscd package-name
same as $ cd `rospack find package-name`
package tools (II)
rosmake package-name1...N
make package-name1...N
as well as $ rospack depends package-name...N
bash <(rosdep satisfy package-name)
Install external dependencies (e.g. wxpython)
Lets give packages a try
$ rospack find foo
[rospack] couldn't find package [foo]
$ roscd
$ roscreate-pkg foo rospy std_msgs
Creating package directory /Users/kwc/ros/foo
Creating python source directory /Users/kwc/ros/foo/src/foo
Creating package file /Users/kwc/ros/foo/Makefile
Creating package file /Users/kwc/ros/foo/manifest.xml
Creating package file /Users/kwc/ros/foo/CMakeLists.txt Creating package file /Users/kwc/ros/foo/mainpage.dox
Please edit foo/manifest.xml and mainpage.dox to finish creating your package
$ rospack find foo
/Users/kwc/ros/foo
$ rospack depends1 foo
rospy
std_msgs
$ roscd foo
$ pwd
/Users/kwc/ros/foo
msg and srv
Simple text files (IDL)
compiled to C++, Python, LISP...
msg (Message Description)
package-name/msg/*.msg
data types:
int8, int16, int32, int64 (plus uint*)
float32, float64
string
time, duration
variable-length array[] and fixed-length array[C]
srv (Service Description)
package-name/srv/*.msg
Request msg + Response msg
example
pr2_msgs/Odometry
Header header
robot_msgs/Pose odom
robot_msgs/PoseDot odom_vel
float64 distance
float64 angle
float64 residual
msg and srv tools
rosmsg
Find and get information about msg files
$ rosmsg show msg-type
$ rosmsg users msg-type
$ rosmsg package package-name
$ rosmsg packages
rossrv: same as rosmsg
CMake macros
ros/core/rosbuild.cmake
genmsg(): run Message generators
gensrv(): run Service generators
Lets give msgs a try
$ roscd foo
$ mkdir msg
$ echo "int64 num" > msg/Num.msg
$ rosmsg show foo/Num
int64 num
$ vi CMakeLists.txt
[uncomment genmsg() line]
$ rosmake foo
master, roscore
Master
Name service for ROS
Nodes register Topics and Services with Master
Nodes find other Nodes using Master
XML-RPC based
roscore
Master
rosout: logs /rosout topic for debugging
Parameter Server
nodes
Executable file within a ROS Package
'nav/move_base'
find nav -name move_base -type f -perm +111
Publish or Subscribe to Topics
Can also provide Services
Have a unique name, e.g. /hokuyo
Name can be remapped at runtime
rosrun hokuyo_node hokuyo_node __name:=base_hokuyo
node tools
rosrun nav/move_base
rosnode
Find and get information about ROS Nodes
$ rosnode list
$ rosnode ping node-name
$ rosnode info node-name
roslaunch: launch many nodes using XML files
<roslaunch>
<node pkg="foo" type="bar" name="talker" />
<node pkg="foo" type="baz" name="listener" />
</roslaunch>
rxgraph: interactive graph of currently running ROS Nodes
Lets play with roscore + rosnode (I)
$ roscore $ rosnode list
/rosout
$ rosnode info /rosout
--------------------------------------------------------------------------------
Node [/rosout]
Publications:
* /rosout_agg [roslib/Log]
Subscriptions:
* /time [unknown type]
* /rosout [unknown type]
Services:
* /rosout/set_logger_level
* /rosout/get_loggers
contacting node http://foo.local:54614/ ...
Pid: 5092
Lets play with roscore + rosnode (II)
$ roscore $ roscd roslaunch $ rosnode list
rosnode list
$ roslaunch example. /included/wg2/talker-5203-1248242468096
launch /included/talker-5201-1248242468096
/included2/talker-5206-1248242468119
/included2/wg2/listener-5223-1248242468252
/wg/talker-1
/included2/wg2/talker-5217-1248242468155
/rosout
/included/wg2/listener-5204-1248242468146
/included2/listener-5210-1248242468165
/wg/listener-5198-1248242468127
/included/listener-5202-1248242468187
/wg/talker-2
$ rosnode ping /wg/talker-1
rosnode: node is [/wg/talker-1]
pinging /wg/talker-1 with a timeout of 3.0s
xmlrpc reply from http://ninja.local:54748/ time=4.
828930ms
ctrl-C to terminate
Lets play...
From now on, all the "Lets play" sections
assume that you're running roscore
topics
Publisher sends Messages to Subscribers
Usually TCP/IP transport
roscpp has experimental UDP transport
XML-RPC is only used to negotiate transport. We don't
send messages over XML-RPC.
Uniquely named
Can be remapped at runtime
$ rosrun hokuyo_node hokuyo_node laser:=base_laser
topic tools
rostopic
Get information about a ROS topic, including printing
messages currently being published
$ rostopic list
$ rostopic echo topic-name
$ rostopic hz topic-name
$ rostopic type topic-name
$ rxplot topic1/field1,topic2/field2
Plots topic data over time
$ rosrecord topic1 topic2 topic3
Creates a bag file (.bag)
Playback with 'rosplay file.bag'
Lets play with rostopic
$ rostopic pub -r 10 numbers foo/Num 12345
$ rostopic echo numbers
---
num: 12345
---
num: 12345
$ bash <(rosdep satisfy rxtools)
[this will take awhile if you haven't done it yet]
$ rxplot numbers
services
RPC
Client <-Request/Response message-> Service
Can be 'persistent', i.e. keep alive connection
Tools
rosservice
Get information about and query ROS Services
$ rosservice call add_two_ints 1 2
$ rosservice list
$ rosservice type
rossrv
Lets play with Services
$ rosrun rospy_tutorials add_two_ints_server.py
$ rosservice list
/add_two_ints
/rosout/set_logger_level
/rosout/get_loggers
$ rosservice type add_two_ints
rospy_tutorials/AddTwoInts
$ rosservice type add_two_ints | rossrv show
int64 a
int64 b
---
int64 sum
$ rosservice call add_two_ints 1 2
sum: 3
parameters
Stored on central Parameter Server (the Master)
Unique names
Can be remapped at runtime
Local parameters ~param_name
~param_name = /node_name/param_name
Set at runtime
$ rosrun mypkg mynode _param_name:=1
Types
integers, floats, boolean, dictionaries, maps
Dictionary of dictionaries
$ rosparam set gains '{p: 1, i: 2, d: 3}'
$ rosparam get gains/p
1
parameter tools
rosparam
Get and set parameters from command-line arguments or YAML files
$ rosparam get parameter-name
$ rosparam set parameter-name
$ rosparam load yaml-file
$ rosparam dump yaml-file
roslaunch
Sets parameters as well
Lets play with Parameters
$ rosparam set hello true
$ rosparam get hello
true
$ rosparam get gains
$ rosparam set gains "{p: 1.0, i: 2.0, d: 3.0}"
$ rosparam get gains/p
1.0
$ rosparam get /
...
$ rosparam dump params.yaml
$ vi params.yaml
$ rosparam load params.yaml copy
$ rosparam get copy/gains
{d: 3.0, i: 2.0, p: 1.0}
names
Syntax:
/global-name
relative-name
~local-name
"Pushing down"
relative-name -> foo/relative-name
Wiki page
pushing down I
<roslaunch>
<node pkg="foo" type="bar" name="talker" />
<node pkg="foo" type="baz" name="listener" />
</roslaunch>
Nodes:
/talker
/listener
Topic:
/topic_name
pushing down II
<roslaunch>
<group ns="wg">
<node pkg="foo" type="bar" name="talker" />
<node pkg="foo" type="baz" name="listener" />
</group>
<group ns="stanford">
<node pkg="foo" type="bar" name="talker" />
<node pkg="foo" type="baz" name="listener" />
</group> ...
Nodes:
/wg/talker
/wg/listener
/stanford/talker
/stanford/listener
Topic:
/wg/topic_name
/stanford/topic_name
more
roswtf: general problem diagnosis tool
rosbash: roscp, rosls, rosed, rospd
rostest: roslaunch for running tests
ROS Packages
rviz: Robot Visualizer
tf: coordinate system
nav/*: 2D+ navigation stack
more on the way
Credits (ROS core)
ROS Lead: Morgan Quigley (Stanford)
ROS Developers: Brian Gerkey, Josh Faust, Ken Conley,
Rob Wheeler, Tully Foote, Jeremy Leibs, Bhaskara Marthi
(WG)
rosoct: Rosen Diankov (CMU)
rosjava: Jason Wolfe