Class WPIMathJNI

    • Method Detail

      • discreteAlgebraicRiccatiEquation

        public static void discreteAlgebraicRiccatiEquation​(double[] A,
                                                            double[] B,
                                                            double[] Q,
                                                            double[] R,
                                                            int states,
                                                            int inputs,
                                                            double[] S)
        Solves the discrete alegebraic Riccati equation.
        Parameters:
        A - Array containing elements of A in row-major order.
        B - Array containing elements of B in row-major order.
        Q - Array containing elements of Q in row-major order.
        R - Array containing elements of R in row-major order.
        states - Number of states in A matrix.
        inputs - Number of inputs in B matrix.
        S - Array storage for DARE solution.
      • exp

        public static void exp​(double[] src,
                               int rows,
                               double[] dst)
        Computes the matrix exp.
        Parameters:
        src - Array of elements of the matrix to be exponentiated.
        rows - How many rows there are.
        dst - Array where the result will be stored.
      • pow

        public static void pow​(double[] src,
                               int rows,
                               double exponent,
                               double[] dst)
        Computes the matrix pow.
        Parameters:
        src - Array of elements of the matrix to be raised to a power.
        rows - How many rows there are.
        exponent - The exponent.
        dst - Array where the result will be stored.
      • isStabilizable

        public static boolean isStabilizable​(int states,
                                             int inputs,
                                             double[] A,
                                             double[] B)
        Returns true if (A, B) is a stabilizable pair.

        (A, B) is stabilizable if and only if the uncontrollable eigenvalues of A, if any, have absolute values less than one, where an eigenvalue is uncontrollable if rank(lambda * I - A, B) < n where n is the number of states.

        Parameters:
        states - the number of states of the system.
        inputs - the number of inputs to the system.
        A - System matrix.
        B - Input matrix.
        Returns:
        If the system is stabilizable.
      • fromPathweaverJson

        public static double[] fromPathweaverJson​(String path)
                                           throws IOException
        Loads a Pathweaver JSON.
        Parameters:
        path - The path to the JSON.
        Returns:
        A double array with the trajectory states from the JSON.
        Throws:
        IOException - if the JSON could not be read.
      • toPathweaverJson

        public static void toPathweaverJson​(double[] elements,
                                            String path)
                                     throws IOException
        Converts a trajectory into a Pathweaver JSON and saves it.
        Parameters:
        elements - The elements of the trajectory.
        path - The location to save the JSON to.
        Throws:
        IOException - if the JSON could not be written.
      • deserializeTrajectory

        public static double[] deserializeTrajectory​(String json)
        Deserializes a trajectory JSON into a double[] of trajectory elements.
        Parameters:
        json - The JSON containing the serialized trajectory.
        Returns:
        A double array with the trajectory states.
      • serializeTrajectory

        public static String serializeTrajectory​(double[] elements)
        Serializes the trajectory into a JSON string.
        Parameters:
        elements - The elements of the trajectory.
        Returns:
        A JSON containing the serialized trajectory.