実現したいこと
プログラムを正式に実行させ、mindstorms,EV3によるライントレースを成功させたい。
発生している問題・分からないこと
ライントレースを実行したいのだが、エラーが出てうまくいかない。
エラーメッセージ
error
1Traceback (most recent call last): 2 File "ex10_14.py", line 52, in <module> 3 follow_line() 4 File "ex10_14.py", line 40, in follow_line 5 tank_drive.on(*speed_left_turn) 6TypeError: on() argument after * must be an iterable, not float
該当のソースコード
Python3
1from time import sleep,time 2 3from ev3dev2.motor import MoveTank, OUTPUT_A, OUTPUT_C 4from ev3dev2.sensor.lego import ColorSensor, TouchSensor 5from ev3dev2.sound import Sound 6 7tank_drive = MoveTank(OUTPUT_A, OUTPUT_C) 8cs, ts = ColorSensor(), TouchSensor() 9snd = Sound() 10 11cs.mode = 'COL-REFLECT' 12 13WHITE,LIGHTGLAY,DARKGLAY,BLACK = 85, 65, 45, 25 14 15 16def follow_line(max_duration=0.25): 17 18 speed_forward = (20,20) 19 speed_left_turn, speed_right_turn = (0.15), (15,0) 20 speed_left_sharpturn, speed_right_sharpturn = (-5, 5), (5, -5) 21 22 time_on = time() 23 24 while time() - time_on < max_duration: 25 26 if ts.is_pressed: 27 break 28 29 intensity = cs.value() 30 31 if intensity > WHITE : 32 tank_drive.on(*speed_right_sharpturn) 33 elif intensity > LIGHTGLAY : 34 tank_drive.on(*speed_right_turn) 35 elif intensity > DARKGLAY : 36 tank_drive.on(*speed_forward) 37 elif intensity > BLACK : 38 tank_drive.on(*speed_left_turn) 39 else: 40 tank_drive.on(*speed_left_sharpturn) 41 if intensity > BLACK: 42 time_on = time() 43 44 tank_drive.off() 45 snd.beep() 46 47if __name__ == '__main__': 48 snd.speak('Ready.Puch the touch sensor to start.') 49 ts.wait_for_bump() 50 follow_line() 51
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
変更したあと、実行したら
しばらく時間がたった後にReady.Puch the touch sensor to startと発し、タッチセンサーを押すとすぐにビープ音がなった
その間、EV3は動いていません。
補足
特になし

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。