-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] run_until_stalled() doesn't return correct angle value in 3.2.0b1 #662
Comments
Thanks for reporting! There's certainly something wrong here, even though the behavior I'm seeing seems to be different. When I run this, the command does block and return the correct value upon stalling. But then it keeps going instead of stopping. In your example snippet above, was there anything before this? Do you see the same behavior after a full reset and running only those commands? |
This bug affects only the coast and brake stop type. As a workaround, you could use hold for now: from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Stop
from pybricks.tools import wait
# Initialize a motor on port A.
example_motor = Motor(Port.A)
# Run at 500 deg/s until the motor stalls
angle = example_motor.run_until_stalled(500, duty_limit=30, then=Stop.HOLD)
print("Stopped at", angle) |
This was broken in pybricks/pybricks-micropython@4efeee2#diff-9c5fdeeb615547288d3470c9ca282d080197673d1d9bb2c2800584a46f336d67L352. A fix for not stopping on completion has now been pushed. |
About returning right away --- it seems like this could be correct behavior. Which motor are you using? With the Medium Angular Motor" found in SPIKE Prime and Robot Inventor, 30% duty cycle is barely enough to get moving, so it really does "stall". Does it still return right away if you use |
In case want to try out the fix on the Move Hub / City Hub / Technic Hub, you can use these instructions and install this build. |
Thank you for the quick support. I tried the workarounds you suggested but none of them solved my issue, unless I add wait() and then read the angle again. |
Describe the bug
motor.run_until_stalled() used to block until motor is stalled then it returns the angle at which is stopped. With 3.2.0b1 it seems like it doesn't block anymore and it returns a wrong value, although the motor runs until it stalls .
To reproduce
Expected behavior
run motor until it stalls, then return the angle value it stopped at.
The text was updated successfully, but these errors were encountered: