0% found this document useful (0 votes)
83 views27 pages

ROS 2 Terminology and Commands Guide

Uploaded by

Juanse munoz
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)
83 views27 pages

ROS 2 Terminology and Commands Guide

Uploaded by

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

ROBOTICS

PLATFORMS
LEVEL 1
Gabriel Diaz
Email: [Link]@[Link]
ROS Terminology
ROS
Node →
Node →AA process
process that
that performs
performs computation.
computation.

Package →
Package →AA collection
collection of
of nodes,
nodes, libraries,
libraries, and
and configuration
configuration files.
files.

Message →
◦ Message → Data
Data structure
structure used
used for
for communication
communication (e.g.
(e.g. std_msgs/String).
std_msgs/String).

Topic →
Topic →AA named
named bus
bus for
for publishing
publishing and
and subscribing
subscribing messages.
messages.

Publisher →
Publisher →AA node
node that
that sends
sends messages
messages on
on a
a topic.
topic.

Subscriber →
Subscriber →AA node
node that
that receives
receives messages
messages from
from a
a topic.
topic.

Service →
◦ Service → Request/response
Request/response communication
communication between
between nodes.
nodes.

◦ Action
Action →
→ Asynchronous
Asynchronous service
service with
with feedback
feedback (used
(used for
for long
long tasks).
tasks).

Parameter →
Parameter → Runtime
Runtime configuration
configuration variable
variable for
for a
a node.
node.
ROS Terminology
ROS
Colcon →
Colcon → The
The build
build system
system for
for ROS
ROS 2
2 workspaces.
workspaces.

Workspace →
Workspace → Directory
Directory containing
containing ROS
ROS packages.
packages.

RMW →
◦ RMW → ROS
ROS Middleware
Middleware interface
interface (e.g.
(e.g. Fast
Fast DDS,
DDS, CycloneDDS).
CycloneDDS).

Launch File
Launch File →
→ XML
XML or
or Python
Python script
script to
to start
start multiple
multiple nodes.
nodes.

Interface →
Interface → Definition
Definition of
of messages,
messages, services,
services, or
or actions.
actions.




Key ROS Files &
Key & Execution
Execution Concepts
Concepts
Run →
Run → Execute
Execute a
a single
single node
node from
from a
a package.
package.

Launch →
Launch → Start
Start multiple
multiple nodes
nodes together,
together, with
with configuration
configuration (YAML/parameters).
(YAML/parameters).

Bag →
Bag → Record
Record and
and replay
replay ROS
ROS data
data streams.
streams.

[Link] →
[Link] → Build
Build configuration
configuration file
file for
for your
your package.
package.

[Link] →
[Link] → Metadata
Metadata and
and dependencies
dependencies for
for your
your package.
package.

[Link] →
[Link] → Configures
Configures the
the ROS
ROS environment
environment variables.
variables.

.bashrc →
.bashrc → Personal
Personal shell
shell configuration,
configuration, where
where you
you usually
usually source
source ROS
ROS setup.
setup.

(Optional additions
(Optional additions if
if you
you want
want a
a bit
bit more
more depth)
depth)

install/ and
install/ and build/
build/ →
→ Generated
Generated after
after building
building your
your workspace
workspace with
with colcon.
colcon.

launch files
launch files →
→ XML
XML or
or Python
Python files
files that
that automate
automate execution
execution of
of multiple
multiple nodes.
nodes.
ROS Execution Commands
ROS Commands
Command Importance Command Origin Description

ros2 ⭐⭐⭐ ros + run Base command for interacting with ROS 2 CLI tools.

ros2 run ⭐⭐⭐ ros2 + run Executes a specific node from a given package.

ros2 launch ⭐⭐⭐ ros2 + launch Launches multiple nodes and configurations using a .[Link] file.

ros2 doctor ⭐⭐ ros2 + doctor Diagnoses common issues in the ROS 2 environment.

ros2 pkg ⭐⭐ ros2 + package Inspects package information (location, executables, etc).

ros2 bag record ⭐⭐ ros2 + bag +


record
Records topic data into a bag file for later playback.

ros2 bag play ⭐⭐ ros2 + bag + play Replays recorded topic data for testing or debugging.

ros2 daemon start/stop ⭐ ros2 + daemon Starts/stops the ROS 2 background service that caches system info.

ros2 workspace (alias via colcon) ⭐ workspace tools Helps to check and interact with the active workspace.
ROS Information Commands
ROS Commands
Command Importance Command Origin Description

