Class LinearSystem<States extends Num,Inputs extends Num,Outputs extends Num>

java.lang.Object
edu.wpi.first.math.system.LinearSystem<States,Inputs,Outputs>
Type Parameters:
States - Number of states.
Inputs - Number of inputs.
Outputs - Number of outputs.

public class LinearSystem<States extends Num,Inputs extends Num,Outputs extends Num> extends Object
A plant defined using state-space notation.

A plant is a mathematical model of a system's dynamics.

For more on the underlying math, read https://file.tavsys.net/control/controls-engineering-in-frc.pdf.

  • Constructor Details

  • Method Details

    • getA

      public Matrix<States,States> getA()
      Returns the system matrix A.
      Returns:
      the system matrix A.
    • getA

      public double getA(int row, int col)
      Returns an element of the system matrix A.
      Parameters:
      row - Row of A.
      col - Column of A.
      Returns:
      the system matrix A at (i, j).
    • getB

      public Matrix<States,Inputs> getB()
      Returns the input matrix B.
      Returns:
      the input matrix B.
    • getB

      public double getB(int row, int col)
      Returns an element of the input matrix B.
      Parameters:
      row - Row of B.
      col - Column of B.
      Returns:
      The value of the input matrix B at (i, j).
    • getC

      Returns the output matrix C.
      Returns:
      Output matrix C.
    • getC

      public double getC(int row, int col)
      Returns an element of the output matrix C.
      Parameters:
      row - Row of C.
      col - Column of C.
      Returns:
      the double value of C at the given position.
    • getD

      Returns the feedthrough matrix D.
      Returns:
      the feedthrough matrix D.
    • getD

      public double getD(int row, int col)
      Returns an element of the feedthrough matrix D.
      Parameters:
      row - Row of D.
      col - Column of D.
      Returns:
      The feedthrough matrix D at (i, j).
    • calculateX

      public Matrix<States,N1> calculateX(Matrix<States,N1> x, Matrix<Inputs,N1> clampedU, double dtSeconds)
      Computes the new x given the old x and the control input.

      This is used by state observers directly to run updates based on state estimate.

      Parameters:
      x - The current state.
      clampedU - The control input.
      dtSeconds - Timestep for model update.
      Returns:
      the updated x.
    • calculateY

      public Matrix<Outputs,N1> calculateY(Matrix<States,N1> x, Matrix<Inputs,N1> clampedU)
      Computes the new y given the control input.

      This is used by state observers directly to run updates based on state estimate.

      Parameters:
      x - The current state.
      clampedU - The control input.
      Returns:
      the updated output matrix Y.
    • slice

      public LinearSystem<States,Inputs,? extends Num> slice(int... outputIndices)
      Returns the LinearSystem with the outputs listed in outputIndices.

      This is used by state observers such as the Kalman Filter.

      Parameters:
      outputIndices - the list of output indices to include in the sliced system.
      Returns:
      the sliced LinearSystem with outputs set to row vectors of LinearSystem.
      Throws:
      IllegalArgumentException - if any outputIndices are outside the range of system outputs.
      IllegalArgumentException - if number of outputIndices exceeds the number of system outputs.
      IllegalArgumentException - if duplication exists in outputIndices.
    • toString

      public String toString()
      Overrides:
      toString in class Object