Ask Your Question
0

It was delayed to subscribe a image topic by frame rate of Images. [closed]

asked 2018-04-24 00:02:05 -0500

harderthan gravatar image

Hello, guys. I have used ROS Kinetic on ubuntu 16.04.

I make a two node. The one is publisher node to publish image topic. Another is subscriber node to subscribe publisher's topic.

The transmission period of the publisher node is 30 fps approximately. As you can see in the code below, When I remove the remark of line include the cv::wait(30) function, Subscriber does not work at regular intervals.

I can not find a clue. Can you tell me what keywords I can find information about?

...(On Subscriber Node)...
while(ros::ok()) {
    ros::spinOnce();
    image_sub_ = it_.subscribe("/video/image/ch0", 1, &imageCb);  // 30 fps by publisher!
    // chKey = cv::waitKey(30);
}
...
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by harderthan
close date 2018-05-03 00:09:32.262204

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-04-24 06:29:35 -0500

You only need to subscribe to the image topic once, do not put this line within the main while loop of your code.

What you're telling ROS to do is re-subscribe to the same topic every iteration of the loop, this is not going to work well at all.

Move the subscribe line outside of the loop, then it should start working as you expect.

edit flag offensive delete link more

Comments

1

Thanks to that I understood well.

harderthan gravatar image harderthan  ( 2018-05-03 00:08:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-24 00:02:05 -0500

Seen: 233 times

Last updated: Apr 24 '18