ros2 topic ⭐⭐⭐ ros2 + topic Inspect and interact with topics (list, echo, info, pub).

ros2 service ⭐⭐⭐ ros2 + service Inspect and call services.

ros2 node ⭐⭐⭐ ros2 + node Explore information about active nodes.

ros2 param ⭐⭐ ros2 + parameter Manage parameters (list, set, get).

ros2 bag info ⭐⭐ ros2 + bag + info View metadata of recorded bag files.

ros2 interface ⭐ ros2 + interface Show available message/service/action definitions.

ros2 wtf (alias: doctor) ⭐ “What the failure” 😅 Debug tool for identifying ROS 2 issues.
Colcon Commands
Colcon Commands
Command Importance Description

colcon build ⭐⭐⭐ Build the workspace and generate install files.

colcon graph ⭐⭐ Show the dependency graph between packages.

colcon info ⭐ Display package information in the workspace.

colcon test ⭐⭐ Run tests defined for packages.

colcon test-result ⭐⭐ Display results of the tests executed.

colcon version-check ⭐ Check for newer versions of dependencies.

colcon clean (extra) ⭐ Clean build, log, and install directories. Useful for fresh rebuilds.
Environment Setup
Environment Setup in
in ROS
ROS 2:
2: source
source and
and .bashrc
.bashrc
What source
What source does
does (and
(and why
why ROS
ROS needs
needs it)
it)
source <file>
source <file> runs
runs a
a script
script in
in the
the current
current shell
shell (it
(it does
does not
not spawn
spawn aa new
new process).
process).
In ROS
In ROS 2,
2, sourcing
sourcing aa [Link]
[Link] exports
exports environment
environment variables
variables so
so the
the shell
shell can
can

find:
find:

Executables (PATH)
Executables (PATH)

Libraries (LD_LIBRARY_PATH)
Libraries (LD_LIBRARY_PATH)

Python modules
Python modules (PYTHONPATH)
(PYTHONPATH)
Build/overlay metadata
Build/overlay metadata (AMENT_PREFIX_PATH,
(AMENT_PREFIX_PATH, COLCON_PREFIX_PATH)
COLCON_PREFIX_PATH)
ROS-specific variables
ROS-specific variables (ROS_DISTRO,
(ROS_DISTRO, ROS_VERSION,
ROS_VERSION, optionally
optionally
RMW_IMPLEMENTATION, ROS_DOMAIN_ID)
RMW_IMPLEMENTATION, ROS_DOMAIN_ID)
Without sourcing,
Without sourcing, commands
commands like like ros2,
ros2, rviz2,
rviz2, or
or packages
packages from
from your
your workspace
workspace
won’t be
won’t be discoverable.
discoverable.
Environment Setup
Environment Setup in
in ROS
ROS 2:
2: source
source and
and .bashrc
.bashrc
Which files
Which files to
to source
source (order
(order matters)
matters)
Underlay (Global
Underlay (Global ROS
ROS install):
install):
/opt/ros/jazzy/[Link]
/opt/ros/jazzy/[Link]

Loads the
Loads the base
base ROS
ROS 22 environment
environment (binaries,
(binaries, core
core packages).
packages).

Overlay (Your
Overlay (Your workspace
workspace after
after build):
build):

~/ras_ws/install/[Link]
~/ras_ws/install/[Link]

Extends the
Extends the environment
environment to to include
include your
your packages
packages first
first (this
(this is
is how
how overlays
overlays
work).
work).
Order rule:
Order rule: Always
Always source
source underlay
underlay first,
first, then
then overlay
overlay (base
(base → → your
your workspace).
workspace).
This ensures
This ensures your
your packages
packages take
take precedence
precedence over
over system
system ones.
ones.
Environment Setup
Environment Setup in
in ROS
ROS 2:
2: source
source and
and .bashrc
.bashrc
What is
What is .bashrc?
.bashrc?
A per-user
A per-user shell
shell startup
startup file
file executed
executed for
for interactive
interactive non-login
non-login shells
shells (most
(most new
new
terminal tabs).
terminal tabs).

A good
A good place
place to
to persist
persist your
your source
source commands
commands so so you
you don’t
don’t have
have to
to run
run them
them

manually each
manually each time.
time.

Related files:
Related files: .bash_profile
.bash_profile // .profile
.profile (login
(login shells);
shells); for
for zsh
zsh use
use .zshrc
.zshrc and
and

