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

Add State Space Documentation #639

Merged
merged 66 commits into from Oct 3, 2020
Merged

Conversation

mcm001
Copy link
Contributor

@mcm001 mcm001 commented Apr 27, 2020

This PR is associated with wpilibsuite/allwpilib#2494

WIP: State-space documentation, to go with the state-space-v2 PR to allwpilib. Things still to do:

  • Basic state-space and LQR documentation
  • Video Hosting and build pipeline for animations with manim
  • Documentation for pose estimators
  • (more) filter documentation for the EKF and UKF
  • Documentation for C++/Java examples

@Daltz333
Copy link
Member

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

source/index.rst Outdated Show resolved Hide resolved
Copy link
Member

@calcmogul calcmogul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to need either a lot of glossary links or a whole section devoted to teaching terminology.

@mcm001 mcm001 force-pushed the state-space branch 2 times, most recently from bdabe7d to 4011931 Compare May 20, 2020 15:57
@Daltz333
Copy link
Member

I'd like to see more usage tutorials.

Aka: If you want to solve X, this is how you do it with state-space
Additionally, don't commit the .idea files.

Copy link
Member

@Starlight220 Starlight220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math (LaTeX) formatting isn't done in tooltip content. Therefore some tooltips have "(\mathbf{y})", etc.
Some more reviews coming in a few days, after I read the rest of the docs.

@mcm001 mcm001 force-pushed the state-space branch 3 times, most recently from 62991fc to 7d45f31 Compare August 25, 2020 20:07
Copy link
Contributor

@modelmat modelmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor nitpicks and requests for clarification.


Kalman filters are used to filter our velocity measurements using our state-space model. As our flywheel model is linear, we can use a Kalman filter to estimate the flywheel's velocity. WPILib's Kalman filter takes a ``LinearSystem`` (which we found above), along with standard deviations of model and sensor measurements. We can adjust how "smooth" our state estimate is by adjusting these weights. Larger state standard deviations will cause the filter to "distrust" our state estimate and favor new measurements more highly, while larger measurement standard deviations will do the opposite. In the case of a flywheel we start with a state standard deviation of 3 rad/s and a measurement standard deviation of 0.01 rad/s. These values are up to the user to choose -- these weights produced a filter that was tolerant to some noise but whose state estimate quickly reacted to external disturbances for *a* flywheel -- and should be tuned to create a filter that behaves well for your specific flywheel. Graphing states, measurements, inputs, references, and outputs over time is a great visual way to tune Kalman filters.

.. image:: images/filter_comparison.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can barely read the key on this graph. It's also (again) a very different style to the rest of the document and (most) of the other graphs.

The lines are also thin and hard to tell apart. It could be beneficial to have the x-axis range from [1600, 3000] to see more detail where the "action" happens.

Copy link
Contributor Author

@mcm001 mcm001 Sep 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spinup part is actually the most important part, as it shows that the kalman filter can laglessly filter data. I'm not sure I have the program that generated that graph anymore

mcm001 and others added 3 commits October 1, 2020 11:47
…-intro.rst

Co-authored-by: Dalton Smith <daltzsmith@gmail.com>
…-intro.rst

Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
…-intro.rst

Co-authored-by: Dalton Smith <daltzsmith@gmail.com>
@Daltz333 Daltz333 changed the title [WIP] State space Add State Space Documentation Oct 1, 2020
mcm001 and others added 2 commits October 1, 2020 12:09
…-intro.rst

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
mcm001 and others added 3 commits October 2, 2020 17:39
* Recreate original graph in matplotlib

* Use 4 subplots to show the differing behaviours of the four filters

Also, add a minimum y-value so the behaviour of the filter is clear.

* Move stdev information onto newline in axis title
…-observers.rst

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
@Daltz333 Daltz333 merged commit 9f9a01c into wpilibsuite:master Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants