Intro To ROS
Intro To ROS
1 2
3 4
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
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
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.
9 10
9 10
11 12
11 12
2
3/25/21
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
15 16
§ 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
§ 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
19 20
19 20
§ 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
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
§ 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
25 26
25 26
27 28
27 28