[Link].
[Link].
Environment Setup
Environment Setup in
in ROS
ROS 2:
2: source
source and
and .bashrc
.bashrc
How to
How to add
add ROS
ROS sourcing
sourcing to
to .bashrc
.bashrc
Add these
Add these lines
lines to
to your
your ~/.bashrc
~/.bashrc (uses
(uses safe
safe checks
checks so
so it
it won’t
won’t break
break if
if paths
paths
don’t exist):
don’t exist):

# ROS
# ROS 22 base
base (underlay)
(underlay)

source /opt/ros/jazzy/[Link]
source /opt/ros/jazzy/[Link]

Apply changes
Apply changes to
to the
the current
current terminal:
terminal:

source ~/.bashrc
source ~/.bashrc
How to
How to verify
verify it
it worked
worked
echo $ROS_DISTRO
echo $ROS_DISTRO
which ros2
which ros2
Running Nodes
Running Nodes in
in ROS
ROS 2:
2: ros2
ros2 run
run
The command:
The command:
ros2 run
ros2 run <package_name>
<package_name> <executable_name>
<executable_name>
Explanation:
Explanation:
ros2 run
ros2 run is
is used
used to
to start
start (execute)
(execute) a a node
node from
from an
an installed
installed ROS
ROS 2
2 package.
package.
It requires:
It requires:
A package
A package that
that has
has been
been built
built and
and installed
installed (in
(in an
an underlay
underlay or
or overlay).
overlay).
An executable
An executable registered
registered in
in that
that package’s
package’s [Link]
[Link] (or
(or [Link]
[Link] for
for Python).
Python).
When you
When you run
run it,
it, ROS
ROS 2:
2:
Finds the
Finds the package
package inin your
your AMENT_PREFIX_PATH.
AMENT_PREFIX_PATH.
Locates the
Locates the executable
executable in
in its
its install/
install/ folder.
folder.
Launches it
Launches it with
with the
the environment
environment setset up.
up.
Running Nodes
Running Nodes in
in ROS
ROS 2:
2: ros2
ros2 run
run
Example:
Example:
ros2 run
ros2 run turtlesim
turtlesim turtlesim_node
turtlesim_node
Breaking down
Breaking down the
the example:
example:
turtlesim →
turtlesim → the
the package
package name.
name.
This is
This is a
a demo
demo package
package that
that provides
provides a a simple
simple 2D
2D turtle
turtle simulator.
simulator.
turtlesim_node →
turtlesim_node → the
the executable
executable name.
name.
This is
This is the
the node
node that
that opens
opens thethe graphical
graphical window
window with
with aa turtle
turtle you
you can
can control.
control.
What happens
What happens whenwhen you
you run
run it:
it:
A new
A new ROS
ROS 2 2 node
node starts.
starts.
A window
A window appears
appears showing
showing a a turtle
turtle in
in a
a colored
colored background.
background.
The node
The node isis now
now publishing
publishing andand subscribing
subscribing toto topics
topics (we’ll
(we’ll explore
explore this
this in
in the
the next
next
lessons).
lessons).
Running Nodes
Running Nodes in
in ROS
ROS 2:
2: ros2
ros2 run
run
Things to
Things to keep
keep in
in mind
mind
If ROS
If ROS cannot
cannot find
find the
the package,
package, check:
check:
Did you
Did you source
source the
the right
right [Link]?
[Link]?
Did you
Did you build
build your
your workspace
workspace with
with colcon
colcon build?
build?
ros2 run
ros2 run is
is for
for executables
executables only.
only.
If you
If you need
need to
to start
start multiple
multiple nodes
nodes with
with parameters,
parameters, use
use a
a launch
launch file
file instead
instead (coming
(coming
later).
later).
ROS 2
ROS 2 NODE
NODE COMMANDS
COMMANDS

ros2 node
ros2 node list:
list: Lists
Lists all
all active
active nodes
nodes currently
currently running
running in
in the
the ROS
ROS 2
2 graph
graph
ros2 node
ros2 node info
info <node_name>:
<node_name>: ShowsShows detailed
detailed information
information about
about a
a specific
specific node:
node:
Subscribed topics
Subscribed topics
Published topics
Published topics
Actions.
Actions.
ROS 2
ROS 2 NODE
NODE Commands
Commands Example
Example

