How to publish an object pose with ROS?

Typically: "How do I... ", "How can I... " questions
Post Reply
mamagosia

How to publish an object pose with ROS?

Post by mamagosia »

Hello,

I have tried publish an object pose with ROS. Like in scene controlTypeExamples.ttt I wrote:

in sysCall_init():

Code: Select all

objHandle = sim.getObjectHandle('objName')
objPos = sim.getObjectPosition(objHandle,-1)
in sysCall_actuation():

Code: Select all

pub = simROS.advertise('pubPos', 'geometry_msgs/Point')
local tab = {}
tab['data'] = objPos  
simROS.publish(pub, tab)
but it doesn't work.

I am not sure about type in advertise and what should I write here:

Code: Select all

tab['data'] = objPos  
Could you tell me what I do wrong, please?

Kind regards

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: How to publish an object pose with ROS?

Post by fferri »

In your code, having simROS.advertise('pubPos','geometry_msgs/Point') in sysCall_actuation is wrong (it will create a publisher every simulation step; move it to sysCall_init. Also, move objPos=sim.getObjectPosition(objHandle,-1) from sysCall_init to sysCall_actuation, otherwise you will be sending the same initial position over and over.

About the type and structure of the message, always refer to the message specification, in this case geometry_msgs/Point, which has only 3 fields, so you would do:

Code: Select all

local msg={}
msg['x']=objPos[1]
msg['y']=objPos[2]
msg['z']=objPos[3]
simROS.publish(pub,msg)
or in short:

Code: Select all

simROS.publish(pub,{x=objPos[1],y=objPos[2],z=objPos[3]})

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: How to publish an object pose with ROS?

Post by fferri »

However, the RosInterface plugin supports TF Transform Broadcaster functionality.

In particular see the functions:
- simROS.sendTransform
- simROS.sendTransforms

See test_sendTransform.ttt for a complete example of sending out poses with TF.

Post Reply