How to publish an float array

Typically: "How do I... ", "How can I... " questions
Post Reply
yangxingjian95
Posts: 4
Joined: 29 Apr 2020, 04:48

How to publish an float array

Post by yangxingjian95 »

I tried

Code: Select all

Pub = simROS.advertise('/topic', 'std_msgs/Float32MultiArray')
create an array

Code: Select all

array ={1.0, 2.0, 3.0, 4.0} 
and publish it

Code: Select all

simROS.publish(Pub, array)
then I got this error:

Code: Select all

read__std_msgs__Float32MultiArray: expected a table (simROS.publish @ 'RosInterface' plugin)
which I am quite confused about...

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: How to publish an float array

Post by coppelia »

Hello,

try with:

Code: Select all

local msg={}
msg.data=array
simRos.publish(Pub,msg)
Cheers

yangxingjian95
Posts: 4
Joined: 29 Apr 2020, 04:48

Re: How to publish an float array

Post by yangxingjian95 »

coppelia wrote: 01 May 2020, 09:49 Hello,

try with:

Code: Select all

local msg={}
msg.data=array
simRos.publish(Pub,msg)
Cheers
Thank you!

Post Reply