According to
According to the
the previous
previous slide,
slide, run
run the
the turtlesim
turtlesim node:
node:
ros2 run
ros2 run turtlesim
turtlesim turtlesim_node
turtlesim_node
Open a
Open a new
new terminal,
terminal, source
source ROS
ROS again:
again:
Step 1:
Step 1: List
List active
active nodes
nodes
ros2 node
ros2 node list
list
Step 2:
Step 2: Inspect
Inspect the
the turtlesim
turtlesim node
node
ros2 node
ros2 node info
info /turtlesim
/turtlesim
ROS 2
ROS 2 Topic
Topic Commands
Commands
ros2 topic
ros2 topic list
list →
→ Shows
Shows all
all active
active topics
topics in
in the
the ROS
ROS 22 graph.
graph.
ros2 topic
ros2 topic info
info <topic>
<topic> →
→ Displays
Displays detailed
detailed information
information about
about aa topic
topic (message
(message
type, publishers,
type, publishers, subscribers,
subscribers, QoS).
QoS).
ros2 topic
ros2 topic echo
echo <topic>
<topic> →
→ Prints
Prints the
the messages
messages published
published onon a
a topic
topic in
in real
real time.
time.
ros2 topic
ros2 topic pub
pub <topic>
<topic> <msg_type>
<msg_type> <data>
<data> → → Publishes
Publishes a a custom
custom message
message to to a
a
topic (testing
topic (testing or
or simulation).
simulation).
ros2 topic
ros2 topic hz
hz <topic>
<topic> →→ Measures
Measures the
the publish
publish rate
rate (frequency)
(frequency) of
of messages
messages in in Hz.
Hz.
ros2 topic
ros2 topic bw
bw <topic>
<topic> →
→ Calculates
Calculates the
the bandwidth
bandwidth usage
usage of
of messages
messages onon a
a topic.
topic.
ROS 2
ROS 2 Topic
Topic Commands
Commands Example
Example
Run turtlesim
Run turtlesim node
node (Terminal
(Terminal 1)1)
ros2 run
ros2 run turtlesim
turtlesim turtlesim_node
turtlesim_node
Run teleop
Run teleop to
to control
control turtle
turtle (Terminal
(Terminal 2)
2)
ros2 run
ros2 run turtlesim
turtlesim turtle_teleop_key
turtle_teleop_key
# List all
# List all active
active topics
topics
ros2 topic
ros2 topic list
list
ros2 topic
ros2 topic info
info /turtle1/cmd_vel
/turtle1/cmd_vel
ros2 topic
ros2 topic echo
echo /turtle1/cmd_vel
/turtle1/cmd_vel
ros2 topic
ros2 topic pub
pub /turtle1/cmd_vel
/turtle1/cmd_vel geometry_msgs/msg/Twist
geometry_msgs/msg/Twist "{linear:
"{linear: {x:
{x: 2.0},
2.0},
angular: {z:
angular: {z: 1.0}}"
1.0}}"
ros2 topic
ros2 topic hz
hz /turtle1/cmd_vel
/turtle1/cmd_vel
ROS 2
ROS 2 Service
Service COMMANDS
COMMANDS

ros2 service
ros2 service list
list →
→ Shows
Shows all
all active
active services
services in
in the
the system.
system.
ros2 service
ros2 service type
type <service>
<service> →
→ Displays
Displays the
the type
type of
of a
a given
given service.
service.
ros2 service
ros2 service find
find <type>
<type> →→ Lists
Lists all
all services
services of
of a
a specific
specific type.
type.
ros2 service
ros2 service call
call <service>
<service> <type>
<type> <args>
<args> → → Calls
Calls a
a service
service with
with arguments.
arguments.
ROS 2
ROS 2 Service
Service Commands
Commands Example
Example

ros2 run
ros2 run turtlesim
turtlesim turtlesim_node
turtlesim_node
ros2 service
ros2 service list
list
ros2 service
ros2 service type
type /reset
/reset
ros2 service
ros2 service find
find std_srvs/srv/Empty
std_srvs/srv/Empty
ros2 service
ros2 service call
call /reset
/reset std_srvs/srv/Empty
std_srvs/srv/Empty "{}"
"{}"
ros2 service
ros2 service call
call /turtle1/teleport_absolute
/turtle1/teleport_absolute turtlesim/srv/TeleportAbsolute
turtlesim/srv/TeleportAbsolute "{x:
"{x:
5.0, y:
5.0, y: 5.0,
5.0, theta:
theta: 1.57}"
1.57}"
ROS Parameters
ROS Parameters COMMANDS
COMMANDS
ros2 param
ros2 param list ➝ List
list ➝ List all
all available
available parameters
parameters ofof a
a node.
node.
ros2 param
ros2 param get
get <node_name>
<node_name> <parameter_name>
<parameter_name> ➝ ➝ Get
Get the
the current
current value
value of
of a
a
parameter.
parameter.
ros2 param
ros2 param set
set <node_name>
<node_name> <parameter_name> <value> ➝
<parameter_name> <value> Change the
➝ Change the value
value
of a
of a parameter
parameter atat runtime.
runtime.
ros2 param
ros2 param dump <node_name> ➝
dump <node_name> Save all
➝ Save all parameters
parameters of
of a
a node
node to
to a
a YAML
YAML
file.
file.
ros2 param
ros2 param load
load <node_name> <[Link]> ➝
<node_name> <[Link]> Load parameters
➝ Load parameters from
from aa YAML
YAML
file into
file into a
a node.
node.
ROS 2
ROS 2 Parameters
Parameters Commands
Commands Example
Example

