first95 / FRC2020

Code base for 2020 robot, initialized with develop branch of 2019 repo.
MIT License
1 stars 1 forks source link

Develop a state estimation class that accounts for certain kinds of time offsets #26

Closed jwalthour closed 4 years ago

jwalthour commented 4 years ago

In the past, our control loops treat the most recent reading from a sensor as describing the state of reality at the present time. ("present", as in, the time at which the control loop is making a decision)

However, when treating our vision system as a sensor, the "sensor value" arrives at the control loop some time after the reality it describes (say 20ms for the sake of discussion). Most state estimation systems (I'm thinking Kalman filters) are capable of extrapolating a little bit into the future. So it wouldn't be a massive leap to account for the fact that, for example, the computed heading to the vision target is 20ms out of date. The control system would want to treat the state of the robot as being extrapolated 20ms into the future from that point.

I'm not sure if this enhancement will have any meaningful effect on closed-loop systems using vision as an input. But I think it's an interesting problem, so I may perform a simulation to evaluate how helpful this feature would be.

jwalthour commented 4 years ago

There are a lot of discussions out there that introduce Kalman filters. I found these ones useful:

https://www.intechopen.com/books/introduction-and-implementations-of-the-kalman-filter/introduction-to-kalman-filter-and-its-applications https://en.wikipedia.org/wiki/Kalman_filter

jwalthour commented 4 years ago

After reading a bunch of tutorials on kalman filters, I still didn't find I had a great understanding of how to configure them. But then I found this series that goes through them with a lot of figures: https://www.youtube.com/watch?v=mwn8xhgNpFY

This presenter explains something I missed: not only are Kalman filters meant to account for stochastic noise, you need to supply some information to the Kalman filter regarding the properties of the noise. (Specifically you need the variance of the noise). We aren't gonna have that information in advance of needing this state estimator.

jwalthour commented 4 years ago

Reference figure for this discussion: https://youtu.be/4OerJmPpkRg?t=359

It seems like the following pieces of information contribute to getting a better state estimate:

And to get anything from either a plain state observer or a kalman filter you need a "State transition matrix"

jwalthour commented 4 years ago

I'm thinking we're unlikely to need this