RGBD_relay to republish RGB

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RGBD_relay to republish RGB

robotino
Hi, I am currently running RTABmap on a client and use a Robotino with a Kinect V1 as robot. I am using rgbd_sync to transfer the image data to the client. RTABmap works great but I was wondering if I can republish the RGB image from the rgbd_relay on the client (I'd like to run apriltag_ros and I am too stupid to compile rtabmap with opencv and apriltag). As I understand the RGB image is a regular JPG within the RGBDimage message.

Thanks for any help
Reply | Threaded
Open this post in threaded view
|

Re: RGBD_relay to republish RGB

matlabbe
Administrator
Hi,

You could create a node in Python to subscribe to RGBDimage topic and then just republish the rgb image (raw or compressed).

#!/usr/bin/env python
import rospy

from sensor_msgs.msg import CameraInfo
from sensor_msgs.msg import Image
from sensor_msgs.msg import CompressedImage
from rtabmap_ros.msg import RGBDImage

def callback(msg):
    global info_pub
    global image_pub
    global compressed_pub
    info_pub.publish(msg.rgb_camera_info)
    if len(msg.rgb.data) > 0:
        image_pub.publish(msg.rgb)
    if len(msg.rgb_compressed.data) > 0:
        compressed_pub.publish(msg.rgb_compressed)

if __name__ == "__main__":

    rospy.init_node("rgbd_to_image", anonymous=True)

    rospy.Subscriber("rgbd_image", RGBDImage, callback, queue_size=1)

    info_pub = rospy.Publisher(rospy.resolve_name("rgbd_image") + "/camera_info", CameraInfo, queue_size=1)
    image_pub = rospy.Publisher(rospy.resolve_name("rgbd_image")+ "/image", Image, queue_size=1)
    compressed_pub = rospy.Publisher(rospy.resolve_name("rgbd_image") + "/image/compressed", CompressedImage, queue_size=1)
    
    rospy.spin()



Usage:
python rgbd_to_image.py rgbd_image:=/rtabmap/rgbd_image
Reply | Threaded
Open this post in threaded view
|

Re: RGBD_relay to republish RGB

robotino
That is very helpful.

Thank you very much!