请注意,我在使用 Python 时非常可怜,但我想做的是附加三个列表(每个 Myro 光传感器一个 - 左、中、右)总共 15 次,每次在模拟机器人之后转动一点。但由于某种原因,它不会多次迭代这些步骤。
这是我所拥有的:
def rotations():
""" Moves robot 360 degrees, appending light values 15 times along the way."""
arcs = 15
lightLeftList = []
lightCenterList = []
lightRightList = []
for count in range (1, arcs+1):
turnRight(1/6.475/15)
resultLeft = getLight("left")
lightLeftList.append(resultLeft)
resultCenter = getLight("center")
lightCenterList.append(resultCenter)
resultRight = getLight("right")
lightRightList.append(resultRight)
return lightLeftList, lightCenterList, lightRightList