Class LinearPlantInversionFeedforward<States extends Num,​Inputs extends Num,​Outputs extends Num>

java.lang.Object
edu.wpi.first.math.controller.LinearPlantInversionFeedforward<States,​Inputs,​Outputs>

public class LinearPlantInversionFeedforward<States extends Num,​Inputs extends Num,​Outputs extends Num>
extends Object
Constructs a plant inversion model-based feedforward from a LinearSystem.

The feedforward is calculated as u_ff = B+ (r_k+1 - A r_k) , where B+ is the pseudoinverse of B.

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

  • Constructor Details

  • Method Details

    • getUff

      public Matrix<Inputs,​N1> getUff()
      Returns the previously calculated feedforward as an input vector.
      Returns:
      The calculated feedforward.
    • getUff

      public double getUff​(int row)
      Returns an element of the previously calculated feedforward.
      Parameters:
      row - Row of uff.
      Returns:
      The row of the calculated feedforward.
    • getR

      public Matrix<States,​N1> getR()
      Returns the current reference vector r.
      Returns:
      The current reference vector.
    • getR

      public double getR​(int row)
      Returns an element of the current reference vector r.
      Parameters:
      row - Row of r.
      Returns:
      The row of the current reference vector.
    • reset

      public void reset​(Matrix<States,​N1> initialState)
      Resets the feedforward with a specified initial state vector.
      Parameters:
      initialState - The initial state vector.
    • reset

      public void reset()
      Resets the feedforward with a zero initial state vector.
    • calculate

      public Matrix<Inputs,​N1> calculate​(Matrix<States,​N1> nextR)
      Calculate the feedforward with only the desired future reference. This uses the internally stored "current" reference.

      If this method is used the initial state of the system is the one set using reset(Matrix). If the initial state is not set it defaults to a zero vector.

      Parameters:
      nextR - The reference state of the future timestep (k + dt).
      Returns:
      The calculated feedforward.
    • calculate

      public Matrix<Inputs,​N1> calculate​(Matrix<States,​N1> r, Matrix<States,​N1> nextR)
      Calculate the feedforward with current and future reference vectors.
      Parameters:
      r - The reference state of the current timestep (k).
      nextR - The reference state of the future timestep (k + dt).
      Returns:
      The calculated feedforward.