Skip to content

Commit

Permalink
added P I and D filters to PIDController, added StopWatch to help wit…
Browse files Browse the repository at this point in the history
…h time dependant filters, added LowPassFilter for real time filtering, updated some comments, added correct sign feature to on derivative
  • Loading branch information
Sam-Belliveau committed Jan 27, 2020
1 parent 93a1065 commit 392f125
Show file tree
Hide file tree
Showing 38 changed files with 921 additions and 564 deletions.
51 changes: 29 additions & 22 deletions docs/allclasses-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
catch(err) {
}
//-->
var data = {"i0":1,"i1":2,"i2":2,"i3":8,"i4":2,"i5":2,"i6":2,"i7":2,"i8":2,"i9":2,"i10":4,"i11":2,"i12":2,"i13":2,"i14":1,"i15":2,"i16":1,"i17":1,"i18":2,"i19":2,"i20":2,"i21":4,"i22":4,"i23":4,"i24":4,"i25":2,"i26":2,"i27":2,"i28":2,"i29":2,"i30":2,"i31":2,"i32":2,"i33":2,"i34":2,"i35":2,"i36":2,"i37":2,"i38":2,"i39":2,"i40":2,"i41":2,"i42":2,"i43":2,"i44":2,"i45":2,"i46":2};
var data = {"i0":1,"i1":2,"i2":2,"i3":8,"i4":2,"i5":2,"i6":2,"i7":2,"i8":2,"i9":2,"i10":4,"i11":2,"i12":2,"i13":2,"i14":1,"i15":2,"i16":1,"i17":1,"i18":2,"i19":2,"i20":4,"i21":4,"i22":4,"i23":4,"i24":2,"i25":2,"i26":2,"i27":2,"i28":2,"i29":2,"i30":2,"i31":2,"i32":2,"i33":2,"i34":2,"i35":2,"i36":2,"i37":2,"i38":2,"i39":2,"i40":2,"i41":2,"i42":2,"i43":2,"i44":2,"i45":2,"i46":2};
var tabs = {65535:["t0","All Classes"],1:["t1","Interface Summary"],2:["t2","Class Summary"],4:["t3","Enum Summary"],8:["t4","Exception Summary"]};
var altColor = "altColor";
var rowColor = "rowColor";
Expand Down Expand Up @@ -239,57 +239,58 @@ <h1 title="All&amp;nbsp;Classes" class="title">All&nbsp;Classes</h1>
</th>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/JerkLimit.html" title="class in com.stuypulse.stuylib.streams.filters">JerkLimit</a></td>
<th class="colLast" scope="row">
<div class="block">This class lets you limit the jerk a stream of inputs</div>
</th>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/network/limelight/Limelight.html" title="class in com.stuypulse.stuylib.network.limelight">Limelight</a></td>
<th class="colLast" scope="row">
<div class="block">This is a class that lets you interface with the limelight network table.</div>
</th>
</tr>
<tr id="i21" class="rowColor">
<tr id="i20" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/network/limelight/Limelight.CameraStream.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.CameraStream</a></td>
<th class="colLast" scope="row">&nbsp;</th>
</tr>
<tr id="i22" class="altColor">
<tr id="i21" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/network/limelight/Limelight.CamMode.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.CamMode</a></td>
<th class="colLast" scope="row">&nbsp;</th>
</tr>
<tr id="i23" class="rowColor">
<tr id="i22" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/network/limelight/Limelight.LEDMode.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.LEDMode</a></td>
<th class="colLast" scope="row">&nbsp;</th>
</tr>
<tr id="i24" class="altColor">
<tr id="i23" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/network/limelight/Limelight.SnapshotMode.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.SnapshotMode</a></td>
<th class="colLast" scope="row">&nbsp;</th>
</tr>
<tr id="i25" class="rowColor">
<tr id="i24" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/input/gamepads/Logitech.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech</a></td>
<th class="colLast" scope="row">
<div class="block">Implementation of Logitech Controller and its 2 Modes for the Gamepad Class</div>
</th>
</tr>
<tr id="i26" class="altColor">
<tr id="i25" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/input/gamepads/Logitech.DMode.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech.DMode</a></td>
<th class="colLast" scope="row">
<div class="block">There is a switch on the back of the controller this is for when the switch
is in the D position</div>
</th>
</tr>
<tr id="i27" class="rowColor">
<tr id="i26" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/input/gamepads/Logitech.XMode.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech.XMode</a></td>
<th class="colLast" scope="row">
<div class="block">There is a switch on the back of the controller this is for when the switch
is in the X position</div>
</th>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/LowPassFilter.html" title="class in com.stuypulse.stuylib.streams.filters">LowPassFilter</a></td>
<th class="colLast" scope="row">&nbsp;</th>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/MovingAverage.html" title="class in com.stuypulse.stuylib.streams.filters">MovingAverage</a></td>
<th class="colLast" scope="row">
<div class="block">Simple implementation of an Simple Moving Average</div>
<div class="block">Simple implementation of an Simple Moving Average

