ROS-I Basic Developers Training - Session 1 PDF
ROS-I Basic Developers Training - Session 1 PDF
Training Class
• Intro to ROS
• Catkin (Create workspace)
• Installing packages (existing)
• Packages (create)
• Nodes
• Messages / Topics
3
An Introduction to ROS
4
ROS Versions
Annual releases (“distribution”)
5
ROS : The Big Picture
software
sensors actuators
environment
6
ROS : The Big Picture
Our Approach: Collaboration, Modularity, and Simulation
sensors actuators
environment
7
What is ROS?
ROS is…
= + + +
8
ROS is… plumbing
Master
(DNS-like)
Publisher Subscriber
/topic
Publisher Subscriber
9
ROS Plumbing : Drivers
● 2d/3d cameras
● laser scanners
● robot actuators
● inertial units
● audio
● GPS
● joysticks
● etc.
(Adapted from Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)
10
ROS is …Tools
•logging/plotting
•graph visualization
•diagnostics
•visualization
11
ROS is…Capabilities
Planning
Perception Execution
12
ROS is… an Ecosystem
http://metrorobots.com/rosmap.html
13
ROS is a growing Ecosystem
(From Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)
14
ROS is International
unique wiki visitors July 2017
visitors per million people
1. Singapore: 1711
2. Hong Kong: 1255
3. Switzerland: 526
4. Taiwan: 500
5. Germany: 482
...
10. USA: 310
http://wiki.ros.org/Metrics
15
ROS is a Repository
https://vimeo.com/245826128
17
ROS Architecture: Nodes
ROS Master
• Enables nodes to locate one another
• Handles Parameter Server
robot
planning
camera image motion robot
interface processing logic interface
ROS Package
(e.g. Pick-and-Place Task)
robot
planning
camera image motion robot
interface processing logic interface
robot
model
multiple no
nodes nodes
ROS MetaPackage
(e.g. fanuc, ros_industrial, ros_desktop, ...)
robot
planning
camera image motion robot
interface processing logic interface
robot
model
21
ROS Resources
Package
wiki
ROS ROS-I
website ? wiki/github
ROS
Answers
22
ROS.org Website
http://ros.org
• Install Instructions
• Tutorials
• Links
– Packages, ROS Answers, etc.
23
Package Wiki
http://wiki.ros.org/<packageName>
26
What is ROS to you?
Training Goals:
• Show you ROS as a software framework
• Show you ROS as a tool for problem solving
• Apply course concepts to a sample application
• Ask lots of questions and break things.
27
Scan & Plan “Application”
28
Day 1 Progression
30
Getting ROS
http://wiki.ros.org/kinetic/Installation
31
Roscore
32
Exercise 1.0
Exercise 1.0
Basic ROS Install/Setup
33
Day 1 Progression
Add “resources”
Create Package Catkin
Create Node Workspace
Basic ROS Node
Interact with other nodes
Messages My Package
Services
Node
Run Node
rosrun
roslaunch
34
Creating a ROS Workspace
35
Catkin
• ROS uses the catkin build system
– based on CMAKE
– cross-platform (Ubuntu, Windows, embedded...)
– replaces older rosbuild system
• different build commands, directory structure, etc.
• most packages have already been upgraded to catkin
• rosbuild: manifest.xml, catkin: package.xml
http://www.clearpathrobotics.com/blog/introducing-catkin/ 36
Catkin Workspace
catkin_workspace
src
package_1
package_2
build
devel
37
Catkin Build Process
Setup (one-time)
1. Create a catkin workspace somewhere
• catkin_ws
• src sub-directory must be created manually
• build, devel directories created automatically
2. Run catkin init from workspace root
3. Download/create packages in src subdir
Compile-Time
1. Run catkin build anywhere in the workspace
2. Run source devel/setup.bash to make workspace
visible to ROS
• Must re-execute in each new terminal window
• Can add to ~/.bashrc to automate this process
38
Exercise 1.1
Exercise 1.1
Create a Catkin Workspace
fake_ar_pub myworkcell_node
myworkcell_support
vision_node
descartes_node
myworkcell_moveit_cfg ur5_driver
39
Day 1 Progression
40
Add 3rd-Party Packages
(a.k.a. “Resource” Packages)
41
Install options
42
Finding the Right Package
43
Install using Debian Packages
44
Installing from Source
• Find GitHub repo
• Clone repo into your workspace src directory
cd catkin_ws/src
git clone http://github.com/user/repo.git
• Build your catkin workspace
cd catkin_ws
catkin build
• Now the package and its resources are
available to you
http://www.clearpathrobotics.com/blog/introducing-catkin/ 45
Exercise 1.2
Exercise 1.2
Install “resource” packages
fake_ar_pub myworkcell_node
myworkcell_support
vision_node
descartes_node
myworkcell_moveit_cfg ur5_driver
46
Day 1 Progression
47
ROS Packages
48
ROS Package Contents
• ROS components are organized into packages
• Packages contain several required files:
– package.xml
• metadata for ROS: package name, description, dependencies, ...
– CMakeLists.txt
• build rules for catkin
package
directory
catkin_workspace
src
package_1 package source-files
(vs. catkin workspace src dir)
package
build
devel required
files
49
package.xml
50
package.xml
51
CMakeLists.txt
include_directories(include ${catkin_INCLUDE_DIRS})
Adds directories to CMAKE include rules
target_link_libraries(myNode ${catkin_LIBRARIES})
Links node myNode to dependency libraries
52
ROS Package Commands
• roscd package_name
Change to package directory
• rospack
– rospack find package_name
Find directory of package_name
– rospack list
List all ros packages installed
53
Create New Package
54
Exercise 1.3.1
Exercise 1.3.1
Create Package
fake_ar_pub myworkcell_node
vision_node
descartes_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
55
Day 1 Progression
56
ROS Nodes
57
A Simple C++ ROS Node
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
ros::init(argc, argv, “hello”);
ros::NodeHandle node;
return 0; return 0;
} }
58
ROS Node Commands
• rosnode
– rosnode list
View running nodes
– rosnode info node_name
View node details (publishers, subscribers, services, etc.)
– rosnode kill node_name
Kill running node; good for remote machines
Ctrl+C is usually easier
59
“Real World” – Nodes
demo_pick_and_place
gripper_action_server target_recognition_server
ethercat_io_driver camera_driver
move_group
joint_trajectory_action robot_state_pub
ur5_driver
rviz
60
Exercise 1.3.2
Exercise 1.3.2
Create a Node:
In myworkcell_core package
called vision_node
fake_ar_pub myworkcell_node
vision_node
descartes_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
61
Day 1 Progression
62
Topics and Messages
63
ROS Topics/Messages
64
Topics vs. Messages
/camera_1/rgb
camera_1 image … image …
/camera_2/rgb image_processing
camera_2 image … image …
65
Practical Example
/Basler1/image_rect
Basler Calibration Node
sensor_msgs/Image
Camera Node Subscribes to
Images from:
/Basler1/image_rect
/Basler2/image_rect /Basler2/image_rect
Basler sensor_msgs/Image /Basler3/image_rect
Camera Node …
66
Multiple Pub/Sub
/camera_1/rgb
image_processing
viewer
67
Topics : Details
• Typical Uses:
– Sensor Readings: camera images, distance, I/O
– Feedback: robot status/position
– Open-Loop Commands: desired position
68
ROS Messages Types
• Similar to C structures
• Standard data primitives
– Boolean: bool
– Integer: int8,int16,int32,int64
– Unsigned Integer: uint8,uint16,uint32,uint64
– Floating Point: float32, float64
– String: string
• Fixed length arrays: bool[16]
• Variable length arrays: int32[]
• Other: Nest message types for more complex data
structure
69
Message Description File
PathPosition.msg
comment # A 2D position and orientation
other Msg type Header header
float64 x # X coordinate
float64 y # Y coordinate
float64 angle # Orientation
data field
type name
70
Custom ROS Messages
• Modify CMakeLists.txt
to enable message
generation.
71
CMakeLists.txt
add_message_files(custom.msg ...)
generate_messages(DEPENDENCIES ...)
catkin_package(CATKIN_DEPENDS roscpp
message_runtime)
72
package.xml
73
ROS Message Commands
• rosmsg list
– Show all ROS topics currently installed on the system
• rosmsg package <package>
– Show all ROS message types in package <package>
• rosmsg show <package>/<message_type>
– Show the structure of the given message type
74
ROS Topic Commands
• rostopic list
– List all topics currently subscribed to and/or publishing
• rostopic type <topic>
– Show the message type of the topic
• rostopic info <topic>
– Show topic message type, subscribers, publishers, etc.
• rostopic echo <topic>
– Echo messages published to the topic to the terminal
• rostopic find <message_type>
– Find topics of the given message type
75
“Real World” – Messages
76
Topics: Syntax
• Topic Publisher
– Advertises available topic (Name, Data Type)
– Populates message data
– Periodically publishes new data
Publisher Object Advertise Topic Message Type Topic Name Queue Size
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<PathPosition>(“/position”, 25);
PathPosition msg;
msg.x=xVal; msg.y=yVal; ... Message Data
pub.publish(msg); Publish Message
ros::spinOnce();
Background
Process
77
Topics: Syntax
• Topic Subscriber
– Defines callback function
– Listens for available topic (Name, Data Type)
78
Qt
Instead of text editor and building
from terminal…
Use an IDE! Wiki instructions here
79
Exercise 1.4
Exercise 1.4
Subscribe to fake_ar_publisher
fake_ar_pub myworkcell_node
AR pose
vision_node
descartes_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
80