Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/_String.py", line 54, in serialize length = len(_x) TypeError: object of type 'int' has no len() During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 882, in publish self.impl.publish(data) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 1066, in publish serialize_message(b, self.seq, message) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/msg.py", line 152, in serialize_message msg.serialize(b) File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/_String.py", line 60, in serialize except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self))))) File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 393, in _check_types check_type(n, t, getattr(self, n)) File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 285, in check_type raise SerializationError('field %s must be of type bytes or an ascii string' % field_name) genpy.message.SerializationError: field data must be of type bytes or an ascii string During handling of the above exception, another exception occurred: Traceback (most recent call last): File "sub.py", line 45, in <module> pub_2.publish(bucket) File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 886, in publish raise ROSSerializationException(str(e)) rospy.exceptions.ROSSerializationException: field data must be of type bytes or an ascii string
时间: 2023-11-07 21:38:41 浏览: 142
Message_missing.py
这个错误提示是在ROS中发布消息时的序列化错误。它表明消息中的某个字段必须是字节或ASCII字符串类型,但是实际上它是一个整数类型,无法被序列化。
你需要检查发布代码中的消息格式,确保消息中的所有字段都具有正确的数据类型。如果你使用的是自定义消息,请确保消息定义中的所有字段都已正确定义。你还可以使用ROS中的rostopic echo命令来检查消息是否正确发布。
阅读全文