How to publish an object pose with ROS?

Typically: "How do I... ", "How can I... " questions
Post Reply
mamagosia
Posts: 12
Joined: 11 Jan 2018, 18:48

How to publish an object pose with ROS?

Post by mamagosia » 13 Mar 2018, 22:07

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: 173
Joined: 09 Sep 2013, 19:28

Re: How to publish an object pose with ROS?

Post by fferri » 13 Mar 2018, 23:39

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 tab = {}
tab['x'] = objPos[1]
tab['y'] = objPos[2]
tab['z'] = objPos[3]
simROS.publish(pub, tab)

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

Re: How to publish an object pose with ROS?

Post by fferri » 14 Mar 2018, 09:21

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