0
$\begingroup$

Rosanswers logo

Dear all,

I have a node which subscribes to 3 different topics and let's call them

A: 80Hz B: 120Hz C: 50Hz

And I define the subscribers like this:

nh.subscribe("A/B/C", 1, A/B/C_callback, ros::TransportHints().tcpNoDelay());

in the main loop(which is 60Hz), I call spinOnce() and do some control task. But I have noticed that at some times I never enter B_callback. I can confirm that the publishers are all working, so why is this happening?

Best,

Ziyang


Originally posted by ZiyangLI on ROS Answers with karma: 93 on 2015-01-24

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This Q/A also has some relevant information. If I read your subscriber definition correctly. you have 3 separate subscribers, all with a queue size of 1. This means that when spinOnce() is called at 60 Hz, you should get your callbacks called for all your subscribers. As you publish faster than 60 Hz on A and B and only have a queue size of 1, it is expected that some messages on both topic are dropped (in fact, on average half of them for B). I'm not sure why B_callback sometimes is never called, but I'd recommend increasing the queue size on your subscribers to see if that improves things.


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2015-01-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ZiyangLI on 2015-01-24:
Dear @Stefan, you understand my question correctly. I am not sure if your suggestion will work, but I don't want to increase the queue_size because I only want to do control based on the latest messages. I am thinking assigning each subscriber its own message queue, do you think that is necessary?

$\endgroup$

Your Answer

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