Skip to content
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] DriveBase acting weird with high values? #729

Closed
Vinz1911 opened this issue Sep 27, 2022 · 13 comments
Closed

[Bug] DriveBase acting weird with high values? #729

Vinz1911 opened this issue Sep 27, 2022 · 13 comments
Labels
bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: motors Issues involving motors

Comments

@Vinz1911
Copy link
Sponsor

Describe the bug
I have a Spike prime with two large motors equipped. The DriveBase is starting acting weird after I set a high speed value or a high turn rate or both at the same time. For example: if I just add a speed value of 500 the robot accelerate very fast for a second and then drives slow ?!. If I add a high turn rate it's the same behavior, it starts turning fast for a second and then it drives/turns slow and sometimes it stops and starts turning in the wrong/opposite direction ?!. If I set a speed value of 300 and a turn rate of 45 (or values below) then everything seems to working correct.

As additional Question: If I set an acceleration value in the settings this does not affect the drive() method. it would be nice if I can also set the acceleration value as a setting for the drive() method. the default value is a bit slow for me.

To reproduce
This little Code snippet is enough to reproduce the behavior, sometimes it needs to restart a few times to trigger it.

from pybricks.hubs import PrimeHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Button, Color, Direction, Port, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch

hub = PrimeHub()
left_motor = Motor(Port.A)
right_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)

base = DriveBase(left_motor, right_motor, 55, 125)

# high drive speed
base.drive(500, 45)

# or high turn rate or both
base.drive(500, 70)

while True: pass

Expected behavior
Drive as expected with high speed and correct turn rate

@Vinz1911 Vinz1911 added the triage Issues that have not been triaged yet label Sep 27, 2022
@laurensvalk
Copy link
Member

Thanks for reporting. Can you add the firmware version used for this experiment?

from pybricks import version
print(version)

@laurensvalk laurensvalk added topic: motors Issues involving motors software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) and removed triage Issues that have not been triaged yet labels Sep 27, 2022
@laurensvalk laurensvalk added this to To do in Pybricks v3.2 via automation Sep 27, 2022
@Vinz1911
Copy link
Sponsor Author

Vinz1911 commented Sep 27, 2022

Yes sure:

('primehub', '3.2.0b3', 'v3.2.0b3-67-gcaffa8a6 on 2022-09-14')

EDIT:

I also tried a pair of Lego Technic 88014 XL Motor's. They work without any problems. I Also will try the small Spike Motors but it seems the Problem is limited to the Large Spike Motors

@laurensvalk
Copy link
Member

Could this be the same as #664 ?

I thought I had fixed it but apparently not.

@laurensvalk laurensvalk added the bug Something isn't working label Sep 27, 2022
@Vinz1911
Copy link
Sponsor Author

Vinz1911 commented Sep 27, 2022

So Problem also does NOT occur with the normal Spike Motors, I have it only with the Large ones.

It seems, this can be the Problem :D

EDIT:

If you just do:

motor.run(1000)

then you also can reproduce it, it starts accelerating fast for a second and then keeps running on a much slower speed

@laurensvalk
Copy link
Member

I can reproduce this, but it is separate from #664.

In #664, there is strictly an issue about the pre-computed trajectory. The reference position jumps, but the PID controller still does as it's told: it goes to the bad trajectory.

But in this issue we have e.g:

motor.run(1000)

then you also can reproduce it, it starts accelerating fast for a second and then keeps running on a much slower speed

So there is something wrong with the PID controller here.

@laurensvalk
Copy link
Member

laurensvalk commented Sep 29, 2022

Possibly the same cause. Run until stalled no longer works:

from pybricks.pupdevices import Motor
from pybricks.parameters import Port

steer = Motor(Port.A)
left_end = steer.run_until_stalled(200)
VID_20220929_165503.mp4

@laurensvalk
Copy link
Member

image

So there is something wrong with the PID controller here.

The torque output is overflowing.

@laurensvalk
Copy link
Member

It looks much better after the fix 😄

image

laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Oct 4, 2022
The intermediate result could overflow for a large value of (kp * err).

See pybricks/support#729
laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Oct 4, 2022
The intermediate result could overflow for a large value of (kp * err).

See pybricks/support#729
@laurensvalk
Copy link
Member

This build fixes the stall issue shown above.

It may or may not also fix the issue you saw.

@Vinz1911
Copy link
Sponsor Author

Vinz1911 commented Oct 4, 2022

This is absolutely Insane!!!

Your fix work very well, it's like driving the robot on rails!
Also on high RPM no problems at all :)

@laurensvalk
Copy link
Member

Sounds like you’ve discovered the full potential of the recent drive base updates we’ve been working on 😄

@laurensvalk
Copy link
Member

Out of curiosity, since you’re the probably one of the first to try the new drive base, what is it that you like in particular? The new features or mainly the precision and performance?

@laurensvalk
Copy link
Member

laurensvalk commented Oct 18, 2022

Run until stalled is now fixed as well, so I think we can close this.

Firmware link: https://github.com/pybricks/pybricks-micropython/actions/runs/3273918813

Pybricks v3.2 automation moved this from To do to Done Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: motors Issues involving motors
Projects
Pybricks v3.2
  
Done
Development

No branches or pull requests

2 participants