0% found this document useful (0 votes)
111 views

ROS-I Basic Developers Training - Session 1 PDF

This document provides an introduction to the Robot Operating System (ROS) through a training class outline. It discusses ROS basics including catkin workspaces, installing and creating packages, nodes, messages, and topics. It describes ROS as plumbing for communication between nodes, as well as tools, capabilities, and an international ecosystem. ROS uses a distributed architecture with nodes that communicate via topics and messages. ROS is an open-source project supported by a large community.

Uploaded by

blah
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)
111 views

ROS-I Basic Developers Training - Session 1 PDF

This document provides an introduction to the Robot Operating System (ROS) through a training class outline. It discusses ROS basics including catkin workspaces, installing and creating packages, nodes, messages, and topics. It describes ROS as plumbing for communication between nodes, as well as tools, capabilities, and an international ecosystem. ROS uses a distributed architecture with nodes that communicate via topics and messages. ROS is an open-source project supported by a large community.

Uploaded by

blah
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/ 80

ROS-Industrial Basic Developer’s

Training Class

Southwest Research Institute


1
Session 1:
ROS Basics

Southwest Research Institute


2
Outline

• Intro to ROS
• Catkin (Create workspace)
• Installing packages (existing)
• Packages (create)
• Nodes
• Messages / Topics

3
An Introduction to ROS

(Image taken from Willow Garage’s “What is ROS?” presentation)

4
ROS Versions
Annual releases (“distribution”)

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

5
ROS : The Big Picture

software

sensors actuators

environment

All robots are:


Software connecting Sensors to Actuators
to interact with the Environment
(Adapted from Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)

6
ROS : The Big Picture
Our Approach: Collaboration, Modularity, and Simulation

sensors actuators

environment

• 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
(Adapted from Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics” presentation)

7
What is ROS?

ROS is…

= + + +

Plumbing Tools Capabilities Ecosystem

(Adapted from Willow Garage’s “What is ROS?” Presentation)

8
ROS is… plumbing

Master

(DNS-like)
Publisher Subscriber
/topic

Publisher Subscriber

(Adapted from Willow Garage’s “What is ROS?” Presentation)

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

(Adapted from Willow Garage’s “What is ROS?” Presentation)

11
ROS is…Capabilities

Planning

Perception Execution

(Adapted from Willow Garage’s “What is ROS?” Presentation)

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

Does not include visitors


to wiki mirrors
(Singapore, China, ...)

http://wiki.ros.org/Metrics
15
ROS is a Repository

only includes publicly released


code!

ros_comm desktop-full all buildfarm


("core") ("core+tools") ("universe")
100 KLOC 400 KLOC 4000 KLOC

(From Morgan Quigley’s “ROS: An Open-Source Framework for Modern Robotics”)


16
ROS is …

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

• A Node is a single ROS-enabled program


– Most communication happens between nodes
– Nodes can run on many different devices
• One Master per system
18
ROS Architecture: Packages

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 Packages are groups of related nodes/data


– Many ROS commands are package-oriented
19
ROS Architecture: MetaPkg

ROS MetaPackage
(e.g. fanuc, ros_industrial, ros_desktop, ...)

robot
planning
camera image motion robot
interface processing logic interface
robot
model

• MetaPackages are groups of related packages


– Mostly for convenient install/deployment
20
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
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>

• Description / Usage • Source-Code link


• Tutorials • Bug Reporting
• Code / Msg API
24
ROS Answers
http://answers.ros.org

• Quick responses to Good Questions


• Search by text or tag
• Don’t re-invent the wheel!
25
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
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

 Install ROS ROS Resource


 Create Workspace Package
 Add “resources”
 Create Package
Catkin
 Create Node
Workspace
 Basic ROS Node
 Interact with other nodes
Messages
Services My Package

 Run Node Node


 rosrun
 roslaunch
 rosparam
29
Installing ROS

30
Getting ROS

http://wiki.ros.org/kinetic/Installation

31
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
Exercise 1.0

Exercise 1.0
Basic ROS Install/Setup

33
Day 1 Progression

 Install ROS (check install) ROS Resource


Create Workspace Package

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 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

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

 Install ROS ROS Resource


 Create Workspace Package
 Add “resources”
 Create Package
Catkin
 Create Node
Workspace
 Basic ROS Node
 Interact with other nodes
Messages
Services My Package

 Run Node Node


 rosrun
 roslaunch

40
Add 3rd-Party Packages
(a.k.a. “Resource” Packages)

41
Install options

Debian Packages Source Repositories


• Nearly “automatic” • Access “latest” code
• Recommended for • Most at Github.com
end-users • More effort to setup
• Stable • Unstable*
• Easy

Can mix both options, as needed

42
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
Install using Debian Packages

sudo apt install ros-kinetic-package

admin manage install all ROS pkgs ROS ROS package


permissions “.deb” new “.deb” start with ros- distribution name
Use “-” not “_”
• 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!)

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

 Install ROS ROS Resource


 Create Workspace Package
 Add “resources”
 Create Package
Catkin
 Create Node
Workspace
 Basic ROS Node
 Interact with other nodes
Messages
Services My Package

 Run Node Node


 rosrun
 roslaunch

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

• Metadata: name, description, author, license ...

50
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
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
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
Create New Package

catkin create pkg mypkg --catkin-deps dep1 dep2

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
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

 Install ROS ROS


 Create Workspace Resource
Package
 Add “resources”
 Create Package
 Create Node Catkin
 Basic ROS Node Workspace
 Interact with other nodes
Messages
Services
My Package
 Run Node
 rosrun
 roslaunch

56
ROS Nodes

57
A Simple C++ ROS Node

Simple C++ Program Simple C++ ROS Node

#include <iostream> #include <ros/ros.h>

int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
ros::init(argc, argv, “hello”);
ros::NodeHandle node;

std::cout << "Hello World!"; ROS_INFO_STREAM("Hello World!“);

return 0; return 0;
} }

58
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
“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

 Install ROS ROS Resource


 Create Workspace Package
 Add “resources”
 Create Package
Catkin
 Create Node
Workspace
 Basic ROS Node
 Interact with other nodes
Messages
Services My Package

 Run Node Node


 rosrun
 roslaunch

62
Topics and Messages

63
ROS Topics/Messages

Topics are for Streaming Data


ROS MASTER

Publisher Node Subscriber Node


/topic
Publishing
Advertises msg
/topic data
is available Listening for
Subscribed to/topic
/topic
msg … msg … msg
Onwith
channel
type /topic
msg with type msg

64
Topics vs. Messages

• Topics are channels, Messages are data types


– Different topics can use the same Message type

/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

• Many nodes can pub/sub to same topic


– comms are direct node-to-node

/camera_1/rgb
image_processing

camera_1 image … image … logger

viewer

67
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
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

• All Messages are defined by a .msg 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

• Custom message types


are defined in msg
subfolder of packages

• Modify CMakeLists.txt
to enable message
generation.

71
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
package.xml

<build_depend> message_generation </build_depend>


<build_export_depend>message_runtime</build_export_depend>
<run_depend>message_runtime</run_depend>

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

• Use rqt_msg to view:


– sensor_msgs/JointState
– trajectory_msgs/JointTrajectory
– sensor_msgs/Image
– rosgraph_msgs/Log

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)

Callback Function Message Type Message Data (IN)

void msg_callback(const PathPosition& msg) {


ROS_INFO_STREAM(“Received msg: “ << msg);
}

ros::Subscriber sub = nh.subscribe(“/topic”, 25, msg_callback);

Server Object Service Name Callback Ref

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

You might also like