PowerPoint Presentationcourses.csail.mit.edu/6.141/spring2014/pu… · PPT file · Web view · 2014-02-19Software basis of Willow Labs’s PR2. ... Peer-to-Peer Network of . ROS

Embed Size (px)

Citation preview

PowerPoint Presentation

Robot Operating System

Spring 2014

Alec Poitzsch

MIT EECS MEng Student (B.Sc 13)

1

Topics

Bridging the gap from simple to complex robotics

Introduction to ROS

ROS Software Development

ROS in 6.141

Bridging the gap fromsimple to complex robotics

RSS Robot Hardware Lab 2

Actuators:

Motors

Sensors:

Encoders

RSS Robot Software Lab 2

translate();

rotate();

RobotPositionController.java

Chassis.java

totalTicks, totalTime, sampleTime

???

publish

subscribe

RSS Robot Software Lab 2

OdometryRobot.java

updateAndControl();

RobotPositionController.java

controlStep();

Problems with this implementation

Single pipeline bottleneck

This is an architecture only suitable for simple systems.

Hardware

RobotBase.java

Software

publish

publish

subscribe

subscribe

We will need an architecture which can support more complex hardware and software components.

Goal: Develop big software for robots

Challenges encountered in robotics

The world is asynchronous

Robots must manage significant complexity

Robot hardware requires abstraction

Most of the robots in the video were doing multiple tasks at the same time.

Navigating towards a goal, while checking for obstacle avoidance; reading encoder information etc.

Reading camera information, sensor information for autonomy

- As a roboticist, work on a single field in which youre trying to be an expert in.

- Most of the components as the robots get bigger need to be abstracted away in order for your code to work

9

Problem 1: Sequential Programming

Lab 2 and conventional programming form:

goForward(1);

turnLeft(Math.PI/2);

Image image = camera.getImage();

double distance = computeDistanceToObject(image);

goForward(distance - 1);

(x, y) = getMyPositionFromTheEncoderCounts();

What happens if an obstacle appears while you are going forward?

What happens to the encoder data while you are turning?

What if some other module wants the same data?

Solution 1: Callbacks

Callback:

Function which is called whenever data is available for processing.

An asynchronous callback can happen at any time.

Examples:

Run the relevant callback function whenever:

An image is read from the camera

The odometry sensor reports new data

void imageCallback(ImageMessage image)

// process the latest image

void odometryCallback(OdometryMessage data)

// handle latest odometry data

void main()initialize();

subscribe(image_msgs, imageCallback);

subscribe(odometry_msgs, odometryCallback);

Problem 2: ComplexitySolution 2: Organizing code

Separate processes: Cameras, Odometry, Laser Scanner, Map Building can all be separated out: theyll interact through an interface

Interfaces: Software processes (nodes in ROS) communicate about shared topics in ROS

Publish/Subscribe: Have each module receive only the data (messages) it requests

12

Camera

Face Detection

Image Message

Obstacle Detection

Image Message

Laser Scanner

PointCloud

Map Building

Obstacle

Topic: /camera/image

Topic: /kinect/cloud

Message passing = Interface

Nodes: Sensors/Algorithms/High-level algorithms

Edges: Topics sent across for communication

12

Problem 3: Hardware dependent codeSolution 3: Abstracting hardware

Camera

Face Detection

Obstacle Detection

Image Message

Laser Scanner

PointCloud

Map Building

Obstacle

Image Message

Hardware-Independent Software

Device-Specific Drivers

Interface

PointCloud

Motors

Etc.

Can also mention the fact that we want code to be agnostic to thetype of hardware our code is running on top of -- both at driverlevel, and at morphology level.

Nodes: can be hardware independent or hardware-specific

Segway: Youve built your robot, how to make it work for these (next slide)

13

Result: Reusable code!

PR2 Roomba Care-O-bot 3

MIT Urban Challenge Vehicle

Summary

We want:

Callbacks

Separate processes that communicate through a messaging interface

A messaging interface that helps avoid hardware dependencies

Theres a software infrastructure out there that enables this (among many other things), and its called ROS.

Introduction to ROS

A meta-operating system for robots

Comparison: the PC ecosystem

Standardized layers

System software abstracts hardware

Applications leverage other applications (such as database, web server).

Widely existent sets of libraries

Applications

Application building blocks

System software

Hardware

Comparison: the robotics ecosystem

Applications

Application building blocks

System software

Hardware

