Class Models

java.lang.Object
org.wpilib.math.system.Models

public final class Models extends Object
Linear system factories.
  • Method Details

    • flywheelFromPhysicalConstants

      public static LinearSystem<N1,N1,N1> flywheelFromPhysicalConstants(DCMotor motor, double J, double gearing)
      Creates a flywheel state-space model from physical constants.

      The states are [angular velocity], the inputs are [voltage], and the outputs are [angular velocity].

      Parameters:
      motor - The motor (or gearbox) attached to the flywheel.
      J - The moment of inertia J of the flywheel.
      gearing - Gear ratio from motor to flywheel (greater than 1 is a reduction).
      Returns:
      Flywheel state-space model.
      Throws:
      IllegalArgumentException - if J <= 0 or gearing <= 0.
    • flywheelFromSysId

      public static LinearSystem<N1,N1,N1> flywheelFromSysId(double kV, double kA)
      Creates a flywheel state-space model from SysId constants kᵥ (V/(rad/s)) and kₐ (V/(rad/s²)) from the feedforward model u = kᵥv + kₐa.

      The states are [velocity], the inputs are [voltage], and the outputs are [velocity].

      Parameters:
      kV - The velocity gain, in V/(rad/s).
      kA - The acceleration gain, in V/(rad/s²).
      Returns:
      Flywheel state-space model.
      Throws:
      IllegalArgumentException - if kV < 0 or kA <= 0.
      See Also:
    • elevatorFromPhysicalConstants

      public static LinearSystem<N2,N1,N2> elevatorFromPhysicalConstants(DCMotor motor, double mass, double radius, double gearing)
      Creates an elevator state-space model from physical constants.

      The states are [position, velocity], the inputs are [voltage], and the outputs are [position, velocity].

      Parameters:
      motor - The motor (or gearbox) attached to the carriage.
      mass - The mass of the elevator carriage, in kilograms.
      radius - The radius of the elevator's driving drum, in meters.
      gearing - Gear ratio from motor to carriage (greater than 1 is a reduction).
      Returns:
      Elevator state-space model.
      Throws:
      IllegalArgumentException - if mass <= 0, radius <= 0, or gearing <= 0.
    • elevatorFromSysId

      public static LinearSystem<N2,N1,N2> elevatorFromSysId(double kV, double kA)
      Creates an elevator state-space model from SysId constants kᵥ (V/(m/s)) and kₐ (V/(m/s²)) from the feedforward model u = kᵥv + kₐa.

      The states are [position, velocity], the inputs are [voltage], and the outputs are [position, velocity].

      Parameters:
      kV - The velocity gain, in V/(m/s).
      kA - The acceleration gain, in V/(m/s²).
      Returns:
      Elevator state-space model.
      Throws:
      IllegalArgumentException - if kV < 0 or kA <= 0.
      See Also:
    • singleJointedArmFromPhysicalConstants

      public static LinearSystem<N2,N1,N2> singleJointedArmFromPhysicalConstants(DCMotor motor, double J, double gearing)
      Create a single-jointed arm state-space model from physical constants.

      The states are [angle, angular velocity], the inputs are [voltage], and the outputs are [angle, angular velocity].

      Parameters:
      motor - The motor (or gearbox) attached to the arm.
      J - The moment of inertia J of the arm.
      gearing - Gear ratio from motor to arm (greater than 1 is a reduction).
      Returns:
      Single-jointed arm state-space model.
      Throws:
      IllegalArgumentException - if J <= 0 or gearing <= 0.
    • singleJointedArmFromSysId

      public static LinearSystem<N2,N1,N2> singleJointedArmFromSysId(double kV, double kA)
      Creates a single-jointed arm state-space model from SysId constants kᵥ (V/(rad/s)) and kₐ (V/(rad/s²)) from the feedforward model u = kᵥv + kₐa.

      The states are [position, velocity], the inputs are [voltage], and the outputs are [position, velocity].

      Parameters:
      kV - The velocity gain, in volts/(unit/sec).
      kA - The acceleration gain, in volts/(unit/sec²).
      Returns:
      Single-jointed arm state-space model.
      Throws:
      IllegalArgumentException - if kV < 0 or kA <= 0.
      See Also:
    • differentialDriveFromPhysicalConstants

      public static LinearSystem<N2,N2,N2> differentialDriveFromPhysicalConstants(DCMotor motor, double mass, double r, double rb, double J, double gearing)
      Creates a differential drive state-space model from physical constants.

      The states are [left velocity, right velocity], the inputs are [left voltage, right voltage], and the outputs are [left velocity, right velocity].

      Parameters:
      motor - The motor (or gearbox) driving the drivetrain.
      mass - The mass of the robot in kilograms.
      r - The radius of the wheels in meters.
      rb - The radius of the base (half of the trackwidth), in meters.
      J - The moment of inertia of the robot.
      gearing - Gear ratio from motor to wheel (greater than 1 is a reduction).
      Returns:
      Differential drive state-space model.
      Throws:
      IllegalArgumentException - if mass <= 0, r <= 0, rb <= 0, J <= 0, or gearing <= 0.
    • differentialDriveFromSysId

      public static LinearSystem<N2,N2,N2> differentialDriveFromSysId(double kVLinear, double kALinear, double kVAngular, double kAAngular)
      Creates a differential drive state-space model from SysId constants kᵥ and kₐ in both linear {(V/(m/s), (V/(m/s²))} and angular {(V/(rad/s), (V/(rad/s²))} cases.

      The states are [left velocity, right velocity], the inputs are [left voltage, right voltage], and the outputs are [left velocity, right velocity].

      Parameters:
      kVLinear - The linear velocity gain in volts per (meters per second).
      kALinear - The linear acceleration gain in volts per (meters per second squared).
      kVAngular - The angular velocity gain in volts per (meters per second).
      kAAngular - The angular acceleration gain in volts per (meters per second squared).
      Returns:
      Differential drive state-space model.
      Throws:
      IllegalArgumentException - if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, or kAAngular <= 0.
      See Also:
    • differentialDriveFromSysId

      public static LinearSystem<N2,N2,N2> differentialDriveFromSysId(double kVLinear, double kALinear, double kVAngular, double kAAngular, double trackwidth)
      Creates a differential drive state-space model from SysId constants kᵥ and kₐ in both linear {(V/(m/s), (V/(m/s²))} and angular {(V/(rad/s), (V/(rad/s²))} cases.

      The states are [left velocity, right velocity], the inputs are [left voltage, right voltage], and the outputs are [left velocity, right velocity].

      Parameters:
      kVLinear - The linear velocity gain in volts per (meters per second).
      kALinear - The linear acceleration gain in volts per (meters per second squared).
      kVAngular - The angular velocity gain in volts per (radians per second).
      kAAngular - The angular acceleration gain in volts per (radians per second squared).
      trackwidth - The distance between the differential drive's left and right wheels, in meters.
      Returns:
      Differential drive state-space model.
      Throws:
      IllegalArgumentException - if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, kAAngular <= 0, or trackwidth <= 0.
      See Also: