IntroductionToROS
Short Description
This document contains tutorials on ROS(Robot operating System) from willow garage....
Description
ROS Tutorial
Getting Started with ROS
Benjamin Cohen University of Pennsylvania 4/9/2010
Disclaimer! Achtung!
I am by no means a ROS wizard! I have a lot of experience. That's about it. I can rant on and on about ROS for days. This is a 1.5 hour summary and so I'm leaving some useful things out...
2
Outline
Part 1: Introduction to ROS
General Description
Important concepts
Simulation
Debugging Tools
Part 2: Create a node
(if you are ROS-curious) ROS-curious)
(if you are planning on using ROS immediatly)
what your basic code should look like
how to build your project
how to run the simulator
bring up the visualizer
3
What is ROS?
ROS & ROS-Pkgs are a creation of Willow Garage, Inc. ROS is a 'meta-operating system' that provides a message passing system between different processes across a network (Inter-Process Communication (IPC)). Why do I need some sort of IPC? Why not run a big 'for loop' on my robot?
For loop:
Simple design & implementation, only uses one core
Works on basic platforms with minimal computing power
Use multiple cores, multiple computers
Modular
ex. plan on an old map while receiving new sensor data
ex. run controller while planning
Parallel:
4
ROS
Are 'ROS' and 'Gazebo' synonymous? NO
Linux, MacOS, partial support for Windows
Languages:
Gazebo is a 3D simulator that originally used 'player' for communication but now uses ROS.
Supported Platforms
ROS is not a simulator.
C/C++,python,octave,lisp,~java
Suggested Hardware:
many cores!
nVidia video card for simulation
Network Support:
TCP/IP
5
High Level Diagram
6
Nodes
is a process that performs some function. nodes communicate with each other using topics & services. nodes are assigned unique names nodes are intended to be modular and 'operate on the fine-grained scale' a robotic system should be made up of many many nodes – it provides some fault tolerance when an isolated node crashes 7
Nodes
below is a diagram displaying the breakdown of the functionality of a navigation system into nodes
8
Messages
nodes communicate by passing around messages
a message is a data structure with typed fields
many standard messages already exist, new messages can be defined with a simple text file a message can be comprised c omprised of other messages ROS generates a data structure for new message that contains many standard stl type of functions (size(), resize(),etc.) mapping_msgs/CollisionMap CollisionMap.msg #header for interpreting box positions Header header #boxes for use in collision testing OrientedBoundingBox[] boxes
Header header uint32 seq time stamp string frame_id OrientedBoundingBox[] boxes geometry_msgs/Point32 center float32 x float32 y float32 z geometry_msgs/Point32 extents float32 x float32 y float32 z float32 angle
9
Params
a parameter server that stores parameter strings & value pairs which are normally passed as input to a program some params can be viewed by other nodes
great way to pass around a name of a topic or other info multiple nodes might need to know
can put XML & YAML files onto server
ex. ”shoulder_pan_max_vel” → '0.7'
ex. ”camera_resolution_640_480” → 'true' (bool)
ex. ”type_of_planner” → ”ARA” (string)
(double)
10
Topics
Method of passing messages
Node 'N' advertises that it is publishing Topic 'A'
Topic B subscribes to Topic 'A' (so (so do topics 'C','D'...) 'C','D'...)
Whenever 'A' publishes message, all of its subscribers receive it and their callback functions are executed
Asynchronous
Many-to-many
Not appropriate for request/reply interaction
Callback function is multi-threaded
ex. 'base_scan' is a publisher that publishes laser scans at 10 hz. Global planner, Controller & localization nodes subscribe to 11 base_scan.
Services
Request/Reply interaction between nodes Node 'A' advertises service 'S', Node 'B' sends request and waits for response. Node 'A' sends back a reply No topic callbacks are issued during service call (service request is blocking)
one-to-one
Used as a remote procedure call
ex. request a motion plan
12
Launch Nodes
A launch file is a convenient way to bringup many different nodes at once
Written in XML
Asynchronous execution
Can put parameters on server
ld.launch"/> unch"/> ht_arm.launch"/>
13
ROS Master
The 'roscore' is the master process that establishes connections between nodes (provides lookup info similar to DNS) Node 'N' wants to subscribe to topic 'T'. First a request for a connection is made, then the master establishes a connection over an agreed connection protocol between the nodes. ** Messages are not passed through the master to the receiving node. Nodes connect to other nodes directly **
Stores topics & services registration info for ROS nodes
Updates nodes about other nodes' statuses
Uses TCP/IP, many computers can connect to one master
Environment Variable ”ROS_MASTER_URI” ”ROS_MASTER_URI” defines the address & port number of ROS master
14
Packages
Willow Garage created 'ROS' as well as ~600 rospackages that are available for your use.
ex. laser pipeline, motor controllers, localization, localization, SLAM, forward kinematics, Hokuyo driver...
A folder that contains your code, build files, launch files, etc.
Should only contain code that is related
Can contain any number of nodes
'manifest.xml' – lists the ROS dependencies & system deps (some pkgs have up to 150 deps!) IMPORTANT: A package will not be found by ROS if it is not in your 'ROS_PACKAGE_PATH' 15
Build System
Need to specify in 'Cmakelists.txt' how to build the source code of a package No need for a handwritten Makefile Compile just package itself OR compile package + all dependencies
'rosmake': compile pkg + deps
'make': compile pkg
Can download system dependencies if not installed Compile multiple pkgs in parallel. ROS resolves deps first. 'ROS_PARALLEL_JOBS' = # of cores 16
Command Line Tools General Use
Many commands support ROS tab-completion!
Use '--help' to learn about numerous options
Command
Description
roscd
Change directory to specified ros-package
rosls
List contents of a ros-package
rosmake
Build all of the ros packages that a package depends on '--pre-clean': first run 'make clean' in each package then run 'make' '--rosdep-install': '--rosdep-install': install system dependencies first then compile all
●
●
roslaunch
Launch a '.launch' file (looks in 'launch' directory for file)
roscreate-pkg
Create a ro ros-package State the name & dependencies Automatically Automatically generates the directory, manifest.xml, manifest.xml, Makefile, etc. Can always change anything later!
●
●
●
rosdep
State dependencies of a package, Find out what depends on a specific package, Capable of output in tree format
roscp
Copy files from one package to another
rosed
Bring up your default text editor and edit file ”ros_package filename.txt” filename.txt”
t
t
E
t
i
t
t fil
17
Command Line Tools Debugging
rxgraph: displays a visualization of the ROS graph – the ROS nodes that are currently running and the topics that connect them
18
Command Line Tools Debugging
rxplot: plot data from one or more ROS topic fields that are currently being published.
19
Command Line Tools Debugging
rxconsole: brings up a viewer that displays any messages being published to 'rosout' can display the filename & line number of a message
useful for debugging code you are unfamiliar unfamiliar with
20
Command Line Tools Debugging Command
Description
*** rostopic rostopic *** displays displays a lot lot of informati information on about about a topic topic lists all topics available (list') echo messages of a specified topic ('echo') get publishing publishing rate of a topic ('hz') get bandwidth used by a topic ('bw') get info about a topic (subscribers, node) ('info') publish data to a topic ('pub') get the type of message of the topic ('type') ●
●
●
●
●
●
●
roswtf
outputs po possible er errors/warnings wi with th the cu current ro roscore ba based on on a set of defined rules
rosnode
displays a list of of no nodes, ca can ge get de detailed in information ab about th them
rosservice
same as rostopic but for services
rostopic echo
21
Command Line Tools Documentation
rosmsg: get field names and field types of a message rossrv: get the field names and field types of a service request/reply message
rosmsg show
22
Simulation: Gazebo
open source 3D simulator has been around for a while but has now been converted to using ROS for communication, communication, is a ros package offered by WG
uses ODE library for ridgid body dynamics
supports multiple robots
good for experiments that include motion planning, control & perception of ground vehicles less good for experiments that require precise contact between robot & environment such as manipulation world and objects in world are described in an XML '.world' file
offers fake localization & fake sensors
fully integrated into ROS
we will discuss in more in the more technical half of the presentation
23
Simulation: Gazebo Screenshots
24
Simulation: Stage
open source 2D simulator
great for multi-agent experiments
great for use with an integrated video card & slower machines
fully integrated into ROS
25
Visualizers: rviz
3D visualizer -
not a
simulator
capable of displaying all 'visualizable' messages without extra coding can change reference frame of visualization supports 'visualization markers', user created shapes to represent 'unvisualizable' data - great for debugging most vital ROS related tool available. note: 'nav_view' is a 2D version of rviz (nav_view is to stage as rviz is to gazebo)
26
Visualizers: rviz
gazebo simulation
Visualization markers accelerate debugging debugging!! red: padding around obstacles orange: obstacle cuboids in occupancy grid blue cubes: poses of randomly generated high-level states small green cubes: poses of low-level states expanded large green cubes: poses of high-level states expanded
rviz visualization
27
Other
tf library
'transform' library can fetch a transform from one frame to another frame at a specific point in time
uses description of robot, the state of joints
can also transform from one point in time to another point in time
ROS Play/Record
can record any information passed over ROS to a 'bag' file
the file can be played back later
ex. log sensor data for later analysis
ex. great for debugging hard to recreate situations
glc-record
record gazebo & rviz windows at the same time to create a multi-window video can easily record many OpenGL apps simultaneously.
28
Documentation
www.ros.org
documentation has been improving
there are many tutorials available
many schools have made public their own rospackage repository (there is a list at https://code.ros.org/gf/)
drivers for lots of common hardware are available
29
Summary
ROS
easy build system
easy to navigate in huge code library
a message passing system between processes on a single computer or on a network
valuable debugging tools are critical to hunting down bugs in complicated systems
ROS-Packages
Simulators: Gazebo & Stage many other packages are available that perform functions you might want
30
Part 2
In part 2 we'll create a new ros package that contains a basic node Feel free to run if you're ROSed-out
31
Part 2: Create a simple node
create a new package write your code (usually as a class)
create a main function that instantiates class
list the dependencies
describe how it should be built
build it
create a launch file
use rviz to inspect it's working correctly 32
create a new package roscreate-pkg meam620_tutorial
33
create a new package (cont'd)
Does 'rospack' find my new package?
test: open a new terminal, then run 'roscd meam620_tutorial' if it can't be found then make sure you created the package in your ROS_PACKAGE_PATH
run 'echo $ROS_PACKAGE_PATH' to check the path move the folder to within the path
34
start coding
Why contain your node's functionality in a class?
you will have many shared variables that you don't want to pass around as parameters between functions (publishers,subscribers,transforms, (publishers,subscribers,transforms, node handles) works best with specific pieces of functionality written as classes so that they can build on top of each other nicely and be reused have a main function that instantiates the class, and then calls ros::spin() 35
using messages
use 'rosmsg show …' to remind yourself of field names and types (or go to ros.org) remember to include the message header file with the correct case
package name: all lowercase message name: first letter of each word is capitalized
36
launching stuff
running many nodes requires opening many terminals launching many nodes from one launch file reduces the number of terminals you will have to open but is not a good idea to include a node that you are debugging in that file try not to copy and paste exact duplicates of launch files, but rather 'include' another launch file and it will be launched from its location 37
Play!
At this point we can continue from the terminal...
38
View more...
Comments