Scratchpad - ROS 1

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


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

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;


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