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

lourd's profile - activity

2013-10-24 06:09:36 -0500 received badge  Famous Question (source)
2013-08-05 05:29:57 -0500 answered a question How to get topic from a message

For future viewer reference, the second line could also be written as:

SUBSCRIPTIONS = map(lambda topic: rospy.Subscriber(topic, AnyMsg, callback=bag, callback_args=topic), TOPICS)

with or without the "callback" and "callback_args". I would say that this follows the ROS convention more closely than the previous answer, although it is excellent and also works.

2013-08-02 03:40:09 -0500 received badge  Notable Question (source)
2013-08-01 17:18:44 -0500 received badge  Student (source)
2013-08-01 16:51:48 -0500 commented answer How to get topic from a message

Ah, yes, beautiful! Thank you!

2013-08-01 16:51:20 -0500 received badge  Supporter (source)
2013-08-01 16:51:18 -0500 received badge  Scholar (source)
2013-08-01 16:50:17 -0500 received badge  Popular Question (source)
2013-08-01 12:00:04 -0500 asked a question How to get topic from a message

I'm trying to write a custom bagging node for my ROS installation. The node's requirements are to only bag topics that are published on the local machine (my ROS installation runs on a 3-computer setup), to throttle the bagging rate based on system load and free disk space, and to only bag topics specific to the state of the robot. This means that subscriptions are being created and destroyed on-the-fly, and therein lies my problem.

For creating and destroying the subscriptions, I have these 2 lines of code:

map(lambda x: x.unregister(), SUBSCRIPTIONS)
SUBSCRIPTIONS = map(lambda topic: rospy.Subscriber(topic, AnyMsg, bag), TOPICS)

The top line unsubscribes everything and the bottom one makes all new ones. As you can see, each subscription has a callback method of bag. In that method, I was hoping to just be able to write the message to a bag, independent of the topic. I didn't realize until now that rosbag.Bag.write() requires both the message _and_ the topic.

So, what's the easiest way of getting the message publisher's topic type? In addition, is there any easier way of doing what I've described?

Thanks for your help!
-lourd