from ev3dev.ev3 import *
from time import sleep
ml = LargeMotor('outB')
mr = LargeMotor('outC')
ts = TouchSensor()
cs = ColorSensor()
us = UltrasonicSensor()
cs.mode = 'COL-REFLECT'
us.mode = 'US-DIST-CM'
def motorenStop(stopaction):
ml.stop(stop_action=stopaction)
mr.stop(stop_action=stopaction)
def motorenRun(speed_sp, time_sp = None, stop_action = None):
if time_sp is not None and stop_action is not None:
ml.run_timed(time_sp=time_sp, speed_sp=speed_sp, stop_action=stop_action)
mr.run_timed(time_sp=time_sp, speed_sp=speed_sp, stop_action=stop_action)
else:
ml.run_forever(speed_sp)
mr.run_forever(speed_sp)
def drive():
while 1==1:
motorenRun(300)
输出:
Traceback (most recent call last):
File "/home/robot/helloworld/main.py", line 21, in <module>
drive()
File "/home/robot/helloworld/drive.py", line 35, in drive
motorenRun(300)
File "/home/robot/helloworld/drive.py", line 26, in motorenRun
ml.run_forever(speed_sp)
TypeError: run_forever() takes 1 positional argument but 2 were given
我试图用 python 运行我的 EV3,现在我遇到了问题,即 2 个参数被传递给一个函数。我搜索了我的问题,但找不到任何解决方案。我该如何解决这个错误?