I am working on Ubuntu 20.04 on Raspberry Pi
I read this error is caused by Windows - Unix Formats conflicts But my script has no /r/n in it, how can I solve this?
#!/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()
CodePudding user response:
Windows by default uses CRLF line endings while Linux/Unix use LF line endings. If your application uses both windows and linux, its better to keep your code in LF since both platforms understand LF line endings.
A foolproof way to convert your code to unix compatible line endings is to use Vi/Vim and explicitly set the line endings to LF.
Use this command in Vi - :set ff=unix
to set the line endings to LF. Your code should then work.
And to avoid further conflicts, while developing on Windows, make sure to check that your text editor line ending settings is set to LF.