Hello everyone. I'm trying to make a node that listens to a camera topic (sensor_msgs/Image) and also to a topic that publishes a custom message. The custom message contains a pair of integers (x,y) that specify a pixel for every frame of the video footage (1 pair per message/frame). I want to use the information the node gets from the custom message topic (the integer) in combination with the information from the camera topic (the sensor_msgs/Image message), so I can colour the pixel using OpenCV (but let's not deal with this right now). I've figured out how to set up 2 different subscribers, each one with its own callback. However, I'm having trouble figuring out how to combine the information from both topics and where I should put the pub.publish(...) line. Also, how can I match each camera frame with the correspondant custom message for that frame? Should I use the timestamps or the seq numbers?
ps1: I'm very new to ROS and robotics in general. ps2: The 2 input topics are in the same rosbag.
Originally posted by rbsb on ROS Answers with karma: 3 on 2018-08-02
Post score: 0
Original comments
Comment by jayess on 2018-08-02:
Can you share with us what you've tried (i.e., code)? It's usually easier to give some help or guidance if we can see what's been done vs a description of it..
Comment by gvdhoorn on 2018-08-03:
This reads like a duplicate of #q299135 (at least, that's just a recent one, there have been many questions posted about this sort of thing).
@rbsb: can you please check whether that Q&A clears things up?
Comment by gvdhoorn on 2018-08-03:
May I also suggest a topic change? The question seems to be really about how to use information from two different subscribers at the same time, and then publish the result. The current title does not seem to reflect that.
Comment by Mehdi. on 2018-08-03:
Threads are your friends, two subscribers setting class variables and their timestamps, and a class function with a while loop running as a separate thread. For your simple use case it wouldn't hurt much if you don't consider variable mutex etc.