-
-
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
Drive Base with gyro is slow to recover perturbed heading angle when driving at high speed #1032
Comments
from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor,
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop, Icon
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
hub = PrimeHub()
motorl = Motor(Port.A, Direction.COUNTERCLOCKWISE)
motorr = Motor(Port.B)
motorl.control.limits(acceleration=[2000, 400])
motorr.control.limits(acceleration=[2000, 400])
drive_base = DriveBase(
left_motor=motorl,
right_motor=motorr,
wheel_diameter=55,
axle_track=143,
positive_direction=Direction.COUNTERCLOCKWISE,
use_gyro=True)
drive_base.settings(
straight_speed=500,
straight_acceleration=1000,
turn_acceleration=2000,
turn_rate=500
)
while True:
drive_base.straight(1000, then=Stop.NONE)
20230405_133825.mp4
from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor,
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop, Icon
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
hub = PrimeHub()
motorl = Motor(Port.A, Direction.COUNTERCLOCKWISE)
motorr = Motor(Port.B)
motorl.control.limits(acceleration=[2000, 400])
motorr.control.limits(acceleration=[2000, 400])
drive_base = DriveBase(
left_motor=motorl,
right_motor=motorr,
wheel_diameter=55,
axle_track=143,
positive_direction=Direction.COUNTERCLOCKWISE,
use_gyro=True)
drive_base.settings(
straight_acceleration=1000,
turn_acceleration=2000,
turn_rate=500
)
while True:
drive_base.straight(1000, then=Stop.NONE)`
20230405_133902.mp4Originally posted by @Xylar52 in #989 (comment) |
Hypothesis: with the gyro as the heading input, it is much easier to perturb the heading controller by a large amount. By contrast, when the motor angles are used for heading, the motors would stall long before you could spin the drivebase by a huge amount. So, something is probably oversaturated in one of the control variables. I'd need to do some datalogging to see what it is. Workaround for now |
Reproduce on the large drive base
|
This piece of code is not working as intended: One controller can pause another as intended, but it unpauses itself immediately in the next iteration. |
Now, the paused controller cannot unpause itself until all controllers are unpaused. This is simpler, and also generalizes to N motors when we go beyond drivebases. Partially fixes pybricks/support#1032
Partially fixes pybricks/support#1032
This was happening partially due to a bug in the way the heading and distance controllers were synchronized. That is now fixed, but that doesn't fix OP's issue completely. This remaining issue still stands: When driving at high speed, the motors are almost saturated with just the feed forward component. Large perturbations are now fixed, so the robot turns back quickly if you spin it far. But small errors are not corrected very well at high speeds. |
I should add that this is the expected result technically, but it is probably more intuitive to slow the robot down explicitly in this scenario using some sort of supervisory controller. |
The simpler solution is probably to reduce the maximum settable speed to something that still allows the robot to over-correct as needed. In fact, we could just add this to the docs. With the default settings, this issue does not occur. |
Partially fixes pybricks/support#1032
Originally posted by @Xylar52 in #989 (comment)
The text was updated successfully, but these errors were encountered: