AI Robotics 2.  ROS Basics Robot Operating System

advertisement
AI Robotics
2.  ROS Basics
Robot Operating System
Alexander Kleiner
Slides are based on material from the
Dr. A. Kleiner
AI Robotics - ROS Basics
(Dr. G. Steinbauer)
1
Robot Operating System (ROS)
•  Open-Source Framework
•  Libraries and Tools to help Software
Developers create Robot Applications
•  Meta-operating system
•  Runs on several robot platforms :
•  Originally developed by Stanford AI Lab
(SAIL)
•  Continued by Willow Garage and now Open
Source Robotics Foundation
•  Provides a lot of functionality, e.g., motion
plannin, localization, 3d perception, …
•  Primarily it runs under Unix-based platforms
Ar.Drone.2.0
NAO
PR2
Roomba
Turtle
RoboNaut2
Pioneer3AT
Dr. A. Kleiner
AI Robotics - ROS Basics
2
Design Principles of ROS
•  Peer-To-Peer
–  (several independent processes and hosts)
•  Multi-Lingual
–  Communication is based on XML-RPC
–  Supports C++, Python, Octave, LISP, Java
–  Defined Data Types, Proprietary Message Definitions
•  Functional Modular and Tool-Based
–  Linux Philosophy, e.g., small Building Blocks
•  Open Source
–  Functionality packed in libraries, also 3rd party
–  Uses own build system
Dr. A. Kleiner
AI Robotics - ROS Basics
3
Overview
ROS vs. OS (Operating System)
High-level view
Mobile manipulation
Simulation
Task executive
Navigation
2D/3D Perception
ROS
Visualization
Client libraries
Message
passing
Word
processor
OS
Web browser
E-mail client
Memory management
File system
Radu Bogdan Rusu
Dr. A. Kleiner
Scheduler
GUI
Drivers
Courtesy R.B. Rusu
AI Robotics - ROS Basics
Robot Operating System
4
ROS - Operation
•  Supports Message Transport
•  Publisher/Subscriber (nodes, messages, topics)
•  Client/Server (services, actionlib)
•  Runtime Execution
•  Threads and Related Techniques
•  Configuration
•  Supports Development
• 
• 
• 
• 
Dr. A. Kleiner
Reusable Classes and Libraries
Definition of Interfaces
Debugging, Logging and Visualization Tools
Build System
AI Robotics - ROS Basics
5
WhyOverview
using ROS?
Why use ROS (1/3)
Courtesy R.B. Rusu
Radu Bogdan Rusu
Dr. A. Kleiner
Robot Operating System
AI Robotics - ROS Basics
6
ROS Eco-System
apps
fetch beer
capabilities
universe
navigation, arm, grasping
libs
tf, pcl, opencv, bullet, eigen
tools
rxgraph, rostopic, roslaunch
middleware
rosmaster, roscpp, rosbuild
main
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
7
Overview
ROS Eco-System
ROS ecosystem (3/3)
universe
apps
capabilites
libs
tools
middleware
(fetch beer)
(navigation, arm, grasping)
(tf, pcl, opencv, bullet, eigen)
(rxgraph, rostopic, roslaunch)
(rosmaster, roscpp, rosbuild)
main
Courtesy R.B. Rusu
Radu Dr.
Bogdan
Rusu
A. Kleiner
AI Robotics - ROS Basics
Robot Operating System
8
Overview
ROS Eco-System – Example Application
ROS ecosystem. Example application (1/2)
Fetch
beer
apps
capabilites
libs
tools
middleware
Courtesy R.B. Rusu
Radu Bogdan Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
Robot Operating System
9
Overview
ROS
Eco-System
– Example
Application
ROS ecosystem.
Example application
(2/2)
Fetch
beer
Clean
room
apps
capabilites
libs
tools
middleware
Courtesy R.B. Rusu
Radu Bogdan Rusu
Dr. A. Kleiner
Robot Operating System
AI Robotics - ROS Basics
10
Overview
ROS Eco-System
– Beer Me!
Example application (1/4)
Fetch
beer
apps
capabilites
libs
tools
middleware
Fetch beer
Radu Bogdan Rusu
Dr. A. Kleiner
Courtesy R.B. Rusu
AI Robotics - ROS Basics
Robot Operating System
11
Overview
ROS Eco-System
– Beer Me!
Example application (2/4)
Fetch
beer
Delivery
Open fridge
Beer
Face recognition identification
Courtesy
R.B. Rusu
Robot Operating
System
Radu Bogdan Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
12
Overview
ROS Eco-System – Beer Me!
Example application (3/4)
Fetch
beer
Delivery
Open fridge
Beer
Face recognition identification
PCL TF navigation OpenCV SMACH
arm_navigation
web_interface
collision_space
Courtesy
R.B. Rusu
Robot Operating System
Radu Bogdan Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
13
Overview
ROS Eco-System – Beer Me!
Example application (4/4)
Fetch
beer
Delivery
Open fridge
Beer
Face recognition identification
PCL TF navigation OpenCV SMACH
arm_navigation
roscpp
web_interface
common_msgs
rospy
collision_space
rosmaster
Courtesy R.B. Rusu
Radu Bogdan Rusu
Dr. A. Kleiner
actionlib
Robot Operating System
AI Robotics - ROS Basics
14
Beer me up!
Dr. A. Kleiner
AI Robotics - ROS Basics
15
ROS Components
•  Packages
–  Contains all sources for a single Software Module in ROS
•  Manifest (part of package)
–  Provides Information about Packages and defines
Dependencies and Compiler Flags
•  Stack
–  Collection of Packages that provide aggregate
functionality (e.g. navigation stack)
•  Stack Manifest
–  provides information about stacks
•  Message & Service Types
–  defines the data structure for messages & request and
response data structures of a service
Dr. A. Kleiner
AI Robotics - ROS Basics
16
Organizational Diagram
Overview
Organizational Diagram (1/4)
Package
Nodes
Messages
Services
Courtesy
R.B.
RusuSystem
Robot
Operating
Radu Bogdan Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
17
Organizational
Diagram cont.
Overview
Organizational Diagram (2/4)
Stack
Package
Package
Nodes
Messages
Services
Nodes
Messages
Services
Package
Nodes
Messages
Services
Courtesy
R.B. Rusu
Robot Operating System
Radu Bogdan Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
18
Organizational Diagram cont.
Overview
Organizational Diagram (3/4)
Repository
Stack
Package
Nodes
Messages
Services
Stack
Package
Nodes
Messages
Services
Package
Nodes
Messages
Services
Package
Nodes
Messages
Services
Radu Bogdan Rusu
Dr. A. Kleiner
Robot Operating System
AI Robotics - ROS Basics
19
Overview
Organizational Diagram cont.
Organizational Diagram (4/4)
ROS universe
Repository
Repository
Stack
Stack
P
Repository
P
P
Courtesy R.B. Rusu
Radu Bogdan Rusu
Dr. A. Kleiner
Robot Operating System
AI Robotics - ROS Basics
20
messages are ROS data type
used by nodes when subscribing
or publishing to topics (streams)
nodes can publish messages to a
topic as well subscribe to a topic
to receive messages (many-tomany communication)
services are used by nodes to
define one input and one output
message type (triggers)
the master is a node that is the
name service for ROS helping
nodes finding each other nodes
the parameter server provides
and manages centrally
parameters across the network
rosout is the decentralized ROS
equivalent of stdout/stderr
roscore is master + rosout +
parameter server
Dr. A. Kleiner
AI Robotics - ROS Basics
Basic infrastructure
a node is an executable that
uses ROS to communicate with
other nodes and does
computation
Computation graph
Building Blocks of ROS
21
Publisher – Subscriber Communication
Dr. A. Kleiner
AI Robotics - ROS Basics
22
Synchronous Service
Dr. A. Kleiner
AI Robotics - ROS Basics
23
Naming in ROS
•  Hierarchical Naming Structure for all Resource Types
•  Nodes / parameter / topics / services
•  Nodes may have a Name Space
/node_name/topic_name
•  Parameter are Hierarchically organized as well
/p3at/odometry/frequency
•  Can be used like a Linux file system (relative, global)
Dr. A. Kleiner
AI Robotics - ROS Basics
24
Navigation the ROS File System
•  Command-line tools can make your life easier:
-  changing into a package directory
roscd package_name
-  building a package
rosmake (package_name)
-  running a node
rosrun package_name node_name
-  running a larger project
roslaunch launch_file
Dr. A. Kleiner
AI Robotics - ROS Basics
25
Messages
•  Simple data structures that are passed between nodes
•  Defined in package-name/msg/*.msg files
•  Structs for ROS services are defined in package-name/srv/
*.srv Service = Request msg + Response msg
•  Can contain primitive data types such as
• 
int{8,16,32,64} /float{32,64} / string / time /Duration /array[]
•  Example TimeStamped 3D Pose:
Dr. A. Kleiner
[geometry_msgs/PoseStamped]:!
Header header!
uint32 seq!
time stamp!
string frame_id!
geometry_msgs/Pose pose!
geometry_msgs/Point position!
float64 x!
float64 y!
float64 z!
geometry_msgs/Quaternion orientation!
float64 x!
float64 y!
float64 z!
float64 w!
AI Robotics - ROS Basics
26
Parameters
•  Have unique names in the Hierarchy
•  Can represent primitive data types such as int,
float,
string, …
•  Can be set and remapped at runtime (good for
debugging)
•  Stored on the parameter server
•  Dynamic reconfiguration – notify nodes about
parameter changes via a handler
Dr. A. Kleiner
AI Robotics - ROS Basics
27
Parameter Setting
•  Nodes can set Parameters on the Server (roscore)
•  Any other Node can read them
•  Can be also from command-line or via GUI
ROS
Master
Talker
Dr. A. Kleiner
Listener
AI Robotics - ROS Basics
28
Working with Topics
•  The command-line tools rostopic makes live easier
•  One can quickly see what topics are used
•  List all available topics
•  rostopic list
•  Showing messages on a topic
•  rostopic echo topic_name
•  Showing message type of a topic
•  rostopic type topic_name
•  …
Dr. A. Kleiner
AI Robotics - ROS Basics
29
Computation Graph
Robot
Odometry
Laser
Readings
IMU
MAP
Localization
Path
Planner
Dr. A. Kleiner
AI Robotics - ROS Basics
30
Launch Files
•  One can imagine that starting several nodes with
specific parameters form the command-line can be time
consuming
•  The tool roslaunch allows to script start up procedures
•  To specify nodes, configurations, renaming …
•  Follows a XML-syntax:
<launch>!
<!-- Start rviz visualization with preset config -->!
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find drone_hri_launch)/rviz
!
rviz_default.vcg”!
/>!
!
<!-- publish a static map -->!
<arg name="map_file" default="$(find drone_hri_launch)/maps/tud_liu_simple_world.yaml"/>!
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" >!
<param name="frame_id" value="/map" />!
</node>!
</launch>!
Dr. A. Kleiner
AI Robotics - ROS Basics
31
Useful Features of ROS
•  Unified data types for similar sensors
and actuators
–  Point Clouds for 3D perception (laser or
kinect)
–  Velocity command for robot platforms
•  Remote access from other hosts
–  Outsourcing of Computation
–  Team development
•  Coordination transformation with tf
–  Manage several Reference Frames
–  Automated Conversion
Dr. A. Kleiner
AI Robotics - ROS Basics
32
tf: Coordinate Transformation
•  Sensors on robots are measuring in
different coordinate frames which can
be static but also dynamically changing
over time
•  In ROS data stays in the producing
frame and is transformed into a target
frame on purpose only
•  The tf library and a set of tools take
care about this transformations
Dr. A. Kleiner
AI Robotics - ROS Basics
33
Transformation Basics
+Z
yaw
pitch
+Y
roll
right hand rule
Dr. A. Kleiner
+X
roll, pitch, yaw
Euler angles
AI Robotics - ROS Basics
34
Transform Chains
•  In ROS one can build transformation chains, i.e. treelike structures
•  Transformation between any two frames can be
computed automatically by tf
map
kinect
frame
laser
frame
odometry
frame
[Andreasson et al. 2008]
Dr. A. Kleiner
AI Robotics - ROS Basics
plate
frame
base
frame
35
Transformation Tree
plate_link
map
kinect_base_link
base_link
odom
laser_base_link
odom
base_lin
k
plate_lin
k
map
laser_base_li
nk
Dr. A. Kleiner
AI Robotics - ROS Basics
kinect:_base_l
ink
36
Tools for working/debugging with tf
•  In the Program Code
–  Instantiate a Transform Listener
–  Retrieve Transformation for Particular
Frames and Time Stamps
–  Transform the data
•  tf_echo
–  Command-line tool to display transformation messages for particular
frames
•  tf_monitor
–  Command-line tool to display all
transformationmessages
•  Rviz
–  Graphical tool to visualize all kind of
data and robots
Dr. A. Kleiner
AI Robotics - ROS Basics
37
Useful Nodes/Stacks in ROS
•  Mapping (gmapping&hector)
–  Simple generation of 2d maps from
logged data
•  Navigation
–  Localization, Planning, and Execution
–  Allows autonomous navigation
•  Manipulation Planning (Arms)
-  Based on OMPL
•  Organization of behaviors
–  Standard templates for behaviors
(actionlib)
•  Behavior Selection
–  SMACH: Finite State Machine
Dr. A. Kleiner
AI Robotics - ROS Basics
38
ROS Tools: rxplot
Dr. A. Kleiner
AI Robotics - ROS Basics
39
ROS Tools: rxgraph
Dr. A. Kleiner
AI Robotics - ROS Basics
40
ROS Tools: rviz and rosbag
Data Visualization in 3D
rviz is a 3D visualization environment that
lets you combine sensor data, robot model,
and other 3D data into a combined view.
You can also send your own 3D markers
into rviz from your software.
Dr. A. Kleiner
Data Logging (e.g. from sensors)
rosbag is a command-line tool for recording
and playing back messages into "bag" files.
AI Robotics - ROS Basics
41
ROS Tools: rxbag
$ rxbag teleop.bag
Try out rxbag to
visualize the contents
of bag files
Dr. A. Kleiner
AI Robotics - ROS Basics
42
Additional Information
•  Ros wiki (http://www.ros.org/wiki/)
•  Ros answers (http://answers.ros.org)
•  Ros tuorials (http://www.ros.org/wiki/ROS/Tutorials)
Dr. A. Kleiner
AI Robotics - ROS Basics
43
•  Questions?
•  Thank you!
Dr. A. Kleiner
AI Robotics - ROS Basics
44
Download