我正在制作Ubuntu 20.04的Raspberry Pi
我读到这个错误是由Windows格式冲突引起的,但是我的脚本中没有/r/n,如何解决这个问题呢?
#!/usr/bin/env python
import rospy
from laser_assembler.srv import *
from sensor_msgs.msg import PointCloud2
rospy.init_node("test_client")
rospy.wait_for_service("assemble_scans2")
assemble_scans = rospy.ServiceProxy('assemble_scans2',AssembleScans2)
pub = rospy.Publisher("/pointcloud", PointCloud2, queue_size = 1)
r = rospy.Rate(1)
while not rospy.is_shutdown():
try:
resp = assemble_scans(rospy.Time(0,0), rospy.get_rostime())
print "Got cloud with %u points" % len(resp.cloud.data)
pub.publish(resp.cloud)
except rospy.ServiceException, e:
print "Service call failed: %s" %e
r.sleep()发布于 2022-02-20 01:51:38
Windows默认使用CRLF行尾,而Linux/Unix使用LF行尾。如果您的应用程序同时使用windows和linux,最好将代码保存在LF中,因为两个平台都了解LF行的结尾。
将代码转换为unix兼容行尾的一种简单方法是使用Vi/Vim并显式地将行尾设置为LF。
在Vi - :set ff=unix中使用此命令将行尾设置为LF。这样,您的代码就可以工作了。
为了避免进一步的冲突,在Windows上进行开发时,请确保检查文本编辑器行结束设置是否设置为LF。
https://stackoverflow.com/questions/71190662
复制相似问题