AI Robotics 2. ROS Basics Robot Operating System (ROS)

advertisement
Robot Operating System (ROS)
AI Robotics
• 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
planning, localization, 3d perception, …
• Primarily it runs under Unix-based platforms
2. ROS Basics
Robot Operating System
Alexander Kleiner
Slides are based on material from the
Dr. A. Kleiner
1
Design Principles of ROS
NAO
PR2
Roomba
Turtle
RoboNaut2
Pioneer3AT
(Dr. G. Steinbauer)
AI Robotics - ROS Basics
Ar.Drone.2.0
Dr. A. Kleiner
AI Robotics - ROS Basics
2
ROS vs. OS (Operating System)
• 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
Courtesy R.B. Rusu
3
Dr. A. Kleiner
AI Robotics - ROS Basics
4
Why using ROS?
ROS - Operation
• Supports Message Transport
• Publisher/Subscriber (nodes, messages, topics)
• Client/Server (services, actionlib)
• Runtime Execution
• Threads and Related Techniques
• Configuration
• Supports Development
•
•
•
•
Reusable Classes and Libraries
Definition of Interfaces
Debugging, Logging and Visualization Tools
Build System
Dr. A. Kleiner
AI Robotics - ROS Basics
Courtesy R.B. Rusu
5
ROS Eco-System
AI Robotics - ROS Basics
6
ROS Eco-System
apps
fetch beer
capabilities
universe
Dr. A. Kleiner
navigation, arm, grasping
libs
tf, pcl, opencv, bullet, eigen
tools
rxgraph, rostopic, roslaunch
middleware
rosmaster, roscpp, rosbuild
main
Courtesy R.B. Rusu
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
7
Dr. A. Kleiner
AI Robotics - ROS Basics
8
ROS Eco-System – Example Application
ROS Eco-System – Example Application
Courtesy R.B. Rusu
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
9
ROS Eco-System – Beer Me!
Dr. A. Kleiner
AI Robotics - ROS Basics
10
ROS Eco-System – Beer Me!
Courtesy R.B. Rusu
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
11
Dr. A. Kleiner
AI Robotics - ROS Basics
12
ROS Eco-System – Beer Me!
ROS Eco-System – Beer Me!
Courtesy R.B. Rusu
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
13
Dr. A. Kleiner
AI Robotics - ROS Basics
14
ROS Components
Beer me up!
• 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
15
Dr. A. Kleiner
AI Robotics - ROS Basics
16
Organizational Diagram
Organizational Diagram cont.
Courtesy R.B. Rusu
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
17
Organizational Diagram cont.
Dr. A. Kleiner
AI Robotics - ROS Basics
18
Organizational Diagram cont.
Courtesy R.B. Rusu
Dr. A. Kleiner
AI Robotics - ROS Basics
19
Dr. A. Kleiner
AI Robotics - ROS Basics
20
nodes can publish messages to a
topic as well subscribe to a topic
to receive messages (many-tomany communication)
messages are ROS data type
used by nodes when subscribing
or publishing to topics (streams)
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
Publisher – Subscriber Communication
Computation graph
Building Blocks of ROS
21
Synchronous Service
Dr. A. Kleiner
AI Robotics - ROS Basics
22
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
23
Dr. A. Kleiner
AI Robotics - ROS Basics
24
Messages
Navigation the ROS File System
• Simple data structures that are passed between nodes
• Defined in package-name/msg/*.msg files
• 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
• 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:
25
Parameters
Dr. A. Kleiner
AI Robotics - ROS Basics
26
Parameter Setting
• Have unique names in the Hierarchy
• Can represent primitive data types such as int,
string, …
float,
• 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
• Nodes can set Parameters on the Server (roscore)
• Any other Node can read them
• Can be also from command-line or via GUI
2
,4
a
tP
se
”
oo
(“f
am
AI Robotics - ROS Basics
)
{fo
o
27
Dr. A. Kleiner
ge
ROS
Master
r
Talker
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
:42
}
AI Robotics - ROS Basics
tPa
ram
(“fo
o ”)
Listener
28
Working with Topics
Computation Graph
• The command-line tools rostopic makes live easier
• One can quickly see what topics are used
• List all available topics
Robot
Odometry
Laser
Readings
IMU
MAP
• rostopic list
• Showing messages on a topic
Localization
• rostopic echo topic_name
• Showing message type of a topic
• rostopic type topic_name
Path
Planner
• …
Dr. A. Kleiner
AI Robotics - ROS Basics
29
Launch Files
AI Robotics - ROS Basics
30
Useful Features of ROS
• 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:
– Point Clouds for 3D perception (laser or
kinect)
– Velocity command for robot platforms
– Outsourcing of Computation
– Team development
• Coordination transformation with tf
– Manage several Reference Frames
– Automated Conversion
<!-- 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>
AI Robotics - ROS Basics
• Unified data types for similar sensors
and actuators
• Remote access from other hosts
<launch>
<!-- Start rviz visualization with preset config -->
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find drone_hri_launch)/rviz
rviz_default.vcg”
/>
Dr. A. Kleiner
Dr. A. Kleiner
31
Dr. A. Kleiner
AI Robotics - ROS Basics
32
Transformation Basics
tf: Coordinate Transformation
• Sensors on robots are measuring in
different coordinate frames which can
be static but also dynamically changing
over time
+Z
yaw
pitch
+Y
• In ROS data stays in the producing
frame and is transformed into a target
frame on purpose only
roll
roll, pitch, yaw
+X
right hand rule
Euler angles
• The tf library and a set of tools take
care about this transformations
Dr. A. Kleiner
AI Robotics - ROS Basics
33
Transform Chains
Dr. A. Kleiner
AI Robotics - ROS Basics
34
Transformation Tree
• In ROS one can build transformation chains, i.e. treelike structures
• Transformation between any two frames can be
computed automatically by tf
plate_link
map
kinect_base_link
map
kinect
frame
laser
frame
odometry
frame
[Andreasson et al. 2008]
Dr. A. Kleiner
AI Robotics - ROS Basics
base_link
odom
laser_base_link
odom
plate
frame
base_lin
k
plate_lin
k
map
base
frame
laser_base_li
nk
35
Dr. A. Kleiner
AI Robotics - ROS Basics
kinect:_base_li
nk
36
Tools for working/debugging with tf
Useful Nodes/Stacks in ROS
• In the Program Code
• Mapping (gmapping&hector)
– Instantiate a Transform Listener
– Retrieve Transformation for Particular
Frames and Time Stamps
– Transform the data
– Simple generation of 2d maps from
logged data
• Navigation
– Localization, Planning, and Execution
– Allows autonomous navigation
• tf_echo
– Command-line tool to display transformation messages for particular
frames
• Manipulation Planning (Arms)
− Based on OMPL
• tf_monitor
• Organization of behaviors
– Command-line tool to display all
transformationmessages
– Standard templates for behaviors
(actionlib)
• Rviz
• Behavior Selection
– Graphical tool to visualize all kind of
data and robots
Dr. A. Kleiner
AI Robotics - ROS Basics
– SMACH: Finite State Machine
37
ROS Tools: rxplot
Dr. A. Kleiner
AI Robotics - ROS Basics
Dr. A. Kleiner
AI Robotics - ROS Basics
38
ROS Tools: rxgraph
39
Dr. A. Kleiner
AI Robotics - ROS Basics
40
ROS Tools: rviz and rosbag
ROS Tools: rxbag
$ rxbag teleop.bag
Try out rxbag to
visualize the contents
of bag files
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
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
Questions?
Thank you!
43
Dr. A. Kleiner
AI Robotics - ROS Basics
44
Download