Applications

ROS

Hardware

What is ROS?

A Meta Operating System.

Open source

Runs in Linux (esp. Ubuntu)

Ongoing Windows implementation

Agent based (nodes)

Message passing

Publish

Subscribe

Services via remote invocation

Supports numerous programming languages (C++, Python, Lisp, Java)

What is ROS?

Low level device abstraction

Joystick

GPS

Camera

Controllers

Laser Scanners

Application building blocks

Coordinate system transforms

Visualization tools

Debugging tools

Robust navigation stack (SLAM with loop closure)

Arm path planning

Object recognition

...

Application building blocks

System software

ROS

What is ROS?

Software management (compiling, packaging)

Remote communication and control

What is ROS?

Founded by Willow Garage

Exponential adoption

Countless commercial, hobby, and academic robots use ROS (http://wiki.ros.org/Robots)

What is ROS?

Software basis of Willow Labss PR2

ROS Philosophical goals

Hardware agnosticism

Peer to peer

Tools based software design

Multiple language support (C++/Java/Python)

Lightweight: runs only at the edge of your modules

Free

Open source

Suitable for large scale research and industry

ROS software development

Conceptual levels of design

29

Node 1

Laser Scanning

Node 2:Map Building

Node 3:Planning

(C) File-system level: ROS Tools for managing source code, build instructions, and message definitions.

Node 4

(B) Computation Graph: Peer-to-Peer Network of

ROS nodes (processes).

Node 5

Node 6

Node7

Carnegie Mellon

(A) ROS Community: ROS Distributions, Repositories

(A) Community Level: Resources that enable separate communities to exchange software:(i) ROS Distributions (ii) Code Repositories (Willow Garage, MIT) (iii) Wiki

(B) Computation Graph Level: Peer-to-Peer network of ROS processing that are processing sensor data and doing other computations. Nodes can be distributed across machines

(C) Filesystem Level: Ros has lots of tools for (i) organizing source code (ii) simplifying build instructions / dependencies (iii) Managing message definitions

29

Tools-based software design

Tools for:

Building ROS nodes

Running ROS nodes

Viewing network topology

Monitoring network traffic

Many cooperating processes, instead of a single monolithic program.

(A) No Monolithic Runtime Environment(B) Small tools for building + running ros nodes: visualizing network topology, measuring bandwidth utilization, plotting.

30

Multiple language support

ROS is implemented natively in each language.

Quickly define messages in language-independent format.

Python Node:

Laser Scanner

C++ Node : Map Building

Topic: LaserData

Publication

Subscription

Header header

Points32[] pointsXYZ

int32 numPoints

File: PointCloud.msg

File-system level

(A) ROS implemented natively in each target langauge.(B) Language-independent Interface Definition Language (IDL) for defining messages:

31

Lightweight

Encourages standalone libraries with no ROS dependencies:

Dont put ROS dependencies in the core of your algorithm!

Use ROS only at the edges of your interconnected software modules: Downstream/Upstream interface

ROS re-uses code from a variety of projects:

OpenCV : Computer Vision Library

Point Cloud Library (PCL) : 3D Data Processing

OpenRAVE : Motion Planning

Carnegie Mellon

ROS Community

Get downstream data, produce upstream data.

(A) Would like modules to be re-usable outside of ROS. Encourage all algorithm development to occur in standalone libraries w/ no dependencies on ROS. Dont put ROS in your algorithm.

(B) ROS re-uses code from a variety of projects: OpenCV, Point Cloud Library, OpenRAVE (ish). ROS just routing data in/out of respective software with as little wrapping as possible.

32

Peer to Peer Messaging

No Central Server through which all messages are routed.

Master service run on 1 machine for name registration + lookup

Messaging Types:

Topics : Asynchronous data streaming

Parameter Server

Computation Graph

The ROS runtime "graph" is a peer-to-peer network of processes.

No Central Server: Contrast w/ central-server-based Carmen: Consider the case of running robot w/ off-board compute-intensive tasks. If we run a central server offboard (or even onboard: go thru both cases) this results in unnecessary traffic across (slow) wireless link: many message routes are fully contained in subnets either onboard or offboard. Peer-to-peer connectivity avoid this issue

Master : DNS / name service : register + find nodes. Nodes connect to other nodes directly; the Master only provides lookup information, much like a DNS server. Nodes that subscribe to a topic will request connections from nodes that publish that topic, and will establish that connection over an agreed upon connection protocol. The most common protocol used in a ROS is called TCPROS, which uses standard TCP/IP sockets.

Styles of communication: *Asynchronous streaming of data over topics, and storage of data on a Parameter Server. 3rd type: synchronous RPC-style communication over services we dont really use

33

Peer to Peer Messaging

Master: Lookup information, think DNS

roscore command starts master, parameter server, logging

Publish: Will not block until receipt, messages get queued.

Delivery Guarantees: Specify a queue size for publishers: If publishing too quickly, will buffer a maximum of X messages before throwing away old ones

Transport Mechanism: TCPROS, uses TCP/IP

Bandwidth: Consider where your datas going, and how

Computation Graph

TCPROS is a transport layer for ROSMessagesandServices. It uses standard TCP/IP sockets for transporting message data. Inbound connections are received via a TCP Server Socket with a header containing message data type and routing information.

34

Free & Open Source

BSD License : Can develop commercial applications

Drivers (Kinect and others)

Perception, Planning, Control libraries

MIT ROS Packages : Kinect Demos, etc

Interfaces to other libraries: OpenCV, etc

ROS Debugging

36

Shutdown Object node re-compile restart : wont disturb system

Logging (VIDEO)

Kinect Driver

Object Recognition

Laser Scanner

Logger

Object Recognition

Logger Playback

Playback (VIDEO)

Editing Software: Say you want to debug 1 node in a large 20-node system. You can start all 20 nodes. Then if you want to change the 1 node youre interested in: you can shut it down while leaving the other 19 running. You can re-code, re-compile, and re-launch that node. The ros infrastructure (graph / master name registration) will automatically adapt to nodes dropping out / activating.

(B) Logging: Can dump any message stream to disk without modifying source code.

Logging/Playback: Recall your simulation environment in Labs

36

Useful ROS Debugging Tools

rostopic: Display debug information about ROS topics: publishers, subscribers, publishing rate, and message content.

rostopic echo [topic name] prints messages to console

rostopic list prints active topics

(several more commands)

rxplot : Plot data from one or more ROS topic fields using matplotlib.

rxplot /turtle1/pose/x,/turtle1/pose/y graph data from 2 topics in 1 plot

Rxplot: Rotation angle of the wheels/ Encoder reading

Rostopic: What if you dont know if your encoders are being read correctly, or if your motor died ( how does the robot know it is not responding )

DEBUGGING tools

37

rosbag

Useful ROS Debugging Tools

rxgraph

ROS Visualization

Visualize:

Sensor data

Robot joint states

Coordinate frames

Maps being built

Debugging 3D markers

VIDEO

(A) rviz (demo): tap into any message stream and visualize (if plugin available)Demo will show visualization of point clouds, robot joint states, coordinate frames, user-added markers

40

rviz

ROS Transformations

TF = Name of Transform package

Tully Foote == Person/Developer

TF Handles transforms between coordinate

frames : space + time

tf_echo : print updated transforms in console

Example:

rosrun tf tf_echo [reference_frame] [target_frame]

Packages

Perception

Point Cloud Library (PCL)

OpenCV

Kinect/OpenNI

ROS in 6.141

Reconciling Lab 2 with ROS

uorc_publisher

uorc_listener

Orcboard

/rss_msgs/EncoderMsg

/rss_msgs/MotionMsg

45

Reconciling Lab 2 with ROS

uorc_publisher

uorc_listener

/rss_msgs/EncoderMsg

/rss_msgs/MotionMsg

Your code

46

Reconciling Lab 2 with ROS

uorc_publisher

uorc_listener

/rss_msgs/EncoderMsg

/rss_msgs/MotionMsg

Your code

Orcboard

/rss_msgs/EncoderMsg

/rss_msgs/MotionMsg

47

Peer to Peer

Workstation

Netbook

ROS code enviroment

Since our codebase is in JAVA, we use rosjava.

roscore launch ROS host on netbook

rosmake build a package (formerly ant)

roslaunch lab4 lab4.launch launch package (formerly ant run)

*.launch file specifies additional parameters

Lab 3 ROS and Visual Servoing

publish

Topic: /rss/video

Your code

subscribe

Lab 3 will contain a comprehensive overview of ROS

ROS Resources

http://www.ros.org

http://wiki.ros.org

ROS Cheatsheet: http://www.tedusar.eu/files/summerschool2013/ROScheatsheet.pdf

Thank you!