Robotics StackExchange | Archived questions

Trying to perform an image transport on ROS2 foxy

Hi, I have been trying to transport images across a network using ROS2 foxy. I have found a couple of sources that help explain talker and listeners, but I have not been able to find anything that really helps me understand how to transport images across a network. I tried using this github that seems promising, https://github.com/ros-perception/image_common/tree/ros2, but there is no explanation on how to use the github. I am new to ROS2 and Foxy so anything will help. Thanks!

Asked by park12345 on 2023-06-29 16:00:13 UTC

Comments

Answers

Depends on your situation but If you have a camera, then you will need to write a publisher and use cv_bridge and opencv to convert the image to sensor_msgs/image message type, and use the ROS2 node to publish the image to a topic. On the other end you will also need a subscriber that does the same thing the other way around. Also, the ROS wiki is here , not sure if there is a ros2 wiki but the tutorials would be similar.

Asked by chased11 on 2023-06-29 23:20:09 UTC

Comments

The image transport package sounds like what you need! Image transport package allows user to define their own transport methods. Here is some common transport methods provided by image transport. The transport methods are transparent to the user. i.e. it will be discovered during runtime. A typical implementation of image transport will look like this.

image_transport::ImageTransport it_(node);
image_transport::Publisher image_pub_;
image_pub_ = it_.advertise("rgb", 10);
auto image = sensor_msgs::msg::Image::SharedPtr(new sensor_msgs::msg::Image);
image_pub_.publish(image);

By doing this, you will see some additional topics for different transport method, such as compressed, if you have install the plugins correctly. I have implemented my own type of image transport plugin that uses nvenc to encode video stream to h.264 encoding.

However, the downside of using image transport is that it will produce a lot of unused topics (an extra topic per image plugin.). There seems to be a way to disable unused topic, but it is always possible to just use sensor_msgs::msg::image to transport compressed data. Just need to make sure the encoding field in the sensor_msgs::msg::image is filled up with the correct encoding format, such as h.264.

Asked by hank880907 on 2023-07-05 03:20:37 UTC

Comments