ros2 run
ros2 run turtlesim
turtlesim turtlesim_node
turtlesim_node
ros2 param
ros2 param list
list /turtlesim
/turtlesim
ros2 param
ros2 param get
get /turtlesim
/turtlesim background_r
background_r
ros2 param
ros2 param set
set /turtlesim
/turtlesim background_r
background_r 255
255
ros2 param
ros2 param set
set /turtlesim
/turtlesim background_g
background_g 255
255
ros2 param
ros2 param set
set /turtlesim
/turtlesim background_b
background_b 255
255
ros2 service
ros2 service call
call /clear
/clear std_srvs/srv/Empty
std_srvs/srv/Empty {}
{}
ros2 param
ros2 param dump
dump /turtlesim
/turtlesim >> turtle_params.yaml
turtle_params.yaml
ros2 param
ros2 param load
load /turtlesim
/turtlesim turtle_params.yaml
turtle_params.yaml
Workspace Folder
Workspace Folder
colcon
workspace

install log
Creating Workspace
Creating Workspace in
in ROS
ROS 2
2

A workspace
A workspace in in ROS
ROS 22 is
is a
a directory
directory where
where you
you develop,
develop, organize,
organize, and
and build
build your
your packages.
packages.
It acts
It acts as
as your
your “workshop”
“workshop” forfor ROS
ROS 2 2 projects.
projects.
Every workspace
Every workspace contains
contains atat least:
least:
src/ →
src/ → source
source folder
folder where
where all
all packages
packages are
are placed.
placed.
install/ log/
install/ log/ and
and build/
build/ →→ automatically
automatically created
created after
after compilation.
compilation.
Creating Workspace
Creating Workspace in
in ROS
ROS 2
2
Minimum steps
Minimum steps toto create
create aa workspace:
workspace:
creates the
creates the workspace
workspace andand source
source folder.
folder.
The root
The root folder
folder for
for your
your ROS
ROS 2 2 project.
project.
mkdir -p
mkdir -p ~/ros2_ws/src
~/ros2_ws/src
Go to
Go to the
the workspace:
workspace:
You always
You always work
work from
from the
the root
root ofof the
the workspace.
workspace.
cd ~/ros2_ws
cd ~/ros2_ws
Compile the
Compile the workspace
workspace
Use colcon
Use colcon build
build to
to build
build all
all packages
packages inside
inside src/.
src/.
If src/
If src/ is
is empty,
empty, the
the build
build still
still creates
creates the
the necessary
necessary structure.
structure.
colcon build
colcon build
Source the
Source the workspace:
workspace:
Updates your
Updates your current
current terminal
terminal environment
environment to to recognize
recognize the
the packages.
packages.
Without sourcing,
Without sourcing, ROS
ROS 22 won’t
won’t find
find your
your newly
newly built
built packages.
packages.
source install/[Link]
source install/[Link]
Practical Example
Practical Example –– Creating
Creating a
a Workspace
Workspace

# Step
# Step 1:
1: Create
Create the
the workspace
workspace and
and src
src folder
folder
mkdir -p
mkdir -p ~/ras_ws/src
~/ras_ws/src
# Step
# Step 2:
2: Move
Move into
into the
the workspace
workspace
cd ~/ras_ws
cd ~/ras_ws
# Step
# Step 3:
3: Build
Build the
the workspace
workspace
colcon build
colcon build
# Step
# Step 4:
4: Source
Source it
it
source install/[Link]
source install/[Link]
References

ROS 2
ROS 2 Jazzy
Jazzy Documentation
Documentation (index)
(index)
ROS 2
ROS 2 Tutorials
Tutorials
Concepts: Nodes,
Concepts: Nodes, Topics,
Topics, Services,
Services, Parameters
Parameters
Turtlesim Package
Turtlesim Package
Colcon Build
Colcon Build System
System

You might also like