0% found this document useful (0 votes)
15 views5 pages

Intro To ROS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Intro To ROS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

3/25/21

ROS: the Robot Bookkeeping


2

Operating System § Schedule is updated


§ Videos, slides, etc. are up
§ Next class: back to kinematics
§ Next homework Friday
§ Today: the Robot Operating System, + projects
These are fantastic
resources. Go see
Most slides drawn, with thanks, from:
Dolev Shapira: https://www.cs.bgu.ac.il/~ben-shahar/Teaching/Computational- the source material!
Vision/StudentProjects/ICBV151/ICBV-2015-1-DolevShapira/object-recognition_slides.ppt,
Quick Introduction to ROS: https://www.cs.columbia.edu/~allen/F19/NOTES/ROS%20Tutorial.pptx,
Introduction to ROS – UW: https://courses.cs.washington.edu/courses/cse490r/18wi/quiz_section_slideseature
Robot Operating System, by Alec Poitzsch: http://courses.csail.mit.edu/6.141/spring2014/pub/lectures/Lec05-
ROS-Lecture.pptm
ROS Basics: http://www.rsl.ethz.ch/education-students/lectures/ros.html 2

1 2

ROS: Robot Operating System ROS


3 4
Camera
§ What is ROS? Well… Microphone § …is not actually an operating system.
Range-finder
Sensor data
Encoders § But it is a meta-operating system that handles:
§ Communication
§ Sharing common tasks
Reasoning,
Updating, § Moving from simulation to reality
Control
Kinematics, § Representing a robot (shape, controllers, …)
Control
Move § ROS lets you
World Model Actions Grasp § Avoid reinventing a lot of wheels!
Scan § Handle the nuts and bolts of communication
Recover § … with some startup effort.
§ How do we actually do this?
3 4

3 4

What does that include? Problem 1: sequential programming


What is5 ROS? 6

ROS = Robot Operating System § Conventional programming:

goForward(1);
turnLeft(Math.PI/2);
ros.org Image image = camera.getImage();
double distance = computeDistanceToObject(image);
goForward(distance - 1);
§ Process § Simulation § Control § Package organization (x, y) = getMyPositionFromTheEncoderCounts();
management § Visualization § Planning § Software distribution …
§ Inter-process § Graphical user § Perception § Documentation What happens if an obstacle appears while you are going forward?
communication interface § Mapping § Tutorials
§ Device drivers § Data logging What happens to the encoder data while you are turning?
§ Manipulation

Péter Fankhauser | 20.02.2017 | 6 What if some other module wants the same data?

5 6

5 6

1
3/25/21

Solution 1: “Callbacks” Problem 2: complexity


7 8 Topic: /camera/image
void imageCallback(ImageMessage image)
§ Callback: // process the latest image
Face Detection Image Message
Camera
§ Function called Image Messa
ge
void odometryCallback(OdometryMessage data)
whenever data is Obstacle Detection
// handle latest odometry data
available for cle
Obsta PointCloud
processing void main()
Laser Scanner

An asynchronous initialize(); 8
§ Map Building Topic: /kinect/cloud
subscribe(“image_msgs”,
callback can
happen any time
imageCallback); § Solutions:
subscribe(“odometry_msgs”,
odometryCallback); § Separate processes: Cameras, Odometry, Laser Scanner,
§ Examples: Map Building can all be separated out: interact through
§ Run the relevant callback function whenever: an interface
§ An image is read from the camera § Interfaces: Software processes (“nodes” in ROS)
§ The odometry sensor reports new data communicate about shared “topics” in ROS
§ Publish/Subscribe: Have each module receive only the
7 data (messages) it requests 8

7 8

Problem 3: Hardware-specific code History of ROS


9 10

Hardware-Independent Software Device-Specific Drivers § Originally developed in 2007 at the Stanford


Face
Artificial Intelligence Laboratory
Image Message
Detection

Imag e Message
Camera § Since 2013 managed by OSRF
Obstacle Detection
Po in tC
lo ud § Today used by many robots, universities and
companies
Obstacle Laser Scanner
lo u d
P o in tC

Map Building
Motors § De facto standard for robot programming
Interface
Etc.

§ Solution 3: Abstract hardware!

9 10

9 10

ROS philosophy Conceptual levels of design


11 12

§ Peer to peer: Individual programs communicate (A) ROS Community: ROS


over defined API (ROS messages, services, etc.) Carnegie Mellon
Distributions, Repositories

§ Distributed: programs can be run on multiple Node


Node
5 (B) Computation Graph:
computers and communicate over the network
4
Peer-to-Peer Network of
Node 1 Node 2:
ROS nodes (processes).
Laser Scanning Map Building
§ Multi-lingual: ROS modules can be written in any
language for which a client library exists Node 3:
Planning
§ In practice: C++ and Python Node
Node
7
6

§ Free and open-source (C) File-system level: ROS Tools for


managing source code, build instructions,
and message definitions.

11 12

11 12

2
3/25/21

Tools-based software design Multiple language support


13 14

§ Tools for: § ROS is implemented natively in each language.


§ Building ROS nodes
§ Quickly define messages in language-
§ Running ROS nodes
independent format.
§ Viewing network topology
§ Monitoring network traffic C++ Node :
Map Building
Python Node:
Laser Scanner

