Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

subscribe field of message array

Hey there,

I would like to subscribe a field of a message array.

E.g. if my message looks like this:

BallStates.msg:

BallState[] ball_states

BallState.msg:

std_msgs/Header header   
uint32 uid 
geometry_msgs/Point position

Only the BallStates.msg is published. And I would like to subscribe to the first ball in this message with message_filters

self.topic2_sub = message_filters.Subscriber("/ball_states[0]/ball_state" , BallState)
ts = message_filters.TimeSynchronizer([self.topic1_sub, self.topic2_sub], 10)
ts.registerCallback(self.topic12_cb)

For that however I get this error:

ball_states[0]/ball_state' is not a legal ROS graph resource name. This may cause problems with other ROS tools
  super(Subscriber, self).__init__(name, data_class, Registration.SUB)

However if I echo that topic in a terminal by rostopic echo /ball_states[0]/ball_state it works :)

Does anyone know a fast workaround to this?

I mean of course I can kind of publish the first ball in an extra message and subscribe to that one but this is actually not what I want.....

I would like to have a fast short solution that does not cost time....

subscribe field of message array

Hey there,

I would like to subscribe a field of a message array.

E.g. if my message looks like this:

BallStates.msg:

BallState[] ball_states

BallState.msg:

std_msgs/Header header   
uint32 uid 
geometry_msgs/Point position

Only the BallStates.msg is published. And I would like to subscribe to the first ball in this message with message_filters

self.topic2_sub = message_filters.Subscriber("/ball_states[0]/ball_state" , BallState)
ts = message_filters.TimeSynchronizer([self.topic1_sub, self.topic2_sub], 10)
ts.registerCallback(self.topic12_cb)

For that however I get this error:

ball_states[0]/ball_state' is not a legal ROS graph resource name. This may cause problems with other ROS tools
  super(Subscriber, self).__init__(name, data_class, Registration.SUB)

However if I echo that topic in a terminal by rostopic echo /ball_states[0]/ball_state it works :)

Does anyone know a fast workaround to this?

I mean of course I can kind of publish the first ball in an extra message and subscribe to that one but this is actually not what I want.....

I would like to have a fast short solution that does not cost time....

subscribe field of message array

Hey there,

I would like to subscribe a field of a message array.

E.g. if my message looks like this:

BallStates.msg:

BallState[] ball_states

BallState.msg:

std_msgs/Header header   
uint32 uid 
geometry_msgs/Point position

Only the BallStates.msg is published. And I would like to subscribe to the first ball in this message with message_filters

self.topic2_sub = message_filters.Subscriber("/ball_states[0]/ball_state" , BallState)
ts = message_filters.TimeSynchronizer([self.topic1_sub, self.topic2_sub], 10)
ts.registerCallback(self.topic12_cb)

For that however I get this error:

ball_states[0]/ball_state' is not a legal ROS graph resource name. This may cause problems with other ROS tools
  super(Subscriber, self).__init__(name, data_class, Registration.SUB)

However if I echo that topic in a terminal by rostopic echo /ball_states[0]/ball_state it works :)

Does anyone know a fast workaround to this?

I mean of course I can kind of publish the first ball in an extra message and subscribe to that one but this is actually not what I want.....

I would like to have a fast short solution that does not cost time....

Note something like this:

  <remap from="ball_states[0]" to="ball1"/>

also will not work for me...:

Invalid <remap> tag: remap from [/turtlebot3/ball_tracking/ball_states[0]] is not a valid ROS name.
XML is <remap from="/turtlebot3/ball_tracking/ball_states[0]" to="ball1"/>
The traceback for the exception was written to the log file