You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
python-ev3dev v2 program freezes if go to current position #505
ev3dev version: 4.14.61-ev3dev-2.2.2-ev3
ev3dev-lang-python version:
ii python3-ev3dev 1.2.0 all Python language bindings for ev3dev
ii python3-ev3dev2 2.0.0~beta1 all Python language bindings for ev3dev
If the script instructs the motor to go to a position that it is already in then this freezes the program! For example, this will freeze the program (i.e. the program will not terminate):
!/usr/bin/env python3
from ev3dev2.motor import LargeMotor, OUTPUT_B
from time import sleep
large_motor = LargeMotor(OUTPUT_B)
large_motor.on_to_position(speed_pct=10, position=-120)
sleep(2)
large_motor.on_to_position(speed_pct=10, position=-120)
I put this comment in one of your other issues, but the point still stands:
motor.py's wait(self, cond, timeout=None) method polls the motor waiting for a change. It assumes that when it is called the motor is running, and it is waiting for a change to either 'stalled' or 'not running'. Unfortunately if you ask the motor to move zero, then it never was running in the first place. Thus the polling will block forever.
You can narrow the race condition by moving the poll to the end of wait()'s while loop, and therefore checking the condition before blocking.
Activity
matskew commentedon Sep 8, 2018
I put this comment in one of your other issues, but the point still stands:
motor.py's wait(self, cond, timeout=None) method polls the motor waiting for a change. It assumes that when it is called the motor is running, and it is waiting for a change to either 'stalled' or 'not running'. Unfortunately if you ask the motor to move zero, then it never was running in the first place. Thus the polling will block forever.
You can narrow the race condition by moving the poll to the end of wait()'s while loop, and therefore checking the condition before blocking.
WasabiFan commentedon Sep 24, 2018
Fix released in
2.0.0~beta2. To upgrade: