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

    • Method Detail

      • update

        public void update​(double dtSeconds)
        Updates the simulation.
        Parameters:
        dtSeconds - The time between updates.
      • getOutput

        public Matrix<Outputs,​N1getOutput()
        Returns the current output of the plant.
        Returns:
        The current output of the plant.
      • getOutput

        public double getOutput​(int row)
        Returns an element of the current output of the plant.
        Parameters:
        row - The row to return.
        Returns:
        An element of the current output of the plant.
      • setInput

        public void setInput​(Matrix<Inputs,​N1> u)
        Sets the system inputs (usually voltages).
        Parameters:
        u - The system inputs.
      • setInput

        public void setInput​(int row,
                             double value)
        Sets the system inputs.
        Parameters:
        row - The row in the input matrix to set.
        value - The value to set the row to.
      • setInput

        public void setInput​(double... u)
        Sets the system inputs.
        Parameters:
        u - An array of doubles that represent the inputs of the system.
      • setState

        public void setState​(Matrix<States,​N1> state)
        Sets the system state.
        Parameters:
        state - The new state.
      • getCurrentDrawAmps

        public double getCurrentDrawAmps()
        Returns the current drawn by this simulated system. Override this method to add a custom current calculation.
        Returns:
        The current drawn by this simulated mechanism.
      • updateX

        protected Matrix<States,​N1updateX​(Matrix<States,​N1> currentXhat,
                                                  Matrix<Inputs,​N1> u,
                                                  double dtSeconds)
        Updates the state estimate of the system.
        Parameters:
        currentXhat - The current state estimate.
        u - The system inputs (usually voltage).
        dtSeconds - The time difference between controller updates.
        Returns:
        The new state.
      • clampInput

        protected Matrix<Inputs,​N1clampInput​(Matrix<Inputs,​N1> u)
        Clamp the input vector such that no element exceeds the given voltage. If any does, the relative magnitudes of the input will be maintained.
        Parameters:
        u - The input vector.
        Returns:
        The normalized input.