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

Revision history [back]

I created a solution to this using a bootstrapping technique: subscribe to an AnyMsg with a regular rospy.Subscriber callback, then look in _connection_header['message_definition'] for Header header, if it exists import the message type using exec(), then resubscribe with a message_filters.Subscriber using eval() and create the TimeSynchronizer, unregister the bootstrap subscriber.

It would be nice to have a solution that doesn't use exec or eval though.

I created a solution to this using a bootstrapping technique: subscribe to an AnyMsg with a regular rospy.Subscriber callback, then look in _connection_header['message_definition'] for Header header, then if it has it:

Current solution

import roslib.message
...
topic_type = msg._connection_header['type']
topic_class = roslib.message.get_message_class(topic_type)
sub = message_filters.Subscriber("foo", topic_class)

Possible Solution

__import__ or importlib - need an example.

Previous solution

if it exists import the message type using exec(), then resubscribe with a message_filters.Subscriber using eval() and create the TimeSynchronizer, unregister the bootstrap subscriber.

It would be nice to have a solution that doesn't use Using exec or and eval though.is undesirable for security reasons.

I created a solution to this using a bootstrapping technique: subscribe to an AnyMsg with a regular rospy.Subscriber callback, then look in _connection_header['message_definition'] for Header header then if it has it:

Current solution

import roslib.message
...
topic_type = msg._connection_header['type']
topic_class = roslib.message.get_message_class(topic_type)
bootstrap_sub.unregister()
sub = message_filters.Subscriber("foo", topic_class)

Possible Solution

__import__ or importlib - need an example.

Previous solution

if it exists import the message type using exec(), then resubscribe with a message_filters.Subscriber using eval() and create the TimeSynchronizer, unregister the bootstrap subscriber.

Using exec and eval is undesirable for security reasons.