Scratchpad - ROS 1

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

Questions/Answers

How to debug launchfile execution:

See the following CLI arguments

--wait
    Delay the launch until a roscore is detected.

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

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

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

-v
    Enable verbose printing. Useful for tracing roslaunch file parsing.

--dump-params
    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 xacro.py `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

Source: https://answers.ros.org/question/360537/unknown-error-handler-name-rosmsg/?answer=360643#post-id-360643

Error: RQT doesn't list plugins on startup:

Remove its cache, then it works: rm ~/.config/ros.org/rqt_gui.ini

Source: https://answers.ros.org/question/91231/rqt-plugin-not-listedfound-in-list-returned-by-rqt-list-plugins/

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

Source: https://answers.ros.org/question/47973/publishing-to-move_base_simplegoal/

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

Source: http://wiki.ros.org/image_transport/Tutorials/ManagingPlugins

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
log4j.logger.ros=WARN
# Override my package to output everything
log4j.logger.ros.my_package_name=DEBUG

List all available plugins of a particular package

rospack plugins --attrib=plugin nav_core

See also: http://wiki.ros.org/pluginlib

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

}

Source: https://github.com/ros/catkin/issues/576

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::master::getTopics(allTopics);

Source: https://answers.ros.org/question/256251/how-to-obtain-list-of-all-available-topics-python/?answer=256260#post-id-256260

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" />
</node>

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: https://answers.ros.org/question/226916/rep-105-and-robot_localization/