training class€¦ · •src sub-directory must be created manually •build, devel directories...
TRANSCRIPT
![Page 1: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/1.jpg)
ROS-Industrial Basic Developer’s Training Class
Southwest Research Institute
1
![Page 2: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/2.jpg)
Session 1: ROS Basics
Southwest Research Institute
2
![Page 3: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/3.jpg)
Outline
• Intro to ROS
• Catkin (Create workspace)
• Installing packages (existing)
• Packages (create)
• Nodes
• Messages / Topics
3
![Page 4: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/4.jpg)
An Introduction to ROS
4
(Image taken from Willow Garage’s “What is ROS?” presentation)
![Page 5: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/5.jpg)
ROS Versions
Annual releases (“distribution”)
5
Box Turtle C Turtle Diamondback Electric Fuerte Groovy
Mar 2010 Aug 2010 Mar 2011 Aug 2011 April 2012 2012 - 2014
Hydro Indigo Jade Kinetic Lunar Melodic
2013 - 2015 2014 - 2019 2015 - 2017 2016 - 2021 2017 - 2019 2018 - 2023
![Page 6: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/6.jpg)
ROS : The Big Picture
All robots are:
Software connecting Sensors to Actuators to interact with the Environment
6
software
sensors
environment
actuators
(Adapted from Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)
![Page 7: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/7.jpg)
ROS : The Big Picture
• Break Complex Software into Smaller Pieces
• Provide a framework, tools, and interfaces for distributed development
• Encourage re-use of software pieces
• Easy transition between simulation and hardware
7
(Adapted from Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)
sensors
environment
actuators
Our Approach: Collaboration, Modularity, and Simulation
![Page 8: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/8.jpg)
= + + +
Plumbing Tools Capabilities Ecosystem
What is ROS?
ROS is…
(Adapted from Willow Garage’s “What is ROS?” Presentation)
8
![Page 9: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/9.jpg)
ROS is… plumbing
(Adapted from Willow Garage’s “What is ROS?” Presentation)
9
Master
Publisher
Publisher
Subscriber
Subscriber
/topic
(DNS-like)
![Page 10: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/10.jpg)
ROS Plumbing : Drivers
10
● 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)
![Page 11: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/11.jpg)
ROS is …Tools
11
•logging/plotting •graph visualization •diagnostics •visualization
(Adapted from Willow Garage’s “What is ROS?” Presentation)
![Page 12: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/12.jpg)
ROS is…Capabilities
12
Execution
Planning
Perception
(Adapted from Willow Garage’s “What is ROS?” Presentation)
![Page 13: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/13.jpg)
ROS is… an Ecosystem
13
http://metrorobots.com/rosmap.html
![Page 14: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/14.jpg)
ROS is a growing Ecosystem
14
(From Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)
![Page 15: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/15.jpg)
ROS is International
15
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
Does not include visitors to wiki mirrors
(Singapore, China, ...)
![Page 16: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/16.jpg)
ROS is a Repository
16
ros_comm ("core")
100 KLOC
desktop-full ("core+tools")
400 KLOC
all buildfarm ("universe") 4000 KLOC
only includes publicly released code!
(From Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics”)
![Page 17: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/17.jpg)
ROS is …
17
https://vimeo.com/245826128
![Page 18: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/18.jpg)
ROS Architecture: Nodes
18
• A Node is a single ROS-enabled program – Most communication happens between nodes – Nodes can run on many different devices
• One Master per system
ROS Master • Enables nodes to locate one another • Handles Parameter Server
camera interface
image processing
motion logic
robot planning
robot interface
![Page 19: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/19.jpg)
ROS Architecture: Packages
19
camera interface
image processing
motion logic
robot planning
robot interface
robot model
ROS Package (e.g. Pick-and-Place Task)
multiple nodes
no nodes
• ROS Packages are groups of related nodes/data
– Many ROS commands are package-oriented
![Page 20: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/20.jpg)
ROS Architecture: MetaPkg
20
camera interface
image processing
motion logic
robot planning
robot interface
robot model
ROS MetaPackage (e.g. fanuc, ros_industrial, ros_desktop, ...)
• MetaPackages are groups of related packages
– Mostly for convenient install/deployment
![Page 21: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/21.jpg)
ROS Programming
• ROS uses platform-agnostic methods for most communication – TCP/IP Sockets, XML, etc.
• Can intermix programming languages
– primary: C++, Python, Lisp
– also: C#, Java, Matlab, etc.
– We will be using C++ for our exercises
21
![Page 22: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/22.jpg)
ROS Resources
22
?
Package wiki
ROS-I wiki/github
ROS Answers
ROS website
![Page 23: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/23.jpg)
ROS.org Website
• Install Instructions
• Tutorials
• Links
– Packages, ROS Answers, etc.
23
http://ros.org
![Page 24: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/24.jpg)
Package Wiki
• Description / Usage
• Tutorials
• Code / Msg API
24
• Source-Code link
• Bug Reporting
http://wiki.ros.org/<packageName>
![Page 25: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/25.jpg)
ROS Answers
25
http://answers.ros.org
• Quick responses to Good Questions
• Search by text or tag
• Don’t re-invent the wheel!
![Page 26: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/26.jpg)
ROS is a Community
• No Central “Authority” for Help/Support
– Many users can provide better (?) support
– ROS-I Consortium can help fill that need
• Most ROS-code is open-source
– can be reviewed / improved by everyone
– we count on YOU to help ROS grow!
26
![Page 27: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/27.jpg)
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
![Page 28: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/28.jpg)
Scan & Plan “Application”
28
![Page 29: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/29.jpg)
ROS
Day 1 Progression
Install ROS
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
rosparam
Catkin Workspace
My Package
Node
Resource
Package
29
![Page 30: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/30.jpg)
Installing ROS
30
![Page 32: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/32.jpg)
Roscore
roscore is a collection of nodes and programs that are pre-requisites of a ROS-based system
To check your install, open a terminal and type:
roscore
To kill the process, press Ctrl+C while in the window running roscore
32
![Page 33: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/33.jpg)
Exercise 1.0
Exercise 1.0 Basic ROS Install/Setup
33
![Page 34: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/34.jpg)
ROS
Day 1 Progression
Install ROS (check install)
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
34
Catkin Workspace
My Package
Node
Resource
Package
![Page 35: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/35.jpg)
Creating a ROS Workspace
35
![Page 36: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/36.jpg)
Catkin
36
• 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/
![Page 37: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/37.jpg)
Catkin Workspace
• Catkin uses a specific directory structure: – each “project” typically gets its own catkin workspace
– all packages/source files go in the src directory
– temporary build-files are created in build
– results are placed in devel
37
catkin_workspace src
package_1 package_2
build devel
![Page 38: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/38.jpg)
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
![Page 39: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/39.jpg)
Exercise 1.1
Exercise 1.1 Create a Catkin Workspace
39
fake_ar_pub
vision_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
myworkcell_node
descartes_node
![Page 40: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/40.jpg)
ROS
Day 1 Progression
Install ROS
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
40
Catkin Workspace
My Package
Node
Resource
Package
![Page 41: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/41.jpg)
Add 3rd-Party Packages (a.k.a. “Resource” Packages)
41
![Page 42: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/42.jpg)
Install options
Debian Packages
• Nearly “automatic”
• Recommended for end-users
• Stable
• Easy
Source Repositories
• Access “latest” code
• Most at Github.com
• More effort to setup
• Unstable*
42
Can mix both options, as needed
![Page 43: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/43.jpg)
Finding the Right Package
• ROS Website (http://ros.org/browse/)
– Browse/Search for known packages
• ROS Answers (http://answers.ros.org)
– When in doubt... ask someone!
43
![Page 44: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/44.jpg)
Install using Debian Packages
sudo apt install ros-kinetic-package
44
• Fully automatic install: • Download .deb package from central ROS repository • Copies files to standard locations (/opt/ros/kinetic/...)
Also installs any other required dependencies
• sudo apt-get remove ros-distro-package
• Removes software (but not dependencies!)
admin permissions
manage “.deb”
install new “.deb”
all ROS pkgs start with ros-
ROS distribution
ROS package name
Use “-” not “_”
![Page 45: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/45.jpg)
Installing from Source
45
• Find GitHub repo
• Clone repo into your workspace src directory
• Build your catkin workspace
• Now the package and its resources are available to you
http://www.clearpathrobotics.com/blog/introducing-catkin/
cd catkin_ws/src
git clone http://github.com/user/repo.git
cd catkin_ws
catkin build
![Page 46: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/46.jpg)
Exercise 1.2
Exercise 1.2 Install “resource” packages
46
fake_ar_pub
vision_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
myworkcell_node
descartes_node
![Page 47: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/47.jpg)
ROS
Day 1 Progression
Install ROS
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
47
Catkin Workspace
My Package
Node
Resource
Package
![Page 48: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/48.jpg)
ROS Packages
48
![Page 49: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/49.jpg)
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
49
required files
package source-files (vs. catkin workspace src dir)
package directory catkin_workspace
src package_1 package
build devel
![Page 50: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/50.jpg)
package.xml
• Metadata: name, description, author, license ...
50
![Page 51: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/51.jpg)
package.xml
• Metadata: name, description, author, license ...
• Dependencies: – Common
• <buildtool_depend>: Needed to build itself. (Typically catkin)
• <depend>: Needed to build, export, and execution dependency. (format “2” only)
– Sometimes • <build_depend>: Needed to build this package.
• <build_export_depend>: Needed to build against this package.
• <exec_depend>: Needed to run code in this package.
– Uncommon • <test_depend>: Only additional dependencies for unit tests.
• <doc_depend>: Needed to generate documentation.
51
![Page 52: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/52.jpg)
CMakeLists.txt
• Provides rules for building software – template file contains many examples
include_directories(include ${catkin_INCLUDE_DIRS})
Adds directories to CMAKE include rules
add_executable(myNode src/myNode.cpp src/widget.cpp)
Builds program myNode, from myNode.cpp and widget.cpp
target_link_libraries(myNode ${catkin_LIBRARIES})
Links node myNode to dependency libraries
52
![Page 53: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/53.jpg)
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
– rospack depends package_name List all dependencies of package_name
53
![Page 54: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/54.jpg)
Create New Package
Easiest way to start a new package
– create directory, required files
– mypkg : name of package to be created
– dep1/2 : dependency package names
• automatically added to CMakeLists and package.xml
• can manually add additional dependencies later
54
catkin create pkg mypkg --catkin-deps dep1 dep2
![Page 55: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/55.jpg)
Exercise 1.3.1
Exercise 1.3.1 Create Package
55
fake_ar_pub
vision_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
myworkcell_node
descartes_node
![Page 56: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/56.jpg)
ROS
Day 1 Progression
Install ROS
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
Catkin Workspace
My Package
Resource
Package
56
![Page 57: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/57.jpg)
ROS Nodes
57
![Page 58: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/58.jpg)
A Simple C++ ROS Node
Simple C++ Program
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello World!";
return 0;
}
Simple C++ ROS Node
#include <ros/ros.h>
int main(int argc, char* argv[])
{
ros::init(argc, argv, “hello”);
ros::NodeHandle node;
ROS_INFO_STREAM("Hello World!“);
return 0;
}
58
![Page 59: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/59.jpg)
ROS Node Commands
• rosrun package_name node_name execute ROS node
• 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
![Page 60: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/60.jpg)
“Real World” – Nodes
60
demo_pick_and_place
gripper_action_server
ethercat_io_driver
move_group
joint_trajectory_action
ur5_driver
robot_state_pub
camera_driver
target_recognition_server
rviz
![Page 61: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/61.jpg)
Exercise 1.3.2
Exercise 1.3.2 Create a Node:
In myworkcell_core package called vision_node
61
vision_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
myworkcell_node
descartes_node
fake_ar_pub
![Page 62: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/62.jpg)
ROS
Day 1 Progression
Install ROS
Create Workspace
Add “resources”
Create Package
Create Node Basic ROS Node
Interact with other nodes Messages
Services
Run Node rosrun
roslaunch
Catkin Workspace
My Package
Node
Resource
Package
62
![Page 63: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/63.jpg)
Topics and Messages
63
![Page 64: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/64.jpg)
ROS Topics/Messages
64
msg … msg … msg
Publisher Node
Publishing msg data On channel /topic
Publisher Node
Advertises /topic is available with type msg
Subscriber Node
Subscribed to /topic with type msg
ROS MASTER
Subscriber Node
Listening for /topic with type msg
/topic
Topics are for Streaming Data
![Page 65: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/65.jpg)
Topics vs. Messages
• Topics are channels, Messages are data types
– Different topics can use the same Message type
65
camera_1
camera_2
image_processing
image … image …
/camera_1/rgb
image … image …
/camera_2/rgb
![Page 66: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/66.jpg)
Practical Example
66
Calibration Node Subscribes to Images from:
/Basler1/image_rect /Basler2/image_rect /Basler3/image_rect
…
Basler Camera Node
sensor_msgs/Image
/Basler1/image_rect
Basler Camera Node
sensor_msgs/Image
/Basler2/image_rect
![Page 67: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/67.jpg)
Multiple Pub/Sub
• Many nodes can pub/sub to same topic
– comms are direct node-to-node
67
camera_1
image_processing
logger
viewer
/camera_1/rgb
image … image …
![Page 68: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/68.jpg)
Topics : Details
• Each Topic is a stream of Messages: – sent by publisher(s), received by subscriber(s)
• Messages are asynchronous – publishers don’t know if anyone’s listening
– messages may be dropped
– subscribers are event-triggered (by incoming messages)
• Typical Uses: – Sensor Readings: camera images, distance, I/O
– Feedback: robot status/position
– Open-Loop Commands: desired position
68
![Page 69: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/69.jpg)
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
![Page 70: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/70.jpg)
Message Description File
• All Messages are defined by a .msg file
70
PathPosition.msg # A 2D position and orientation
Header header
float64 x # X coordinate
float64 y # Y coordinate
float64 angle # Orientation
data type
field name
comment
other Msg type
![Page 71: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/71.jpg)
Custom ROS Messages
• Custom message types are defined in msg subfolder of packages
• Modify CMakeLists.txt to enable message generation.
71
![Page 72: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/72.jpg)
CMakeLists.txt
• Lines needed to generate custom msg types
find_package(catkin REQUIRED COMPONENTS
message_generation)
add_message_files(custom.msg ...)
generate_messages(DEPENDENCIES ...)
catkin_package(CATKIN_DEPENDS roscpp
message_runtime)
72
![Page 73: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/73.jpg)
package.xml
<build_depend> message_generation </build_depend>
<build_export_depend>message_runtime</build_export_depend>
<run_depend>message_runtime</run_depend>
73
![Page 74: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/74.jpg)
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
![Page 75: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/75.jpg)
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
![Page 76: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/76.jpg)
“Real World” – Messages
• Use rqt_msg to view: – sensor_msgs/JointState
– trajectory_msgs/JointTrajectory
– sensor_msgs/Image
– rosgraph_msgs/Log
76
![Page 77: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/77.jpg)
• Topic Publisher – Advertises available topic (Name, Data Type)
– Populates message data
– Periodically publishes new data
Topics: Syntax
77
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<PathPosition>(“/position”, 25);
PathPosition msg;
msg.x=xVal; msg.y=yVal; ...
pub.publish(msg);
ros::spinOnce();
Publisher Object Advertise Topic Message Type
Background Process
Topic Name Queue Size
Message Data
Publish Message
![Page 78: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/78.jpg)
• Topic Subscriber
– Defines callback function
– Listens for available topic (Name, Data Type)
Topics: Syntax
78
void msg_callback(const PathPosition& msg) {
ROS_INFO_STREAM(“Received msg: “ << msg);
}
ros::Subscriber sub = nh.subscribe(“/topic”, 25, msg_callback);
Callback Function Message Type Message Data (IN)
Server Object Service Name Callback Ref
![Page 79: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/79.jpg)
Qt
Instead of text editor and building from terminal…
Use an IDE! Wiki instructions here
79
![Page 80: Training Class€¦ · •src sub-directory must be created manually •build, devel directories created automatically 2. Run catkin init from workspace root 3. Download/create packages](https://reader034.vdocuments.us/reader034/viewer/2022050508/5f9916768b0f4f00426d7546/html5/thumbnails/80.jpg)
fake_ar_pub
Exercise 1.4
Exercise 1.4 Subscribe to fake_ar_publisher
80
vision_node
myworkcell_support
myworkcell_moveit_cfg ur5_driver
myworkcell_node
descartes_node
AR pose