Skip to content

Commit

Permalink
Add test programs.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Nov 26, 2024
1 parent 37083bc commit 5c55e38
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,5 @@ <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>

<!--
MkDocs version : 1.5.3
Build Date UTC : 2024-11-26 16:43:48.484203+00:00
Build Date UTC : 2024-11-26 17:16:43.307063+00:00
-->
42 changes: 42 additions & 0 deletions docs/libs/filters/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,48 @@ <h4 id="usage_81">Usage</h4>
<li><code>z</code>: Measurement signal (Mx1)</li>
<li><code>reset</code>: Trigger to reset. Reset whenever <code>reset&gt;0</code></li>
</ul>
<h4 id="example-test-programs">Example test programs</h4>
<p>Demo 1 <code>(N=1, M=1)</code> (don't listen, just use oscilloscope):</p>
<pre><code>process = u, z : fi.kalman(N, M, B, R, H, Q, F, reset) : it.interpolate_linear(filteredAmt, z)
with {
B = 1.;
R = 0.1;
H = 1;
Q = .01;
F = la.identity(N);
reset = button(&quot;reset&quot;);

// Dimensions
N = 1; // State size
M = 1; // Measurement size

freq = hslider(&quot;Freq&quot;, 1, 0.01, 10, .01);
u = 0.; // constant input
trueState = os.osc(freq)*.5 + u;
noiseGain = hslider(&quot;Noise Gain&quot;, .1, 0, 1, .01);

filteredAmt = hslider(&quot;Filter Amount&quot;, 1, 0, 1, .01) : si.smoo;

measurementNoise = no.noise*noiseGain;
z = trueState + measurementNoise; // Observed state
</code></pre>
<p>Demo 2 <code>(N=2, M=1)</code> (don't listen, just use oscilloscope)</p>
<pre><code>process = u, z : fi.kalman(N, M, B, R, H, Q, F, reset)
with {
B = par(i, N, 0);
R = (0.1);
H = (1, 0);
Q = la.diag(2, par(i, N, .1));
F = la.identity(N);
reset = 0;
u = si.bus(M);
z = si.bus(M);

// Dimensions
N = 2; // State size
M = 1; // Measurement size
};
</code></pre>
<h4 id="references_21">References</h4>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Kalman_filter">https://en.wikipedia.org/wiki/Kalman_filter</a></li>
Expand Down
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

Binary file modified docs/sitemap.xml.gz
Binary file not shown.
48 changes: 48 additions & 0 deletions filters.lib
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,54 @@ kalmanEnv = environment {
// * `z`: Measurement signal (Mx1)
// * `reset`: Trigger to reset. Reset whenever `reset>0`
//
// #### Example test programs
// Demo 1 `(N=1, M=1)` (don't listen, just use oscilloscope):
//
// ```
// process = u, z : fi.kalman(N, M, B, R, H, Q, F, reset) : it.interpolate_linear(filteredAmt, z)
// with {
// B = 1.;
// R = 0.1;
// H = 1;
// Q = .01;
// F = la.identity(N);
// reset = button("reset");
//
// // Dimensions
// N = 1; // State size
// M = 1; // Measurement size
//
// freq = hslider("Freq", 1, 0.01, 10, .01);
// u = 0.; // constant input
// trueState = os.osc(freq)*.5 + u;
// noiseGain = hslider("Noise Gain", .1, 0, 1, .01);
//
// filteredAmt = hslider("Filter Amount", 1, 0, 1, .01) : si.smoo;
//
// measurementNoise = no.noise*noiseGain;
// z = trueState + measurementNoise; // Observed state
//};
// ```
//
// Demo 2 `(N=2, M=1)` (don't listen, just use oscilloscope)
//
// ```
// process = u, z : fi.kalman(N, M, B, R, H, Q, F, reset)
// with {
// B = par(i, N, 0);
// R = (0.1);
// H = (1, 0);
// Q = la.diag(2, par(i, N, .1));
// F = la.identity(N);
// reset = 0;
// u = si.bus(M);
// z = si.bus(M);
//
// // Dimensions
// N = 2; // State size
// M = 1; // Measurement size
// };
// ```
// #### References
// * <https://en.wikipedia.org/wiki/Kalman_filter>
// * <https://www.cs.unc.edu/~welch/kalman/index.html>
Expand Down

0 comments on commit 5c55e38

Please sign in to comment.