-
Notifications
You must be signed in to change notification settings - Fork 133
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
[Swerve Setpoint Generator] Limit max speed when voltage sags #931
base: main
Are you sure you want to change the base?
Conversation
This prevents an edge case where the torque limit breaks when the desired velocity is not possible for the motor given the current max supply voltage.
These changes would allow the setpoint generator to generate setpoints that are not attainable for the robot. Desaturating the modules based on the voltage would limit the speed to a maximum that it can't necessarily decelerate to because the desaturation does not take the motor torque/wheel friction into account. The ability for the motor torque to be negative is also important because that is what will cause the robot to slow down when the drive motor is moving faster than the battery voltage would allow. Additionally, #930 sort of supersedes this PR by allowing the user to specify a static voltage to avoid the behavior of using a dynamic voltage. |
I'm also not really sure what the graphs you posted are showing, so if I am missing some other issue that still persists, let me know. |
Sorry for not adding an explanation to the graphs. The first graph shows the setpoint velocity making a discontinuous jump when voltage sags below 12 volts, as the drive acceleration constraint stops taking effect due to The second graph got deleted from the initial post, as it was implementation error in a separate unrelated modification I made.
From my testing in simulation with these changes, the setpoint can still decelerate when the voltage sags, even in a unreasonable scenario of dropping 4 volts in 1 tick. In the above image, I have a trigger bound such that when the button is pressed, the supply voltage fed into the generator is subtracted by 4. It's initially held, then released, then held again. Blue is setpoint, yellow is actual. If accounting for battery internal capacitance and a less extreme voltage sag, the deceleration is more gradual. |
Oh interesting. I’ll reopen this for now and do some testing with it. |
Ok so this will need to be updated a bit for some changes made to the generator, and needs the same changes made to the new python version. I can help with translation if needed. |
What autoformatter does PPLib Python use? |
I haven’t set one up yet. I just typically use the Code -> Format Code option in PyCharm. If you don’t use that then don’t worry about it. |
So it looks like the python version is missing the current draw limits. This will also need to be ported to the C++ version as well which was just merged |
This prevents an edge case where the torque limit breaks when the desired velocity is not possible for the motor given the current max supply voltage.