Class LinearSystemId

java.lang.Object
edu.wpi.first.math.system.plant.LinearSystemId

public final class LinearSystemId
extends Object
  • Method Details

    • createElevatorSystem

      public static LinearSystem<N2,​N1,​N1> createElevatorSystem​(DCMotor motor, double massKg, double radiusMeters, double G)
      Create a state-space model of an elevator system. The states of the system are [position, velocity]ᵀ, inputs are [voltage], and outputs are [position].
      Parameters:
      motor - The motor (or gearbox) attached to the arm.
      massKg - The mass of the elevator carriage, in kilograms.
      radiusMeters - The radius of thd driving drum of the elevator, in meters.
      G - The reduction between motor and drum, as a ratio of output to input.
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if massKg <= 0, radiusMeters <= 0, or G <= 0.
    • createFlywheelSystem

      public static LinearSystem<N1,​N1,​N1> createFlywheelSystem​(DCMotor motor, double jKgMetersSquared, double G)
      Create a state-space model of a flywheel system. The states of the system are [angular velocity], inputs are [voltage], and outputs are [angular velocity].
      Parameters:
      motor - The motor (or gearbox) attached to the arm.
      jKgMetersSquared - The moment of inertia J of the flywheel.
      G - The reduction between motor and drum, as a ratio of output to input.
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if jKgMetersSquared <= 0 or G <= 0.
    • createDrivetrainVelocitySystem

      public static LinearSystem<N2,​N2,​N2> createDrivetrainVelocitySystem​(DCMotor motor, double massKg, double rMeters, double rbMeters, double JKgMetersSquared, double G)
      Create a state-space model of a differential drive drivetrain. In this model, the states are [v_left, v_right]ᵀ, inputs are [V_left, V_right]ᵀ and outputs are [v_left, v_right]ᵀ.
      Parameters:
      motor - the gearbox representing the motors driving the drivetrain.
      massKg - the mass of the robot.
      rMeters - the radius of the wheels in meters.
      rbMeters - the radius of the base (half the track width) in meters.
      JKgMetersSquared - the moment of inertia of the robot.
      G - the gearing reduction as output over input.
      Returns:
      A LinearSystem representing a differential drivetrain.
      Throws:
      IllegalArgumentException - if m <= 0, r <= 0, rb <= 0, J <= 0, or G <= 0.
    • createSingleJointedArmSystem

      public static LinearSystem<N2,​N1,​N1> createSingleJointedArmSystem​(DCMotor motor, double jKgSquaredMeters, double G)
      Create a state-space model of a single jointed arm system. The states of the system are [angle, angular velocity], inputs are [voltage], and outputs are [angle].
      Parameters:
      motor - The motor (or gearbox) attached to the arm.
      jKgSquaredMeters - The moment of inertia J of the arm.
      G - The gearing between the motor and arm, in output over input. Most of the time this will be greater than 1.
      Returns:
      A LinearSystem representing the given characterized constants.
    • identifyVelocitySystem

      public static LinearSystem<N1,​N1,​N1> identifyVelocitySystem​(double kV, double kA)
      Identify a velocity system from it's kV (volts/(unit/sec)) and kA (volts/(unit/sec^2). These constants cam be found using SysId. The states of the system are [velocity], inputs are [voltage], and outputs are [velocity].

      The distance unit you choose MUST be an SI unit (i.e. meters or radians). You can use the Units class for converting between unit types.

      Parameters:
      kV - The velocity gain, in volts per (units per second)
      kA - The acceleration gain, in volts per (units per second squared)
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if kV <= 0 or kA <= 0.
      See Also:
      https://github.com/wpilibsuite/sysid
    • identifyPositionSystem

      public static LinearSystem<N2,​N1,​N1> identifyPositionSystem​(double kV, double kA)
      Identify a position system from it's kV (volts/(unit/sec)) and kA (volts/(unit/sec^2). These constants cam be found using SysId. The states of the system are [position, velocity]ᵀ, inputs are [voltage], and outputs are [position].

      The distance unit you choose MUST be an SI unit (i.e. meters or radians). You can use the Units class for converting between unit types.

      Parameters:
      kV - The velocity gain, in volts per (units per second)
      kA - The acceleration gain, in volts per (units per second squared)
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if kV <= 0 or kA <= 0.
      See Also:
      https://github.com/wpilibsuite/sysid
    • identifyDrivetrainSystem

      public static LinearSystem<N2,​N2,​N2> identifyDrivetrainSystem​(double kVLinear, double kALinear, double kVAngular, double kAAngular)
      Identify a standard differential drive drivetrain, given the drivetrain's kV and kA in both linear (volts/(meter/sec) and volts/(meter/sec^2)) and angular (volts/(meter/sec) and volts/(meter/sec^2)) cases. This can be found using SysId. The states of the system are [left velocity, right velocity]ᵀ, inputs are [left voltage, right voltage]ᵀ, and outputs are [left velocity, right velocity]ᵀ.
      Parameters:
      kVLinear - The linear velocity gain, volts per (meter per second).
      kALinear - The linear acceleration gain, volts per (meter per second squared).
      kVAngular - The angular velocity gain, volts per (meter per second).
      kAAngular - The angular acceleration gain, volts per (meter per second squared).
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, or kAAngular <= 0.
      See Also:
      https://github.com/wpilibsuite/sysid
    • identifyDrivetrainSystem

      public static LinearSystem<N2,​N2,​N2> identifyDrivetrainSystem​(double kVLinear, double kALinear, double kVAngular, double kAAngular, double trackwidth)
      Identify a standard differential drive drivetrain, given the drivetrain's kV and kA in both linear (volts/(meter/sec) and volts/(meter/sec^2)) and angular (volts/(radian/sec) and volts/(radian/sec^2)) cases. This can be found using SysId. The states of the system are [left velocity, right velocity]ᵀ, inputs are [left voltage, right voltage]ᵀ, and outputs are [left velocity, right velocity]ᵀ.
      Parameters:
      kVLinear - The linear velocity gain, volts per (meter per second).
      kALinear - The linear acceleration gain, volts per (meter per second squared).
      kVAngular - The angular velocity gain, volts per (radians per second).
      kAAngular - The angular acceleration gain, volts per (radians per second squared).
      trackwidth - The width of the drivetrain in meters.
      Returns:
      A LinearSystem representing the given characterized constants.
      Throws:
      IllegalArgumentException - if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, kAAngular <= 0, or trackwidth <= 0.
      See Also:
      https://github.com/wpilibsuite/sysid