<class 'struct.error'> when use Float64MultiArray

asked 2020-03-01 02:50:33 -0600

mingcheng gravatar image

updated 2020-03-01 05:52:29 -0600

gvdhoorn gravatar image


I create an array of (30,2) using numpy and I have it populated, however, when I trying to publish it using ros publisher, I can successfully push out the 1st column but not the second column. I gt this error message

rospy.exceptions.ROSSerializationException: <class 'struct.error'>: 'required argument is not a float' when writing 'layout:

My code related to this problem is:

self.exportArray = np.zeros((30,2))-1
pub4 = rospy.Publisher('SecondKalmanInput',Float64MultiArray,queue_size=20)
data_to_send2 = Float64MultiArray()
data_to_send2.data = tuple(self.exportArray[:1])
if (self.sub.frameCount == self.sub.frameCountMax-1):

Thank you for any help MingCheng

edit retag flag offensive close merge delete


Quick comment: unless you manually write some sort of conversion, I'm not sure you can just assign a numpy array to a Float64MultiArray message field. See std_msgs/Float64MultiArray for the msg documentation.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-01 05:57:01 -0600 )edit