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
LinearSystemSim Constructor and method cleanup #6502
LinearSystemSim Constructor and method cleanup #6502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can run /format
to fix the formatting if you want
/format |
Your build seems to be failing because the exponential elevator sim example is broken |
That's weird because I didn't modify any of the exponential elevator sim example code |
It'll just be because you modified constructors or methods it used prolly |
So I replaced in the C++ version GetBatteryVoltage with a hardcoded 12.0 and that made the linux and macos builds complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this 12 being passed into a lot of the constructors, should that be made some kind of constant? Why is that number chosen?
/format |
2 similar comments
/format |
/format |
wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/ElevatorSim.java
Outdated
Show resolved
Hide resolved
/format |
@calcmogul EDIT: I found my mistake. I ran a local build with 6_V and the test still failed and on Windows this time |
/format |
We can either use a 1% tolerance, disable current draw to get exact numbers, or figure out how to properly compensate the sim. I'd prefer the third, but idk how to do it. |
What about this at line 44 EDIT: The test passes, but does this solution stay true to the purpose of the test |
/format |
What's failing on the CMake Mac OS build |
/format |
Okay. So I reverted DCMotorSimTest.cpp to its original state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the target branch to development since there's API breaking changes in this PR. Please rebase against development (e.g., git rebase -i development
).
/format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the clamping was moved out of LinearSystemSim because the input isn't necessarily voltage.
wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h
Outdated
Show resolved
Hide resolved
…tro2020/allwpilib into FurtherLinearSystemSimSimp
I think I've got everything back and in good shape w.r.t. the branch rebase and overall state. |
I'm sorry I didn't answer this sooner. That is the basic idea. getCurrentDraw was also moved for similar reasons. |
Should I merge current state of main into this or are there other concerns in this PR since it's been marked breaking? |
The breaking label means there's breaking changes to either the API or user-visible behavior. We use that label to track what to add to the next release's breaking changes list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The breaking changes are:
- The measurement standard deviations vector constructor argument was replaced with varargs in Java for improved ergonomics and performance. C++ is unchanged.
- LinearSystemSim's input clamping was moved to the derived class since the base class doesn't know the input limits; it just assumed 12.
Ah okay. I'm sorry to pester. This had just been sitting for a week and if there were any changes to be made I wanted to make them when I had the free time. Thank you |
Some merge conflicts to fix up. |
All Merge conflicts merged |
wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/ElevatorSimTest.java
Outdated
Show resolved
Hide resolved
wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/armsimulation/subsystems/Arm.java
Outdated
Show resolved
Hide resolved
…rSimTest.java Co-authored-by: Tyler Veness <calcmogul@gmail.com>
…rmsimulation/subsystems/Arm.java Co-authored-by: Tyler Veness <calcmogul@gmail.com>
/format |
wpilibj/src/test/java/edu/wpi/first/wpilibj/simulation/ElevatorSimTest.java
Outdated
Show resolved
Hide resolved
…rSimTest.java Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Modified Java constructors to take a variable number of measurement std devs argument with checks in place to make sure the right amount (or none) are passed into the constructor. All changes passed down to classes utilizing LinearSystemSim.
Removed excess constructors
Removed Java and C++ CurrentDrawAmps method as it doesn't belong in a generic (non electrical) linear system. Kept a non override version in all derived electrical classes.
EDIT: Also LinearSystemSim has now been made agnostic to electrical systems. Inputs don't have to be voltage. BatteryVoltage clamp function has been pushed down to electrical subclasses.