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

Make LinearSystemId functions return LinearSystem with fully observable state #6513

Open
calcmogul opened this issue Apr 13, 2024 · 7 comments
Labels
component: wpimath Math library type: fix Iterations on existing features or infrastructure.

Comments

@calcmogul
Copy link
Member

calcmogul commented Apr 13, 2024

LinearSystemId.IdentifyPositionSystem() returns a LinearSystem<2, 1, 1>, which is incompatible with the physics simulation classes.

Instead, it should return a LinearSystem<2, 1, 2>, and LinearSystem should have a function for slicing the states, inputs, and outputs so that it can produce a LinearSystem<2, 1, 1> for use with a Kalman filter.

@calcmogul calcmogul added component: wpimath Math library type: fix Iterations on existing features or infrastructure. labels Apr 13, 2024
@narmstro2020
Copy link
Contributor

I've wanted this fix for a bit myself. Seemed like a weird gap after reading all of the documentation on the subject.
I can take a whack at it. This should also apply to createElevatorSystem and createSingleJointedArmSystem. Flywheel, DCMotor, and the DriveTrain should be left alone if I'm not mistaken?

@calcmogul
Copy link
Member Author

Yea, those three already do the correct thing.

@narmstro2020
Copy link
Contributor

On a marginally related subject I'd also like to take the type to add a WheelSim class that simulates something like a drive wheel. It would effectively be the same as DCMotorSim, but reading out linear units instead of angular ones.

@calcmogul
Copy link
Member Author

calcmogul commented Apr 27, 2024

When would that be used? Seems like a lot of API/library overhead for a single scalar multiplication on the user side.

@narmstro2020
Copy link
Contributor

My use case would be in terms of simulating a drive wheel given starting with kV and kA values in VoltsPerMPS instead of RadPerSec.

Perhaps a constructor that takes in kV and kA in the linear units along with a conversion factor in the existing DCMotorSim class?

@calcmogul
Copy link
Member Author

calcmogul commented Apr 27, 2024

A constructor overload like that is a non-starter in C++ because it isn't unit-safe.

I'm also hesitant about a WheelSim class because it bloats the API with overlapping functionality.

@narmstro2020
Copy link
Contributor

Okay. I'm content without. Just an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpimath Math library type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

No branches or pull requests

2 participants