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

Synchronizing messages without time headers

asked 2013-04-12 06:38:13 -0600

whiterose gravatar image

updated 2014-01-28 17:16:09 -0600

ngrennan gravatar image

Hi all,

I am trying to synchronize subscription from a few topics from custom messages.

armj_cmd_pos_sub = message_filters.Subscriber("/arm_controller/position_command", JointPositions) armj_cmd_vel_sub = message_filters.Subscriber("/arm_controller/velocity_command", JointVelocities) armj_cmd_eff_sub = message_filters.Subscriber("/arm_controller/effort_command", JointTorques) armj_states_sub = message_filters.Subscriber("/joint_states", JointState)

It gave me

AttributeError: 'JointPositions' object has no attribute 'header'

I am suspecting the /arm_controller/position_command topic.

The type of the /arm_controller/position_command topic is brics_actuator/JointPositions and the content is

Poison poisonStamp JointValue[] positions

and the content of JointValue is

time timeStamp #time of the data

string joint_uri

string unit #if empy expects si units, you can use boost::unit

float64 value

my question is how do I get rid of the attribute error? How to synchronize topics when their message don't have headers? Is there a way to add headers without meddling with the message files?

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-12 07:12:20 -0600

dornhege gravatar image

Without extra work, you can't. Simply because the filter needs to know what to synchronize.

The main problem here is that the message you pointed out doesn't use a Header, but a custom stamp. At least there is one, so probably the easiest method is to use the filters manually. I haven't checked the API, but I'd try to not directly use the subscriber as an input, but instead put your own "FixHeaderForMyCustomMsg"-Filter in between that just constructs a data type that contains your message + a header (that you fill from the stamp). Given pythons typing, you should be able to just pass that into the TimeSynchronizer.

Meddling with built-in messages probably won't work as the types are defined using __slots__ (probably for efficiency), so you can't change that.

edit flag offensive delete link more


Does that mean the following steps: (1) Subscribe to the topic and get the message (2) republish the message with another topic with a message with header (3) And subscribe to the new topic ? Or is there a better way?

whiterose gravatar image whiterose  ( 2013-04-14 10:37:08 -0600 )edit

No. There is no need to republish. Basically message_filters are filters, so just take the message and put it in something that has a header. That something you should be able to put into the message filter.

dornhege gravatar image dornhege  ( 2013-04-14 23:43:51 -0600 )edit

Question Tools


Asked: 2013-04-12 06:38:13 -0600

Seen: 2,599 times

Last updated: Apr 12 '13