This is not time dependant, so the values will change if you change the rate
that you call this filter, the filter will not adapt for that.</div>
</th>
</tr>
<tr id="i29" class="rowColor">
Expand Down Expand Up @@ -344,8 +345,8 @@ <h1 title="All&amp;nbsp;Classes" class="title">All&nbsp;Classes</h1>
<tr id="i35" class="rowColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/OnDerivative.html" title="class in com.stuypulse.stuylib.streams.filters">OnDerivative</a></td>
<th class="colLast" scope="row">
<div class="block">This class lets you take a simple filter like "x * 0.5" and apply it
to the derivative of the IStream.</div>
<div class="block">This class lets you take a simple filter like "x * 0.5" and apply it to the
derivative of the IStream.</div>
</th>
</tr>
<tr id="i36" class="altColor">
Expand Down Expand Up @@ -375,13 +376,19 @@ <h1 title="All&amp;nbsp;Classes" class="title">All&nbsp;Classes</h1>
<div class="block">This class lets you rate limit a stream of inputs

That means that the value can not change more than a specified amount in one
update</div>
update

This is not time dependant, so the values will change if you change the rate
that you call this filter, the filter will not adapt for that.</div>
</th>
</tr>
<tr id="i40" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/RollingAverage.html" title="class in com.stuypulse.stuylib.streams.filters">RollingAverage</a></td>
<th class="colLast" scope="row">
<div class="block">Simple implementation of an Exponential Moving Average</div>
<div class="block">Simple implementation of an Exponential Moving Average

