ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Trying to display sensor_msgs/Image in rqt_bag

asked 2018-04-30 13:25:18 -0600

alejandro gravatar image

updated 2018-04-30 13:33:22 -0600

I´m trying to display a custom message in rqt_bag. For that, I´ve tried the following:

msg = Image() //This is the initialization of my message
msg.image = self.msg
self.bag.write(topic, msg, self.msg.header.stamp)
self.bag2.write(topic, self.msg, self.msg.header.stamp)

  • My message content (msg) is just: sensor_msgs/Image image.
  • rqt_bag message (self.msg) contents:
    std_msgs/Header header
    uint32 height
    uint32 width
    string encoding
    uint8 is_bigendian
    uint32 step
    uint8[] data
  • self.msg is tyoe sensor_msgs/Image, that´s why I can save the whole self.msg into msg.image

If I try to open the bag2 file which the one that uses the msg that rqt_bag creates, all works. However, If i try to open my custom message, rqt_bag doesn´t allow me to display the images.

I´ve also tried to save each field from self.msg to msg making first my custom message (msg) have the same structure as the rqt_bag message (self.msg):

msg.header = self.msg.header
msg.height = self.msg.height...
(in bag)-----------(in bag2)

Doing this what I have realized is that bag weights 306kB and bag2 308kB. It is like if there is some extra date somewhere which I don´t know.

Neither ways work for me. What can I do so that rqt_bag displays the images save on my custom message?? Thank you.

edit retag flag offensive close merge delete

Comments

This may be slightly off point, but why are you trying to use a custom message to do exactly the same job as sensor_msgs/Image?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-04-30 17:38:32 -0600 )edit

@PeteBlackerThe3rd cause I need to add extra parameters but I prefer to go little by little.

alejandro gravatar image alejandro  ( 2018-04-30 17:45:02 -0600 )edit

There is a much easier way of doing this, you can nest message types. Create your custom message type which includes a sensor_msgs/Image message along with the extra parameters you want to add. No need to re-invent the wheel.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-04-30 17:48:45 -0600 )edit

@PeteBlackerThe3rd I dont know exactly what u mean. What I want is a message with sensor_msgs/Image image, string name, int8 number. Then, I have to store that msg in a bag, and finally display that bag in rqt_bag but i cant. Any idea? What u were saying is valid for this? If it is, can u explain?

alejandro gravatar image alejandro  ( 2018-05-01 09:37:07 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-05-01 12:55:30 -0600

Replying to your question and subsequent comments: A custom message type which includes a sensor_msgs/image field will do everything you ask for apart from being visible in rqt_bag. An example .msg file for this would be

# my custom message type
# embedded image message
sensor_msgs/image myImage
# the extra fields needed
string name
int8 number

rqt_bag will only display sensor_msgs/image messages as images, it will not show any custom message types unless you make a plugin to extend its functionality. This is also true if you make a custom message type that has the same structure as sensor_msgs/image ROS still considers that a different type of message.

If you really need to view these images in rqt_bag then you could publish a normal sensor_msgs/image message at the same time as your custom message. This way you could view them in rqt_bag and use the custom message in the other nodes that use that information.

edit flag offensive delete link more

Comments

You are talking about publish messages but I don´t pretend to publish messages like in some examples of Publisher-Subscriber. I only want to save that msg in a bag file and then display that bag with rqt_bag. Reading what you say, it seems to be impossible unless I change rqt_bag code?

alejandro gravatar image alejandro  ( 2018-05-01 13:06:42 -0600 )edit

What is the actual problem you are Trying to solve? Saving messages in bag files and viewing images in rqt_bag is an unusual use of the ROS system.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-01 13:28:05 -0600 )edit

The problem is not saving the message but displaying that custom message which contains as I said before a sensor_msgs/Image and other parameters like strings. Rqt_bag doesn´t allow me to view (by type or topic) those images.

alejandro gravatar image alejandro  ( 2018-05-01 17:28:14 -0600 )edit

Rqt_bag doesn't have this feature unless you add it with a custom plugin. My comment about publishing two messages is just as valid for saving two messages to a bag file, the concept is the same.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-02 02:37:10 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-04-30 13:25:18 -0600

Seen: 631 times

Last updated: May 01 '18