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

[Question] Strange behaviour on Motor.run with acceleration limit #484

Closed
vascolp opened this issue Sep 16, 2021 · 4 comments
Closed

[Question] Strange behaviour on Motor.run with acceleration limit #484

vascolp opened this issue Sep 16, 2021 · 4 comments
Labels
bug Something isn't working software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) support Request for technical support for a problem that is not a bug or feature request topic: motors Issues involving motors

Comments

@vascolp
Copy link

vascolp commented Sep 16, 2021

Hi,

beta.pybricks.com loaded yesterday 2021-09-15, on a Technic hub, Technic Large or Extra Motor connected to any port.
Program:

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

m= Motor(Port.B)
m.control.limits(acceleration=35791) 
m.run(0)
wait(1000)
print('Bye')

This program does nothing, as expected.
However, if instead of 35791 you use 35792 or above, the motor will rotate at maximum speed during the wait....
Can you explain?

Thanks and Regards,
Continue th egood work!
Vasco

@vascolp vascolp added support Request for technical support for a problem that is not a bug or feature request triage Issues that have not been triaged yet labels Sep 16, 2021
@laurensvalk laurensvalk added bug Something isn't working topic: motors Issues involving motors and removed triage Issues that have not been triaged yet labels Sep 16, 2021
@laurensvalk
Copy link
Member

Thanks for opening this issue! This is a bug.

Can you explain?

Everything above 32767 is probably undefined behavior. This is due to the way we currently convert user input values before saving the motor settings. This is done with a library called libfixmath, which stores decimal numbers up to 32767 only.

We should probably add more checks to deal with large input numbers, or reconsider the use of this library.

We avoided certain checks in some of the more advanced settings until now, to save space on the hub.

@vascolp
Copy link
Author

vascolp commented Sep 17, 2021

Thank you for your explanation, I thought it would be something like that.
I tried high numbers for the acceleration because I could not find anything in the documentation about the limits of this parameter... I want the motors to work like PF motors, that is, start immediately at maximum speed.... what should I use?
I understand very well space the space saving issues, I intend to do a “big” program and that matters!
By the way, where can I know the space limits of each hub, how much space my program is using, and things like that?

@laurensvalk
Copy link
Member

If you just want the motors to run without speed control (like PF 1.0), you can use the Motor.dc method.

That's still not going to give you an acceleration of over 32767 degrees per second squared, but it's the fastest it can do 🚀

By the way, where can I know the space limits of each hub, how much space my program is using, and things like that?

You can read some tips and references to the documentation here: #483 .

@dlech dlech added the software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) label Jul 7, 2022
@laurensvalk
Copy link
Member

Accelerations up to 20,000 deg/s^2 are now supported.

I think we need to defer (exception) handling of higher values to a future release. See #831.

laurensvalk added a commit to pybricks/pybricks-micropython that referenced this issue Mar 17, 2023
Ensures limit setters respect numerical bounds imposed by the trajectory math.

Properly fixes pybricks/support#484.
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) support Request for technical support for a problem that is not a bug or feature request topic: motors Issues involving motors
Projects
None yet
Development

No branches or pull requests

3 participants