This is not time dependant, so the values will change if you change the rate
that you call this filter, the filter will not adapt for that.</div>
</th>
</tr>
<tr id="i41" class="rowColor">
Expand All @@ -405,10 +412,10 @@ <h1 title="All&amp;nbsp;Classes" class="title">All&nbsp;Classes</h1>
</th>
</tr>
<tr id="i44" class="altColor">
<td class="colFirst"><a href="com/stuypulse/stuylib/streams/filters/TimedRateLimit.html" title="class in com.stuypulse.stuylib.streams.filters">TimedRateLimit</a></td>
<td class="colFirst"><a href="com/stuypulse/stuylib/util/StopWatch.html" title="class in com.stuypulse.stuylib.util">StopWatch</a></td>
<th class="colLast" scope="row">
<div class="block">This class lets you rate limit a stream of inputs where the values are
limited based on time passed</div>
<div class="block">This StopWatch class helps classes who want their functions to be time
independant do that by giving them an easy way to get intervals of time.</div>
</th>
</tr>
<tr id="i45" class="rowColor">
Expand Down
4 changes: 2 additions & 2 deletions docs/allclasses.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/stuypulse/stuylib/streams/IStream.html" title="interface in com.stuypulse.stuylib.streams"><span class="interfaceName">IStream</span></a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/IStreamFilter.html" title="interface in com.stuypulse.stuylib.streams.filters"><span class="interfaceName">IStreamFilter</span></a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/IStreamFilterGroup.html" title="class in com.stuypulse.stuylib.streams.filters">IStreamFilterGroup</a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/JerkLimit.html" title="class in com.stuypulse.stuylib.streams.filters">JerkLimit</a></li>
<li><a href="com/stuypulse/stuylib/network/limelight/Limelight.html" title="class in com.stuypulse.stuylib.network.limelight">Limelight</a></li>
<li><a href="com/stuypulse/stuylib/network/limelight/Limelight.CameraStream.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.CameraStream</a></li>
<li><a href="com/stuypulse/stuylib/network/limelight/Limelight.CamMode.html" title="enum in com.stuypulse.stuylib.network.limelight">Limelight.CamMode</a></li>
Expand All @@ -49,6 +48,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/stuypulse/stuylib/input/gamepads/Logitech.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech</a></li>
<li><a href="com/stuypulse/stuylib/input/gamepads/Logitech.DMode.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech.DMode</a></li>
<li><a href="com/stuypulse/stuylib/input/gamepads/Logitech.XMode.html" title="class in com.stuypulse.stuylib.input.gamepads">Logitech.XMode</a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/LowPassFilter.html" title="class in com.stuypulse.stuylib.streams.filters">LowPassFilter</a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/MovingAverage.html" title="class in com.stuypulse.stuylib.streams.filters">MovingAverage</a></li>
<li><a href="com/stuypulse/stuylib/input/keyboard/NetKeyboard.html" title="class in com.stuypulse.stuylib.input.keyboard">NetKeyboard</a></li>
<li><a href="com/stuypulse/stuylib/input/gamepads/NetKeyGamepad.html" title="class in com.stuypulse.stuylib.input.gamepads">NetKeyGamepad</a></li>
Expand All @@ -65,7 +65,7 @@ <h1 class="bar">All&nbsp;Classes</h1>
<li><a href="com/stuypulse/stuylib/math/SLMath.html" title="class in com.stuypulse.stuylib.math">SLMath</a></li>
<li><a href="com/stuypulse/stuylib/network/SLNetworkTable.html" title="class in com.stuypulse.stuylib.network">SLNetworkTable</a></li>
<li><a href="com/stuypulse/stuylib/network/limelight/Solve3DResult.html" title="class in com.stuypulse.stuylib.network.limelight">Solve3DResult</a></li>
<li><a href="com/stuypulse/stuylib/streams/filters/TimedRateLimit.html" title="class in com.stuypulse.stuylib.streams.filters">TimedRateLimit</a></li>
<li><a href="com/stuypulse/stuylib/util/StopWatch.html" title="class in com.stuypulse.stuylib.util">StopWatch</a></li>
<li><a href="com/stuypulse/stuylib/math/Vector2D.html" title="class in com.stuypulse.stuylib.math">Vector2D</a></li>
<li><a href="com/stuypulse/stuylib/input/WPIGamepad.html" title="class in com.stuypulse.stuylib.input">WPIGamepad</a></li>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions docs/allpackages-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ <h1 title="All&amp;nbsp;Packages" class="title">All&nbsp;Packages</h1>
<th class="colFirst" scope="row"><a href="com/stuypulse/stuylib/streams/filters/package-summary.html">com.stuypulse.stuylib.streams.filters</a></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="com/stuypulse/stuylib/util/package-summary.html">com.stuypulse.stuylib.util</a></th>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
</table>
</li>
Expand Down
41 changes: 4 additions & 37 deletions docs/com/stuypulse/stuylib/control/Controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
catch(err) {
}
//-->
var data = {"i0":9,"i1":6,"i2":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var data = {"i0":6,"i1":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
Expand Down Expand Up @@ -175,27 +175,20 @@ <h3>Constructor Summary</h3>
</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>protected static double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getCurrentTime()">getCurrentTime</a></span>()</code></th>
<td class="colLast">
<div class="block">Get the current time relative time in seconds.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>abstract double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(double)">update</a></span>&#8203;(double&nbsp;error)</code></th>
<td class="colLast">
<div class="block">Update the controller with the error just measured</div>
</td>
</tr>
<tr id="i2" class="altColor">
<tr id="i1" class="rowColor">
<td class="colFirst"><code>double</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#update(double,double)">update</a></span>&#8203;(double&nbsp;measurement,
double&nbsp;setpoint)</code></th>
Expand Down Expand Up @@ -247,32 +240,6 @@ <h4>Controller</h4>
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="getCurrentTime()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getCurrentTime</h4>
<pre class="methodSignature">protected static final&nbsp;double&nbsp;getCurrentTime()</pre>
<div class="block">Get the current time relative time in seconds. This is accurate to the nano
second, but there are a few issues:

1. Results are meaningless if not compared to past result
2. Clocks on different threads give incorrect results
3. Even through its to the nano second, its not 100% accurate
4. Calls made more than 292 years appart will give incorrect results

But we use it any way for controllers because:

1. All time sampling is relative anyways
2. A controller is only run on 1 thread
3. Its better than getTimeMillis() due to resolution</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>time represented in seconds</dd>
</dl>
</li>
</ul>
<a id="update(double,double)">
<!-- -->
</a>
Expand Down
Loading

0 comments on commit 392f125

Please sign in to comment.