Friday, June 7, 2024

ROS republish node command and roslaunch equivalent

I've been working on ROS and recently had to subscribe to a topic that had a theora_image_transport/Packet message type.  I'm also using rospy library to use python to interface with ROS.


  • Ubuntu 20.04.6 LTS
  • ROS noetic
  • Python 3.8.10

Theora_image_transport is a plugin package for image_transport, and because of that, is not yet supported with Python.  I ran a republish node from theora to compressed image format in order to save the files using python to the file system.

The original theora topic name is /cherryshoe/camera/image_raw/theora.  The republish node is named /cherryshoe/repub/camera/image_compressed.  This node publishes images in the sensor_msgs/CompressedImage type.

Republish node command with rosrun

rosrun image_transport republish theora in:=/cherryshoe/camera/image_raw compressed out:=/cherryshoe/repub/camera/image_compressed

Republish node using roslaunch

This assumes catkin has been installed, the environment has been sourced, and a catkin workspace has been created and built.  Let's call the catkin package name "cherry_shoe_package".  I created a repub_theora_to_compressed.launch file in the same location as the package.xml file.

    This creates republish nodes from a theora topic to compressed image topic.
    The available parameters are: format, jpeg_quality, jpeg_progressive, jpeg_optimize, jpreg_rest, jpeg_restart_interval, png_level
    These are currently configured with jpeg default values.
    <node pkg="image_transport" type="republish" name="republish_camera"
        args="theora in:=/cherryshoe/camera/image_raw compressed out:=/cherryshoe/repub/camera/image_compressed"
        <rosparam param="/cherryshoe/repub/camera/image_compressed/compressed/format">jpeg</rosparam>
        <rosparam param="/cherryshoe/repub/camera/image_compressed/compressed/jpeg_quality">80</rosparam>

I used the roslaunch command to start the republish node.  Later on I could add more nodes to this same launch file.

roslaunch cherry_shoe_package repub_theora_to_compressed.launch 

Verify both methods work

I was able to verify both the rosrun and roslaunch methods by replaying a bag file to simulate live data and with a live feed using the rqt_image_view tool.

rosrun rqt_image_view rqt_image_view, then go to /cherryshoe/repub/camera/image_compressed/compressed topic.

I also verified that the original topic and republished topic data was coming through with the live feed or while the bag file was being replayed:

  • rostopic bw /cherryshoe/camera/image_raw/theora
  • rostopic bw /cherryshoe/repub/camera/image_compressed/compressed

No comments:

Post a Comment

I appreciate your time in leaving a comment!