Skip to content

carjavi/ROS-Command-line-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

ROS Command-line tools

Jun 23

Ubuntu

ROS

© 2004 Foo Corporation

ROS Cheat Sheet


Filesystem Command-line Tools

Command

Action

Example usage and subcommand examples

rospack/rosstack

A tool inspecting packages/stacks.

$ rospack find [package]

roscd

Changes directories to a package or stack.

$ roscd [package[/subdir]]

rosls

Lists package or stack information.

$ rosls [package[/subdir]]

roscreate-pkg

Creates a new ROS package.

$ roscreate-pkg [package name]

roscreate-stack

Creates a new ROS stack.

$ ros command [parameter]

rosdep

Installs ROS package system dependencies.

rosdep install [package]

rosmake

Builds a ROS package.

$ rosmake [package]

roswtf

Displays a errors and warnings about a running ROS system or launch file.

$ roswtf or roswtf [file]

rxdeps

Displays package structure and dependencies.

$ rxdeps [options]

rosed

It allows you to directly edit a file within a package by package name rather than having to know the package path.

Usage:

$ rosed packagename filename

Example:

$ rosed roscpp ros.h



ROS commands summary

Command

Action

Example usage and subcommand examples

roscore

This starts the Master

$ roscore

rosrun

This runs an executable program and creates nodes

$ rosrun [package name] [executable name]

$ rosrun package executable

rosnode

This shows information about nodes and lists the active nodes

$ rosnode info [node name]

$ rosnode <subcommand>

$ rosnode list List active nodes.

$ rosnode ping [node name] Test connectivity to node.

$ rosnode ping --all Ping all nodes.

$ rosnode info [node name] Print information about a node.

$ rosnode machine List nodes running on a particular ma- chine.

$ rosnode kill [node name] Kills a running node.

$ rosnode kill -a Kill all nodes:

rostopic

This shows information about ROS topics

$ rostopic <subcommand> <topic name>

Subcommands: echo, info, and type

$ rostopic echo Print messages to screen.

$ rostopic list Print information about active topics.

$ rostopic pub Publish data to topic.

$ rostopic type Print topic type.

$ rostopic find Find topics by type.

$ rostopic hz Display publishing rate of topic.

$ rostopic bw Display bandwidth used by topic.

Example:

Publish hello at 10 Hz: $ rostopic pub -r 10 /topic name std msgs/String hello

Clear the screen after each message is published: $ rostopic echo -c /topic name

Display messages that match a given Python expression: $ rostopic echo --filter "m.data=='foo'" /topic name

Pipe the output of rostopic to rosmsg to view the msg type: $ rostopic type /topic name | rosmsg show

rosmsg

This shows information about the message types

$ rosmsg <subcommand> [package name]/ [message type]

Subcommands: show, type, and list

$ rosmsg show Display the fields in the msg.

$ rosmsg package List all the messages in a package.

$ rosnode packages List all the packages with messages.

$ rosmsg users sensor msgs/CameraInfo List the files using sensor msgs/CameraInfo.

roslaunch

Starts ROS nodes locally and remotely via SSH, as well as setting parameters on the parameter server.

Launch on a different port: $ roslaunch -p 1234 package filename.launch

Launch a file in a package: $ roslaunch package filename.launch

Launch on the local nodes: $ roslaunch --local package filename.launch

rosservice

This displays the runtime information about various services and allows the display of messages being sent to a topic

$ rosservice <subcommand> [service name]

Subcommands: args, call, find, info, list, and type

rosparam

This is used to get and set parameters (data) used by nodes. A tool for getting and setting ROS parameters on the parameter server using YAML-encoded files.

$ rosparam <subcommand> [parameter]

Subcommands: get, set, list, and delete

$ rosparam set Set a parameter.

$ rosparam get Get a parameter.

$ rosparam load Load parameters from a file.

$ rosparam dump Dump parameters to a file.

$ rosparam delete Delete a parameter.

$ rosparam list List parameter names.

Example:

List all the parameters in a namespace: $ rosparam list /namespace

Setting a list with one as a string, integer, and oat: $ rosparam set /foo "['1', 1, 1.0]"

Dump only the parameters in a specific namespace to file: $ rosparam dump dump.yaml /namespace

rosservice

A tool for listing and querying ROS services.

$ rosservice list Print information about active services.

$ rosservice node Print the name of the node providing a service.

$ rosservice call Call the service with the given args.

$ rosservice args List the arguments of a service.

$ rosservice type Print the service type.

$ rosservice uri Print the service ROSRPC uri.

$ rosservice find Find services by service type.

Examples:

Call a service from the command-line: $ rosservice call /add two ints 1 2

Pipe the output of rosservice to rossrv to view the srv type: $ rosservice type add two ints | rossrv show

Display all services of a particular type: $ rosservice find rospy tutorials/AddTwoInts



