Scratchpad - ROS 1

A scratchpad for common pitfalls, commands, and shortcuts when using ROS 1.


How to debug launchfile execution:

See the following CLI arguments

    Delay the launch until a roscore is detected.

    Launch of the local nodes only. Nodes on remote machines will not be run.

    Force all node output to screen. Useful for node debugging.

    Force all node output to log file. Also useful for node debugging.

    Enable verbose printing. Useful for tracing roslaunch file parsing.

    Print parameters in launch file in YAML format. 

Visualise topics/services/images etc from the command line (without X/OpenGL):

Use rosshow

ps -ef | grep -E ros\|melodic | awk '{print $2}' | xargs kill -9

How do I debug a URDF file and its transforms?

Use the urdfdom tools (independent package)

apt-get install liburdfdom-tools graphviz
urdf_to_graphiz <path-to-your-urdf

You can also use the xacro package and the check_urdf tool:

rosrun xacro `rospack find pr2_description`/robots/pr2.urdf.xacro -o /tmp/pr2.urdf
check_urdf pr2.urdf

[ERROR]: Creation of publisher failed: unknown error handler name ‘rosmsg’

There is a bug in genpy versions <= 0.6.13, try apt-get upgradeing it


Error: RQT doesn't list plugins on startup:

Remove its cache, then it works: rm ~/.config/


I’m getting the following error: multiple files named ... in package

Disable install space.

catkin clean
catkin build <package-name> --no-install

Run catkin for the package in the current directory:

catkin build --this -DCMAKE...

Publish to /move_base_simple/goal:

rostpic pub /move_base_simple/goal geometry_msgs/PoseStamped '{header: {stamp: now, frame_id: "map"}, pose: {position: {x: 1.0, y: 0.0, z: 0.0}, orientation: {w: 1.0}}}'


image_transport plugins - how to setup:

sudo apt-get install ros-melodic-*-image-transport
rosrun image_transport republish compressed /in/compressed:=/<path-to-topic>/compressed_image0  "raw" out:=/<path-to-topic>/image0


Use ninja when building with catkin_make

catkin_make --use-ninja --cmake-args -DCMAKE_BUILD_TYPE=Release

Adjust logger verbosity - inspect “debug” messages:

Run the rqt_logger_level GUI:

rosrun rqt_logger_level rqt_logger_level

Alternatively adjust it using the service call:

rosservice list
rosservice call /rviz_123/get_loggers <tab><tab>
rosservice call /rviz_123/set_logger_level <tab><tab>

Adjust the logger verbosity from the start of the run

Define your own ROSCONSOLE_CONFIG_FILE variable + config file.

rosconsole will load a config file from $ROS_ROOT/config/rosconsole.config when it initializes.

rosconsole also lets you define your own configuration file that will be used by log4cxx, defined by the ROSCONSOLE_CONFIG_FILE environment variable. Anything defined in this config file will override the default config file.

A simple example:

# Set the default ros output to warning and higher
# Override my package to output everything

List all available plugins of a particular package

rospack plugins --attrib=plugin nav_core

See also:

Have detailed output for debugging

# Try one of the following
export ROSCONSOLE_FORMAT='[${severity}] [${time}]: ${message}' # default
export ROSCONSOLE_FORMAT='${severity} | ${time} | ${message}'
export ROSCONSOLE_FORMAT='${severity} | ${node} | ${time} | ${message} | ${file}:${line}'
export ROSCONSOLE_FORMAT='${severity} | ${node} - ${thread} | ${time} | ${message} | +${line} ${file}'

ROS Unittesting

If you use only gtest then you have to add your target like this:

catkin_add_gtest(UT_${PROJECT_NAME} test/test_file.cpp

However, if you also use gmock then you should use catkin_add_gmock instead!

catkin_add_gmock(UT_${PROJECT_NAME} test/test_file.cpp

To run all the tests:

catkin_make run_tests

Notice that the previous call will return a 0 (success) error code in any case even if the tests fail.

To get a summary and get the appropriate error code you can either run catkin_test_results or the CTest target test:

catkin_make test



Get all ROS topics programmatically

Query the master; from C++ use something like this:

#include <ros/master.h>
// see /opt/ros/<ros-version>/include/ros/master.h for more details on this
// struct
ros::master::V_TopicInfo allTopics;


Remap a topic in the same TF Tree

<node name="remapper" pkg="tf_remapper_cpp" type="tf_remap">
  <rosparam param="mappings">[{old: /slamcore/map, new: /kalimera}]</rosparam>
  <param name="old_tf_topic_name" value="/tf" />
  <param name="new_tf_topic_name" value="/tf" />

ROS REPs of interest

  • REP-117:
    • Readings too close to measure -> -Inf
    • Invalid measurements -> ` NaN`
    • Readings of no return -> +Inf
  • REP-118
    • Representing depth data
    • Use 32-bit Float
  • REP-105
    • Frames of reference convention
    • Relevant answer with the rationale: