0
$\begingroup$

Rosanswers logo

I am currently following this tutorial to publish image messages using the camera plugin. I can totally subscribe the image_raw topic and save every published image message, but that's not what I need.

I am using gazebo to collect image dataset of object manipulation. So ideally I need to capture (save to file) one image after some manipulation actions, then continue with the next round of manipulation and image capturing. So it is like a service request to save the image when needed rather than save images all the time. However, the only source of image I know in gazebo is the image topic. Does anyone have a better idea on how to do that?

Thanks!


Originally posted by wy3 on ROS Answers with karma: 3 on 2017-06-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

One option would be to use ros::topic::waitForMessage(..) (docs).


Originally posted by gvdhoorn with karma: 86574 on 2017-06-22

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by wy3 on 2017-06-26:
Thank you! Work like a charm.

Comment by houhao on 2021-06-09:
Hello, i was wondering how to update the msg content? I used this waitForMessage in a for loop but every time i call it, the msg content seems the same. Basically, I just tried to save the image when moving to a new position. Thanks

Comment by gvdhoorn on 2021-06-09:
Please do not post follow-up questions in comments under 5 year old questions with accepted answers. This has almost zero visibility. Post a new question instead.

But as a quick comment: if used correctly, waitForMessage(..) will return new messages each time. I don't know why it doesn't work for you. Please include more detail about how you're calling the function in your new post.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.