ControlAffinePlantInversionFeedforward_2_2

class wpimath.controller.ControlAffinePlantInversionFeedforward_2_2(*args, **kwargs)

Bases: pybind11_object

Constructs a control-affine plant inversion model-based feedforward from given model dynamics.

If given the vector valued function as f(x, u) where x is the state vector and u is the input vector, the B matrix(continuous input matrix) is calculated through a NumericalJacobian. In this case f has to be control-affine (of the form f(x) + Bu).

The feedforward is calculated as :strong:` u_ff = B:sup:+ (rDot - f(x)) , where :strong: B:sup:+ ` is the pseudoinverse of B.

This feedforward does not account for a dynamic B matrix, B is either determined or supplied when the feedforward is created and remains constant.

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

@tparam States The number of states. @tparam Inputs the number of inputs.

Overloaded function.

  1. __init__(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, f: Callable[[numpy.ndarray[numpy.float64[2, 1]], numpy.ndarray[numpy.float64[2, 1]]], numpy.ndarray[numpy.float64[2, 1]]], dt: seconds) -> None

Constructs a feedforward with given model dynamics as a function of state and input.

Parameters:
  • f – A vector-valued function of x, the state, and u, the input, that returns the derivative of the state vector. HAS to be control-affine (of the form f(x) + Bu).

  • dt – The timestep between calls of calculate().

  1. __init__(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, f: Callable[[numpy.ndarray[numpy.float64[2, 1]]], numpy.ndarray[numpy.float64[2, 1]]], B: numpy.ndarray[numpy.float64[2, 2]], dt: seconds) -> None

Constructs a feedforward with given model dynamics as a function of state, and the plant’s B matrix(continuous input matrix).

Parameters:
  • f – A vector-valued function of x, the state, that returns the derivative of the state vector.

  • B – Continuous input matrix of the plant being controlled.

  • dt – The timestep between calls of calculate().

R(*args, **kwargs)

Overloaded function.

  1. R(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2) -> numpy.ndarray[numpy.float64[2, 1]]

Returns the current reference vector r.

Returns:

The current reference vector.

  1. R(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, i: int) -> float

Returns an element of the reference vector r.

Parameters:

i – Row of r.

Returns:

The row of the current reference vector.

calculate(*args, **kwargs)

Overloaded function.

  1. calculate(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, nextR: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.float64[2, 1]]

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(const StateVector&). 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.

  1. calculate(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, r: numpy.ndarray[numpy.float64[2, 1]], nextR: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.float64[2, 1]]

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.

reset(*args, **kwargs)

Overloaded function.

  1. reset(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, initialState: numpy.ndarray[numpy.float64[2, 1]]) -> None

Resets the feedforward with a specified initial state vector.

Parameters:

initialState – The initial state vector.

  1. reset(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2) -> None

Resets the feedforward with a zero initial state vector.

uff(*args, **kwargs)

Overloaded function.

  1. uff(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2) -> numpy.ndarray[numpy.float64[2, 1]]

Returns the previously calculated feedforward as an input vector.

Returns:

The calculated feedforward.

  1. uff(self: wpimath._controls._controls.controller.ControlAffinePlantInversionFeedforward_2_2, i: int) -> float

Returns an element of the previously calculated feedforward.

Parameters:

i – Row of uff.

Returns:

The row of the calculated feedforward.