0
$\begingroup$

Rosanswers logo

Hi, My apologies if the question is unclear, I'll elaborate here:

I have a node that publishes real-time image to a topic at 30Hz.

I am writing another node that subscribes to this topic and processes the image (find a target in the image).

The processing time varies, sometimes the algorithm can process images at 10Hz, sometimes 5Hz.

I want my node to process a frame, and after it finishes, get the latest frame and process that.

I tried setting queue_size of my publisher to 1, I thought that would force all old messages to be dropped. However that didn't work. My callback is just processing the old frames that's remained in the pipeline(whose size I don't know how to set)

Can someone help me with this? I'm using python. I'm trying to build a sampling port rather than a queuing port, if this explanation helps.

Another question:

  1. Does ros spawns a new thread for callback function every time a new message is available in a topic?

  2. How many buffers/pipes are there in a publisher->topic->subscriber system?

Thank you!

Nick


Originally posted by nickzhang on ROS Answers with karma: 41 on 2017-12-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You need to set the queue size of your subscriber, not your publisher to 1. According to the rospy Subscriber API docs, the queue size defaults to infinite if not explicitly set, which would explain the behavior you're seeing.


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2018-01-02

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by nickzhang on 2018-01-15:
Hi Stefan. I tried the method proposed and I still have similar problems. could you look into https://answers.ros.org/question/279791/unexpected-delay-in-subscriber-subscriber-not-getting-latest-message/ Thanks!

$\endgroup$

Your Answer

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