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

2 nodes publishing on same topic - merge?

asked 2013-10-04 01:04:06 -0500

MikeStrike gravatar image

updated 2013-11-18 19:10:52 -0500

tfoote gravatar image

Hello,

I have a robot description (urdf file) where the joint state publisher is publishing for all the non-fixed joints a message. I have 4 such joints which are published on topic /joint_states. But 2 of this joints I want to control with a script publishing on a different topic -> /motor/states.
The problem is when I remap from motor/states to joint_states, then the joint state messages switch between this two:

header: 
  seq: 7270
  stamp: 
    secs: 1380880430
    nsecs: 894582033
  frame_id: ''
name: ['motor1', 'left_joint', 'right_joint', 'motor2']
position: [0.0, 0.0, 0.0, 0.0]
velocity: []
effort: []
---
header: 
  seq: 36366
  stamp: 
    secs: 1380880430
    nsecs: 900352954
  frame_id: ''
name: ['motor1', 'motor2']
position: [0.0, 0.0015339807878856412]
velocity: [0.0, 0.0]
effort: []

what I actually want is left_joint and right_joint from the above message but replace the motor1 motor2 in the first by those in the second message.

Thanks for helping!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-10-04 03:25:32 -0500

dornhege gravatar image

Easy answer: Just don't send motor1/2 in the first one. The data will be merged correctly.

You should ask yourself the question why there are two different sources of data for the same joints. Are they sending the same values? Then just use the first message. Are they sending different values? Then something in the system is wrong as one is sending bad data.

edit flag offensive delete link more

Comments

"Are they sending the same values?" -> no, data1 has values [ a b c d ] while a and b are always 0 (that's my problem). data2 has values [a b] with the desired values. But I still need c, d from data1. That is why not sending 1 doesn't work. And the first message is (automatically) published by the joint_state_publisher due to the joint properties("revolute") in the urdf model of the robot , isn't it? What I would want is that the 3D model (data1 [a b c d]) is listening to data2 [a b] and then sending out [a b c d] with the desired values for a and b. But How? Sorry for the question but I do not know how to fix it.

MikeStrike gravatar image MikeStrike  ( 2013-10-04 05:10:40 -0500 )edit
1

I think you are setting up things backwards. The data that goes to robot_state_publisher should be the current state of the robot, not any control commands. You'll need some component in between, either robot or simulation that receives commands and puts the robot in another state that is published.

dornhege gravatar image dornhege  ( 2013-10-04 05:21:12 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2013-10-04 01:04:06 -0500

Seen: 1,889 times

Last updated: Oct 04 '13