§ Many cooperating processes, instead of a Sub


scrip
tion licati
on
Pub
single monolithic program. File: PointCloud.msg
Topic:
“LaserData”
Header header
Points32[] pointsXYZ
int32 numPoints

File-system level

13 14

13 14

Lightweight Communication
15 16

§ Encourages standalone libraries with no ROS § ROS provides an interface that allows the user
dependencies: to create modular pieces that communicate
§ Don’t put ROS dependencies in the core of your
algorithm § Approximate equivalents:
§ Nodes ≅ “processes”
§ Use ROS only at the edges of your § Topics ≅ “message boards”
interconnected software modules:
Carnegie

Subscribers ≅ Nodes “watching” the topics and


Mellon
§
Downstream/Upstream interface ROS Community
reading incoming messages
§ Publishers ≅ Nodes publishing (“posting”)
§ ROS integrates code from a variety of projects: messages to topics
§ OpenCV : Computer Vision Library
§ Point Cloud Library (PCL) : 3D Data Processing
§ OpenRAVE : Motion Planning
15 16

15 16

Peer to Peer Messaging Peer to Peer Messaging


17 18

§ No central server through which all messages § Master: Lookup information, think DNS
are routed
§ Publish: Will not block until receipt, messages
§ “Master” service runs on one machine for get queued.
name registration + lookup
§ Delivery guarantees: Specify a queue size for
§ Messaging Types: publishers: If publishing too quickly, will buffer
§ Topics : Asynchronous data streaming a maximum of X messages before throwing
§ Parameter Server away old ones

Sidebar: computer science is getting better § Transport mechanism: TCPROS, uses TCP/IP
about terminology like “master/slave” systems, Bandwidth: Consider where your data’s going,
§
but it persists here. We’ll get there.
and how
17 18

17 18

3
3/25/21

ROS master/clients ROS master/clients


19ROS Master 20ROS Nodes

§ Master: § Clients:
ROS Master ROS Master
§ Manages
§ Manages the communication
the communication between nodes (processes)
between nodes § Single-purpose,
§ Single-purpose, executable
executable program program
§ Every node registers at startup with the
§ Every node registers at startup with the master
§ Individually compiled, executed, and
§ Individually compiled, executed, and managed Registration Registration
master managed
§ Organized in packages
§ Organized in packages

Start a master with Run a node with Node 1 Node 2


> roscore > rosrun package_name node_name

See active nodes with


> rosnode list

Retrieve information about a node with


More info More info
> rosnode info node_name
http://wiki.ros.org/Master http://wiki.ros.org/rosnode

Péter Fankhauser | 20.02.2017 | 10 Péter Fankhauser | 20.02.2017 | 11

19 20

19 20

ROS topics ROS messages


21 22

§ Nodes communicate over topics § Data structure defining the type of a topic
ROS Topics
§ Nodes can publish or subscribe to a topic § Nested structure of integers,
§ Nodes communicate over topics ROS Master booleans, strings etc., and
§ Typically, 1 publisher and n subscribers
§ Nodes can publish or subscribe to a topic arrays of objects
§ Typically, 1 publisher and n subscribers Registration Registration

§ Topic
ROS§ Topics
Topic is a nameisforaa name for a stream
stream of messages of messages Informs about
connection § Defined in *.msg files
Node 1 Messages Node 2
PublisherROS Master Subscriber
§ NodesList
communicate
active topics over
with topics
§ Nodes can publish
> rostopic or subscribe to a topic
list
§ Typically, 1 publisher and n subscribers
Publish
Registration Registration Subscribe
Subscribe and print the contents of a topic with topic
Informs about Subscribe
§ Topic is a name for a stream of messages
> rostopic echo /topic connection

Show information about a topic with Node 1 Messages Node 2


Publisher Subscriber More info
List active topics with
> rostopic info /topic http://wiki.ros.org/rostopic
> rostopic list
Publish Subscribe
Subscribe and print the contents of a topic with topic Péter Fankhauser | 20.02.2017 | 12

Subscribe
> rostopic echo /topic 21 22

21
Show information about a topic with
> rostopic info /topic
More info
http://wiki.ros.org/rostopic
22
Péter Fankhauser | 20.02.2017 | 12

ROS Visualization rviz


23 24

§ Visualize:
§ Sensor data
§ Robot joint states
§ Coordinate frames
§ Maps being built
§ Debugging 3D
markers

23 Image: https://neilnie.com/2018/05/10/gps-localization-with-ros-rviz-and-osm/ 24

23 24

4
3/25/21

More solvable problems: Gazebo simulator


25 26

§ I don’t have a robot in front of me


§ I want to try something that may break my robot
§ Setting up the robot takes too much time, I want
to test changes to my code quickly

25 26

25 26

Gazebo simulator Sources of information


27 28

§ Same interface as real robot § Tutorials: http://wiki.ros.org/ROS/Tutorials


§ We’ll start with these?
§ Add/remove 3D items in environment
§ http://answers.ros.org/questions/
§ Physics engine to simulate effects of motor
commands § Googling – ROS is surprisingly widely used!
§ Collision detection
§ Updated sensor feedback § To start with:
§ Debugging info § http://wiki.ros.org/ROS/Installation

27 28

27 28

You might also like