Post on 16-Nov-2014
description
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 roboticsSystem for obtaining, building, writing and running code across multiple computers Not realtime, but it can communicate with realtime processes
Architecturedistributed processesnetwork-based, peer-to-peer transport of datasynchronous Services and asynchronous Topics that transport Message data
ROS Concepts
ROS concepts can be divided into three layers:computation graph : how programs runfile system : how program files are organized and builtrepositories : 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)
WikisROS wiki: http://pr.willowgarage.com/wikiOpenCV 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 soone.g.: http://stair.stanford.edu/ros/list.php
Lets try roslocate
$ roslocate search irobot irobot_create$ roslocate svn irobot_createhttp://brown-ros-pkg.googlecode.com/svn/trunk/rlab/irobot_create$ svn co `roslocate svn irobot_create`
packages, stacks and apps
PackagesCan contain anything: libraries, Nodes, Messages, toolsGoldilocks 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
ROS2D navmanipulationcontrollers
AppsComing soon Similar to Stacks, but are runnable
Stacks = libraries, Apps = applications
packages, stacks, and apps
common/stack.xmltf/
manifest.xmlrobot_msgs/
manifest.xmlmsg/
...nav/
stack.xml amcl/
manifest.xmlmove_base/
manifest.xml...
A stack is a directory with a stack.xml file. An app is a directory with a app.xml file. A package is a directory with a manifest.xml file.A package inside of a stack/app's directory is part of that stack/app.
package tools
roscreate-pkg package-name dependency1...NCreate a new ROS package$ roscreate-pkg foo roscpp tf
rospackFind 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...Nmake 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_msgsCreating 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 foorospystd_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, float64stringtime, durationvariable-length array[] and fixed-length array[C]
srv (Service Description)package-name/srv/*.msg Request msg + Response msg
example
pr2_msgs/OdometryHeader headerrobot_msgs/Pose odomrobot_msgs/PoseDot odom_velfloat64 distancefloat64 anglefloat64 residual
msg and srv tools
rosmsgFind and get information about msg files $ rosmsg show msg-type$ rosmsg users msg-type$ rosmsg package package-name $ rosmsg packages
rossrv: same as rosmsgCMake macros
ros/core/rosbuild.cmake genmsg(): run Message generatorsgensrv(): run Service generators
Lets give msgs a try
$ roscd foo$ mkdir msg$ echo "int64 num" > msg/Num.msg$ rosmsg show foo/Numint64 num
$ vi CMakeLists.txt [uncomment genmsg() line] $ rosmake foo
master, roscore
MasterName service for ROS
Nodes register Topics and Services with MasterNodes find other Nodes using Master
XML-RPC based roscore
Masterrosout: logs /rosout topic for debuggingParameter Server
nodes
Executable file within a ROS Package'nav/move_base'find nav -name move_base -type f -perm +111
Publish or Subscribe to TopicsCan also provide ServicesHave 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_baserosnode
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$ roslaunch example.launch
ctrl-C to terminate
$ rosnode listrosnode list/included/wg2/talker-5203-1248242468096/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-1rosnode: node is [/wg/talker-1]pinging /wg/talker-1 with a timeout of 3.0sxmlrpc reply from http://ninja.local:54748/ time=4.828930ms
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 transportroscpp has experimental UDP transportXML-RPC is only used to negotiate transport. We don't send messages over XML-RPC.
Uniquely namedCan be remapped at runtime$ rosrun hokuyo_node hokuyo_node laser:=base_laser
topic tools
rostopicGet 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/field2Plots 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
RPCClient <-Request/Response message-> Service
Can be 'persistent', i.e. keep alive connectionTools
rosserviceGet 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_intsrospy_tutorials/AddTwoInts $ rosservice type add_two_ints | rossrv showint64 aint64 b---int64 sum $ rosservice call add_two_ints 1 2sum: 3
parameters
Stored on central Parameter Server (the Master)Unique names
Can be remapped at runtimeLocal parameters ~param_name
~param_name = /node_name/param_nameSet at runtime
$ rosrun mypkg mynode _param_name:=1Types
integers, floats, boolean, dictionaries, mapsDictionary of dictionaries
$ rosparam set gains '{p: 1, i: 2, d: 3}'$ rosparam get gains/p1
parameter tools
rosparamGet 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
roslaunchSets parameters as well
Lets play with Parameters$ rosparam set hello true$ rosparam get hellotrue$ rosparam get gains$ rosparam set gains "{p: 1.0, i: 2.0, d: 3.0}"$ rosparam get gains/p1.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-namerelative-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 toolrosbash: roscp, rosls, rosed, rospdrostest: roslaunch for running testsROS Packages
rviz: Robot Visualizertf: coordinate systemnav/*: 2D+ navigation stackmore 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