ROSSerializationException while publishing PointCloud2 Message
Hello everyone,
when my node is publishing a PointCloud2 message I get the following error:
Traceback (most recent call last):
File "/home/rosuser/ros_workspace/src/udp_83b_adapter_eclipse_python/src/UDP83BAdapter.py", line 141, in <module>
adapter.init()
File "/home/rosuser/ros_workspace/src/udp_83b_adapter_eclipse_python/src/UDP83BAdapter.py", line 137, in init
self.receive()
File "/home/rosuser/ros_workspace/src/udp_83b_adapter_eclipse_python/src/UDP83BAdapter.py", line 43, in receive
self.sonarToPointfield()
File "/home/rosuser/ros_workspace/src/udp_83b_adapter_eclipse_python/src/UDP83BAdapter.py", line 128, in sonarToPointfield
self.pub.publish(msg_pointcloud2)
File "/opt/ros/groovy/lib/python2.7/dist-packages/rospy/topics.py", line 801, in publish
raise ROSSerializationException(str(e))
rospy.exceptions.ROSSerializationException: field fields[].offset must be unsigned integer type
The message is completely generated by my python script. Here is the fields declaration and initialization:
# Create 4 PointFields as channel description
msg_pf1 = smsgs.PointField()
msg_pf1.name = np.str('x')
msg_pf1.offset = np.uint32(0)
msg_pf1.datatype = np.uint8(7)
msg_pf1.count = np.uint32(1)
msg_pf2 = smsgs.PointField()
msg_pf2.name = np.str('y')
msg_pf2.offset = np.uint32(4)
msg_pf2.datatype = np.uint8(7)
msg_pf2.count = np.uint32(1)
msg_pf3 = smsgs.PointField()
msg_pf3.name = np.str('z')
msg_pf3.offset = np.uint32(8)
msg_pf3.datatype = np.uint8(7)
msg_pf3.count = np.uint32(1)
msg_pf4 = smsgs.PointField()
msg_pf4.name = np.str('intensity')
msg_pf4.offset = np.uint32(12)
msg_pf4.datatype = np.uint8(2)
msg_pf4.count = np.uint32(1)
And somewhere later in the code:
msg_pointcloud2.fields = [msg_pf1, msg_pf2, msg_pf3, msg_pf4]
I'm using python/rospy. Another strange thing: I can run the script. As soon as I try to access the message (e.g. via rostopic echo) the error comes up.
Does anybody have a idea why this is happening? What can I try to debug?