Logging Command-line Tools

Command

Action

Example usage and subcommand examples

rosbag

This is a set of tools for recording from and playing back to ROS topics.

Record all topics: $ rosbag record -a

Record select topics: $ rosbag record topic1 topic2

rosbag play

will take the contents of one or more bagfile, and play them back in a time-synchronized fashion.

Replay all messages without waiting: $ rosbag play -a demo log.bag

Replay several bag files at once: $ rosbag play demo1.bag demo2.bag



Graphical Tools

Command

Action

Example usage and subcommand examples

rxgraph

Displays a graph of the ROS nodes that are currently running,as well as the ROS topics that connect them.

$ rxgraph

rxplot

A tool for plotting data from one or more ROS topic fields using matplotlib.

To graph the data in different plots: $ rxplot /topic1/field1 /topic2/field2

To graph the data all on the same plot: $ rxplot /topic1/field1,/topic2/field2

To graph multiple fields of a message: $ rxplot /topic1/field1:field2:field3

rxbag

A tool for visualizing, inspecting, and replaying histories (bag files) of ROS messages.

$ rxbag bag file.bag

rxconsole

A tool for displaying and filtering messages published on rosout.

$ rxconsole



Workspaces

Create workspace

mkdir catkin_ws
cd catkin_ws
wstool init src
catkin_make
source devel/setup.bash

Source space (/src): contains the source code of catkin packages. Subfolder of this are the ROS packages you want to add to your system. All your stuff goes here!

Build space (/build): space where cmake is invoked to build the catkin packages cmake and catkin keep their cache information and other intermediate files here. Not where catkin_make is invoked!

Devel space (/devel): Space where built targets are placed prior to being installed

Add repo to workspace

roscd
cd ../src
wstool set repo_name --git http://github.com/org/repo_name.git --version=indigo-devel
wstool up

Resolve dependencies in workspace

sudo rosdep init # only once
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=indigo -y


Packages

Create a package

catkin_create_pkg package_name [dependencies ...]

Package folders

include/package_name   # C++ header files
src                    # Source files, Python libraries in subdirectories
scripts                # Python nodes and scripts
msg, srv, action       # Message, Service, and Action definitions

Release repo packages

catkin_generate_changelog
# review & commit changelogs"
catkin_prepare_release
bloom-release --track indigo --ros-distro indigo repo_name


Running System

Run ROS using plain

roscore

Running roslaunch will run its own roscore automatically

roslaunch my_package package_launchfile.launch

Nodes, topics, messages

rosnode list
rostopic list
rostopic echo cmd_vel
rostopic hz cmd_vel
rostopic info cmd_vel
rosmsg show geometry_msgs/Twist

Remote connection - master’s ROS environment

export ROS_IP or ROS_HOSTNAME  #set to this machine’s network address
export ROS_MASTER_URI          #set to URI containing that IP or hostname

Remote connection - your environment

export ROS_IP or ROS_HOSTNAME   #set to your machine’s network address
export ROS_MASTER_URI           #set to the URI from the master

To debug, check ping from each side to the other, run roswtf on each side

ROS Console

vi $HOME/.ros/config/rosconsole.config log4j.logger.ros.package_name=DEBUG

Adjust using rqt_logger_level and monitor via rqt_console. Use the roslaunch --screen flag to force all node output to the screen, as if each declared had the output="screen" attribute.



Developer Commands

Name Purpose
catkin_make Build all projects in workspace. Run from root folder. Example: ~/catkin_ws/.
catkin_make clean Clean all projects in workspace. Run from root folder. Example: ~/catkin_ws/.


Setting up your environment

ROS_MASTER_URI

Set the address of the robot.

export ROS_MASTER_URI=http://<robot ip>:11311/

ROS_HOSTNAME

Should be set to the PC you are as the workstation.

export ROS_HOSTNAME=<workstation IP>

Bags

Para crear un bag que salve todos los mensajes

rosbag record [-O bag_file] -a

Para salvar unos topics en particular:

rosbag record [-O bag_file] [topic_name1] [topic_name2] ...

La grabación se termina cuando se pulsa ctrl-c


Pasar de .bag.active a .bag

rosbag reindex *.bag.active
rosbag fix *.bag.active new_name.bag

Cierre seguro del rosbag

rosnode kill /vt/rosbag/record


Examples Commands

$ rostopic find sensor_msgs/String // you want to find all the topics of a certain message type

More info: http://wiki.ros.org/ROS/CommandLineTools

ROS2: https://osrf.github.io/ros2multirobotbook/intro.html

ROS1 & NodeJs: http://wiki.ros.org/rosnodejs


Tips

📝 Note: Cuando corremos un comando echo -c , el topico se mostrara sin salto de linea



Copyright © 2022 carjavi.
www.instintodigital.net
[email protected]

www.instintodigital.net

About

ROS Command-line tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published