Skip to content

Laguerre Basis

examples/laguerre.py parameterizes the input of the mass-spring-damper with discrete Laguerre functions instead of a B-spline, using Parameterization.fromBasis(). It runs two forms of the controller in closed loop and prints the final position and tracking cost of each.

What the Example Demonstrates

  • Building a sampled basis matrix (discrete Laguerre functions) and passing it to Parameterization.fromBasis()
  • Preparing a custom basis: orthonormalizing the columns with numpy.linalg.qr (the MPC omits the input bounds of samples where the basis has decayed)
  • The deviation form \(\bm{u} = \bm{u}_{\mathrm{ss}} + \Psi \bm{c}\): the steady-state input \(\bm{u}_{\mathrm{ss}}\) is computed outside the library and enters through the model offset \(\bm{w}\) and shifted input limits
  • The direct form \(\bm{u} = \Psi \bm{c}\) for comparison, whose planned input decays to zero over the horizon

Custom Bases explains the forms, the requirements on a custom basis, and how a custom basis changes the input limits, input cost, and slew rates.

Run the Example

The example is Python-only and needs NumPy; it prints its results and does not log or plot.

python examples/laguerre.py

Results

direct    form: final position 0.8697, cost 11.395
deviation form: final position 1.0000, cost 9.129

The reference position is 1. The direct form settles short of it, because an input that decays to zero can not hold the steady force the spring needs; the deviation form reaches it at a lower cost.