-
-
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] Slow gyro turn triggers imu drifting #1840
Comments
Thanks for reporting! This was very useful. I was able to reproduce this on the standard large drivebase from the expansion set. I think what is happening is that during slow turns it is considering itself stationary enough to recalibrate. And because it is moving, that throws off the calibration. To confirm, I've changed your debug function as follows (full code below) to print the async def debug():
while True:
print(hub.imu.ready(), hub.imu.stationary(), hub.imu.heading(), hub.imu.angular_velocity(Axis.Z), sep=",")
await wait(200) You can change the calibration thresholds using this method. I think the defaults are currently a bit too high, causing the issue shown here. The reason that the defaults are high is to ensure it can calibrate even in a noisy FLL environment after feedback we got in #989 To better address this, the upcoming firmware will save your configured settings so they persist when you reboot. This way, we can choose lower defaults, and people in noisy environments can increase them if they have to. Additional notes:
# This is mostly OP's program, modified for the standard Advanced Driving Base
#⭐the program sets up the hub⭐#
from pybricks.hubs import PrimeHub
from pybricks.parameters import Direction, Port, Axis
from pybricks.pupdevices import Motor
from pybricks.robotics import DriveBase
from pybricks.tools import run_task, wait, multitask
#⭐the program sets up the devices⭐#
hub = PrimeHub()
drive_left = Motor(Port.A, Direction.COUNTERCLOCKWISE)
drive_right = Motor(Port.B, Direction.CLOCKWISE)
base = DriveBase(drive_left, drive_right, 88, 18*8)
base.use_gyro(True)
#⭐🌟⭐the program officially begins⭐🌟⭐#
async def debug():
while True:
print(hub.imu.ready(), hub.imu.stationary(), hub.imu.heading(), hub.imu.angular_velocity(Axis.Z), sep=",")
await wait(200)
async def movement():
base.settings(straight_speed=300)
await wait(2000)
print("start drive")
await base.straight(130)
print("done drive")
await wait(2000)
base.settings(turn_rate=50)
print("start turn")
await base.turn(-180)
print("done turn")
await wait(15000)
raise SystemExit
async def main():
await multitask(movement(), debug())
run_task(main()) |
Thanks for addressing the problem in just a few hours. I will try to tune the turnning rate and imu settings. Also, on the firmware side, is it possible to block imu from calibration when the drive base is executing a moving related function? |
Right. Maybe it needs to disable calibration during every motor move, not just drive bases. EDIT: Disabling calibration during any controlled movements is quite easy to implement. The even simpler option would be to disable calibration while any code is running, but we would still want the user to be able to wait for calibration within their program. For example: # device setup here
# Wait for calibration to finish in case it hasn't already.
while not hub.imu.ready():
print("wait for calibration to complete!")
wait(100)
# and possibly after some time relax the settings ... |
The fix is available for testing using these instructions to try the latest version Please re-open if you experience any further issues or inconsistencies. Thank you! |
Confirm this bug has been fixed with |
Thank you! |
Describe the bug
What is the problem?
After a drive base makes a slow left turn with gyro, the imu heading starts to drift.
To reproduce
Steps to reproduce the behavior:
Expected behavior
What did you expect to happen instead?
The drive base should stop still without turnning.
Video
IMG_6094_720p.mov
Full code and logs
The text was updated successfully, but these errors were encountered: