Comments (6)
This was closed in #138, which was reverted... so I presume that this bug still exists? This should be reopened in that case.
from allwpilib.
Actually, we only need to keep a buffer of inputs. Here's some math:
a, b, c, and d are inputs. s is the setpoint. "s - a" is the error with respect to a.
Currently, we average the errors in GetAvgError():
avgError = ((s - a) + (s - b) + (s - c) + (s - d)) / 4
= (-(a - s) + -(b - s) + -(c - s) + -(d - s)) / 4
= -((a - s) + (b - s) + (c - s) + (d - s)) / 4
= -(a + b + c + d - 4 * s) / 4
= -(a + b + c + d - 4 * s) / 4
= -(a + b + c + d - 4 * s) / 4
= (4 * s - (a + b + c + d)) / 4
= s - (a + b + c + d) / 4
Therefore, GetAvgError() could instead return the current setpoint minus the input average. This would make anything using GetAvgError(), like OnTarget(), more robust to setpoint changes.
from allwpilib.
👍 for application of some basic math.
from allwpilib.
How should we go about fixing it this time? Apparently using doubles in a large FIR filter (moving average) causes rounding errors due to so many additions. We could approximate it with an IIR filter and avoid that problem. Using a cutoff frequency isn't necessarily intuitive, but it provides more tuning hints than the size of the FIR filter does. Teams would probably tune both by guessing and checking anyway.
from allwpilib.
Changing this to an IIR filter breaks the interface. If we're going to do interface breakage, I'd rather move the filter out of PIDController entirely because the state estimation should be separate from the controller. If the user does the following:
frc::Encoder encoder{1, 2};
frc::LinearDigitalFilter filter = frc::LinearDigitalFilter::SinglePoleIIR(&encoder, 0.3, 0.05);
frc::Spark motor{0};
PIDController pid{kP, kI, kD, &encoder, &motor};
the input is filtered instead of the error (which is more correct) and the user can decide what filtering would be best.
from allwpilib.
Fixed by #38.
from allwpilib.
Related Issues (20)
- cmake build fails in glfw with doxygen installed
- Make upstream_utils update patch list during format-patch command
- All GUI apps crash when built on Windows with CMake
- Add protobuf and struct support to apriltag
- imgui should not be built for Athena
- [epilogue] Allow logging period to be configurable HOT 1
- [Epilogue] Add support for persistant variables HOT 9
- [Epilogue] Improve opt-in logging support HOT 1
- Add usage reporting ID for epilogue
- Add usage reporting ID for the LEDPattern API
- Remove empty defaults from switch statements and expressions HOT 3
- Add libssh wrapper
- Epilogue warning in RapidReactCommandBot example
- LoggerTest.addMessageTest often fails due to race conditions
- RoboRIO team number setter: display/output log
- Memory Leek When Robot Container Object is Deconstructed HOT 7
- I Would Like to Volunteer HOT 1
- Add Catch2 to upstream_utils
- Add Upload Support for Persistent Tables HOT 1
- Generated command HID classes not included in C++ build, despite being included in the build.gradle HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from allwpilib.