I made a similar question here as to how to assign a callback to two different topics.
The answer was to use message_filter
. I tried it and it worked.
I am trying to do the same with two other types of topics and I got the error:
AttributeError: 'Image' object has no attribute 'header'
I investigated and found that the synchronization uses the time stamp in the headers of the topics. The problem is that now I am using two topics and one of them is a types of messages without headers.
The topic message type ("Image") is
uint64 unique_id
sensor_msgs/CompressedImage image
As you can see it has no headers. (therefore the error "no attribute header")
My question is, is there a way that I can still combine these two topics in one callback?
P.S I have tried to follow the advice of the wiki and use allow_headerless=True but when I do this the callback function never gets called
P.S.2 is this the only way?
Originally posted by Kansai on ROS Answers with karma: 170 on 2021-04-14
Post score: 0
Original comments
Comment by tryan on 2021-04-14:\
P.S I have tried to follow the advice of the wiki and use allow_headerless=True but when I do this the callback function never gets called
P.S.2 is this the only way?
If using the receipt time instead of a timestamp is acceptable (depends on your application), allow_headerless = True
should work, and you can post your code for help troubleshooting. Otherwise, there's no need to modify the publisher directly. If you're really trying to synchronize the messages, the image
field of your Image
message, should have a header in it as I mentioned below, which is probably what you should use.
Comment by Kansai on 2021-04-14:
I have checked and the image field does seem to have a header filled. I am now learning how to use topic_tools relay to republish... it seems it can be done by a launch file but I wonder if that is possible from the code? mmm it seems relay will only republish the same message... wonder how to publish only the image part...
Comment by Kansai on 2021-04-14:
@tryan is there a way to synchronize it with the header of the image part of the message?
Comment by tryan on 2021-04-14:
You could do that if you write a custom message filter, but it would probably be easier to write a node (if topic_tools doesn't work) to republish a message you can use with an existing filter.