ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Haarslev's profile - activity

2019-05-15 05:05:55 -0500 received badge  Nice Answer (source)
2018-05-18 09:36:26 -0500 received badge  Self-Learner (source)
2018-05-18 09:36:26 -0500 received badge  Teacher (source)
2018-05-18 09:36:17 -0500 received badge  Nice Question (source)
2018-01-24 13:03:46 -0500 marked best answer How to set callback queue size in rospy

Hello,

I'm currently working on a project where I use a network written in TensorFlow to segment some point clouds. I have created a node which subscribes to the point cloud topic. The callback function then passes the point cloud through the network, and publishes the results on a different topic.

This all works well, but I have a problem:

The time it takes to run the point cloud through the network is greater than the publish rate of the LiDAR. This creates an ever increasing delay between the input and the output of the node, as a new thread is created for each callback function, which then waits until the network is available.

I would therefore like a way to cancel all callbacks until the network is available again, so all other point clouds than the latest gets discarded.

Currently I do the following

# Callback
def segment(pointcloud):
    feed_dict = {ops['pointclouds_pl']: pointcloud,
                ops['is_training_pl']: False}
    labels = sess.run(ops['pred'], feed_dict=feed_dict)
    publisher.publish(labels)

The subscriber is declared like this

subscriber = rospy.Subscriber('aligned_pointcloud', PointCloud2, segment, queue_size=1)

I would assume that setting the queue_size to one would do the trick but that is not the case.

 while not rospy.is_shutdown():
        pc = rospy.wait_for_message('aligned_pointcloud', PointCloud2)
        segment(pc)

The above code is also a possibility I have tried which sorta work. The problem is that it first listens for messages after the function has terminated, instead of keeping the latest ready. So if a message is published right before segment() terminates, the message is not received and the node waits for the next message to be published.

2017-09-25 03:29:34 -0500 answered a question How to set callback queue size in rospy

As pointed out by gvdhoorn, the fix was to set queue_size=None subscriber = rospy.Subscriber('aligned_pointcloud', Poin

2017-09-24 12:38:16 -0500 commented question How to set callback queue size in rospy

I'll try as soon as I'm near my workstation again, thank you

2017-09-23 16:16:22 -0500 received badge  Famous Question (source)
2017-09-18 14:03:47 -0500 received badge  Student (source)
2017-09-04 05:46:17 -0500 received badge  Notable Question (source)
2017-08-30 02:58:01 -0500 received badge  Popular Question (source)
2017-08-29 16:13:14 -0500 commented question How to set callback queue size in rospy

In the bottom example I have not declared a subscriber. I simply wait for a message on the topic, and call the function

2017-08-29 12:23:26 -0500 asked a question How to set callback queue size in rospy

How to set callback queue size in rospy Hello, I'm currently working on a project where I use a network written in Tens

2017-08-29 12:20:00 -0500 asked a question How to set callback queue size in rospy

How to set callback queue size in rospy Hello, I'm currently working on a project where I use a network written in Tens

2017-08-29 12:20:00 -0500 asked a question rospy subscriber queue

rospy subscriber queue Hello, I'm currently working on a project where I use a network written in TensorFlow to segment