我有一个 python 脚本来运行激光雷达传感器。它测量距离。我在伺服电机的帮助下移动激光雷达。所以我必须以不同的角度测量距离。我正在尝试用角度和距离更新字典。但是字典总是显示错误的角度值。
下面给出部分代码。任何类型的建议都会非常有帮助
angle_start =0
angle_step = 2 #degree step
self.set_angle(angle_start) #a method to set servo angle
time.sleep(pos_time)
angle_dict = {} #an empty dict
angle=angle_start
while angle <= angle_stop:
self.set_angle(angle)
time.sleep(0.05)
distance = int(self.messure_distance()) #a method to measure the distance. it works fine.
angle_dict[angle] = distance #trying to update the dict. it stores right distance. but now the right angle.
angle = angle + angle_step #increasing angle