Custom Data
Upload a recording with columns t, x1, x2, ... and u1, u2, .... A linear model
x[k+1] = A x[k] + B u[k] is fitted to it by least squares, and once it is found your data becomes a live simulation
you can push and steer with an LQR. Nothing leaves your browser.
1 · Arrive Turn a recording into a model, then drive the model as a live simulation with a controller you designed. about 10 min
2 · Inform What the page does
Least squares picks the A and B that best predict each sample from the one before. The dashed lines show those one-step predictions against your data; the fit percentage says how close. The poles show the model's own motions: any outside the unit circle is unstable.
The LQR trades state error (Q) against input effort (R) and gives a feedback u = −K(x − xref) plus the input that holds the reference. Once the model is found, the bottom plot becomes a simulation of it, running live: drag the reference, push the states, or switch the controller off to see the model on its own.
Some states may not be reachable. The input only moves a state directly or through the other states. If nothing connects a state to the input, no controller can steer it, and a recording that never excited it cannot show how it responds. The page counts the directions the input can move (reachable: r of n) and tells you when some are out of reach. The same goes for tracking: a state can be followed only if some steady input holds it at a constant value.
The recording is a plain-text CSV, described below.
CSV format
A header row, then one row per sample. Three kinds of column, named like this:
t,x1,x2,x3,x4,u1 0.00,0.00000,0.00000,0.08000,0.00000,-1.9060 0.05,0.00031,0.00112,0.08140,0.01560,-2.0420 0.10,0.00112,...
| Column | Rule |
|---|---|
| t | Time in seconds. One column, strictly increasing. |
| x1, x2, ... | The states, measured at each sample. A single state can be just x. |
| u1, u2, ... | The inputs, as commanded at each sample. A single input can be just u. The input in row k acts between row k and row k+1. |
Columns with any other name are ignored. Commas, semicolons or tabs separate the columns, and lines starting with
# are skipped. Values are plain numbers in your own units; the LQR gain comes out in those units. A row with an
empty cell is dropped. You need at least 20 complete rows. Evenly spaced times are best: if the spacing varies by more than
5%, the data is resampled onto the median spacing. The signals should wiggle around one operating point, since the model is linear.
Recording
LQR weights
Simulation
Result
Try it
- The page opens on an example: a cart-pole balanced by an LQR with a little dither, recorded through noisy sensors. How well does the model predict each state, noise and all?
- Look at the poles: is the model unstable on its own? Where do the poles go with the LQR?
- Watch the bottom plot: it is your model running live under the LQR. Drag the reference and the tracked state follows it.
- Press Push the states: how fast does the controller recover? Raise a Q weight and it recovers faster, at the cost of more input.
- Switch the controller off. Does the model sit still or run away? Compare with the poles.
- Change the tracked state. Some states may have no steady state of their own, or may not be reachable at all: read the reachable count above the weights.
- Download the example CSV, rename a state column (say
x3toy3) so it is ignored, and see what the model loses. Then try your own recording; Load the example brings the cart-pole back.