-
-
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] Running to an absolute angle immediately after boot fails sometimes #361
Comments
This appears to confirm it. Flash this along with the firmware so you can run it after boot. The first time you run this it shows 0 for all positions, while it should show the absolute angle instead. from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port
from pybricks.tools import wait
hub = PrimeHub()
angles = {}
for motor_port in (Port.A, Port.C, Port.D, Port.E):
motor = Motor(motor_port)
char = repr(motor_port)[5]
angles[char] = motor.angle()
while True:
for char, angle in angles.items():
hub.display.char(char)
wait(500)
hub.display.number(angle)
wait(1000)
hub.display.off()
wait(500) |
In the setup during Therefore, motor data is not defined even though the motor is synced up and so we read zero. |
The original comment suggested that this is used to let external devices know that a device is ready, but this isn't strictly true. It may still be reporting garbage data at this point. So, we move it to the point where it has received one good data message. It would be better to have a proper function to check this, but this can be done as part of the bigger lpf2 driver overhaul in a future release. pybricks/support#361
This getter was masking several different possible errors into just one generic error. We also use it in just one place, so it makes sense unpack it and save a bit of space. pybricks/support#361
This allows higher level code to call this again as neeeded. pybricks/support#361
At the drv level, the dc motor getter is performing several checks whether the motor is ready, so do those first. pybricks/support#361
When starting scripts immediately after boot, they often failed because the sensors had not yet finished syncing up. This avoids a crash by waiting for the sensor to sync up if a UART device is detected. Related to pybricks/support#361
In short, this series of commits:
You'll still get ENODEV if you're so fast that it's still running the device connection manager, but this is much less likely and therefore much less annoying. Since it fixes a bug and improves the user experience, I think it's worth including this in v3.0. Do you want to review this @dlech before merging? |
It all looks reasonable to me. We should probably wait and call what we have now 3.0 though since this isn't a critical bug. |
I’d say the rotation sensor giving garbage values is probably a critical bug though. For example, a humanoid robot will fall flat on its face. |
FWIW, when I say "critical bug", I mean it frequently affects a large number of users and there is no workaround. |
Right, but in robotics I’d include mechanical failures even if they don’t occur very often - safety first. There’s no such thing as a soft reboot if it just jumped off your desk. For example, depending on the user script, this will try to flip the motor by up to 180 degrees at maximum power, which is probably critical. And since we have the option to save programs permanently on the hub, this is part of the release features. |
Merged, so closing. |
Describe the bug
Sometimes, going to an absolute position does not work. Mostly immediately after boot, so when running a program from flash.
To reproduce
I haven't identified a consistent reproducable case yet, but it has happened several times now. I'm also not entirely sure it is only after boot, but it does seem that way. I've only tried on Primehub so far.
Perhaps the motor is synched up, but did not receive its first data value yet.
For example, this script should put two motors 180 degrees apart, but sometimes it puts them in parallel.
The text was updated successfully, but these errors were encountered: