Class LinearSystemId
public final class LinearSystemId extends Object
-
Method Summary
Modifier and Type Method Description static LinearSystem<N2,N1,N2>
createDCMotorSystem(double kV, double kA)
Create a state-space model of a DC motor system.static LinearSystem<N2,N1,N2>
createDCMotorSystem(DCMotor motor, double JKgMetersSquared, double gearing)
Create a state-space model of a DC motor system.static LinearSystem<N2,N2,N2>
createDrivetrainVelocitySystem(DCMotor motor, double massKg, double rMeters, double rbMeters, double JKgMetersSquared, double gearing)
Create a state-space model of a differential drive drivetrain.static LinearSystem<N2,N1,N1>
createElevatorSystem(DCMotor motor, double massKg, double radiusMeters, double gearing)
Create a state-space model of an elevator system.static LinearSystem<N1,N1,N1>
createFlywheelSystem(DCMotor motor, double JKgMetersSquared, double gearing)
Create a state-space model of a flywheel system.static LinearSystem<N2,N1,N1>
createSingleJointedArmSystem(DCMotor motor, double JKgSquaredMeters, double gearing)
Create a state-space model of a single jointed arm system.static LinearSystem<N2,N2,N2>
identifyDrivetrainSystem(double kVLinear, double kALinear, double kVAngular, double kAAngular)
Identify a differential drive drivetrain given the drivetrain's kV and kA in both linear {(volts/(meter/sec), (volts/(meter/sec²))} and angular {(volts/(radian/sec)), (volts/(radian/sec²))} cases.static LinearSystem<N2,N2,N2>
identifyDrivetrainSystem(double kVLinear, double kALinear, double kVAngular, double kAAngular, double trackwidth)
Identify a differential drive drivetrain given the drivetrain's kV and kA in both linear {(volts/(meter/sec)), (volts/(meter/sec²))} and angular {(volts/(radian/sec)), (volts/(radian/sec²))} cases.static LinearSystem<N2,N1,N1>
identifyPositionSystem(double kV, double kA)
Create a state-space model for a 1 DOF position system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²).static LinearSystem<N1,N1,N1>
identifyVelocitySystem(double kV, double kA)
Create a state-space model for a 1 DOF velocity system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²).
-
Method Details
-
createElevatorSystem
public static LinearSystem<N2,N1,N1> createElevatorSystem(DCMotor motor, double massKg, double radiusMeters, double gearing)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 carriage.massKg
- The mass of the elevator carriage, in kilograms.radiusMeters
- The radius of the elevator's driving drum, in meters.gearing
- 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 gearing <= 0.
-
createFlywheelSystem
public static LinearSystem<N1,N1,N1> createFlywheelSystem(DCMotor motor, double JKgMetersSquared, double gearing)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 flywheel.JKgMetersSquared
- The moment of inertia J of the flywheel.gearing
- 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 gearing <= 0.
-
createDCMotorSystem
public static LinearSystem<N2,N1,N2> createDCMotorSystem(DCMotor motor, double JKgMetersSquared, double gearing)Create a state-space model of a DC motor system. The states of the system are [angular position, angular velocity], inputs are [voltage], and outputs are [angular position, angular velocity].- Parameters:
motor
- The motor (or gearbox) attached to system.JKgMetersSquared
- The moment of inertia J of the DC motor.gearing
- 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 gearing <= 0.
-
createDCMotorSystem
Create a state-space model of a DC motor system. The states of the system are [angular position, angular velocity], inputs are [voltage], and outputs are [angular position, angular 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.The parameters provided by the user are from this feedforward model:
u = K_v v + K_a a
- Parameters:
kV
- The velocity gain, in volts/(unit/sec)kA
- The acceleration gain, in volts/(unit/sec²)- Returns:
- A LinearSystem representing the given characterized constants.
- Throws:
IllegalArgumentException
- if kV < 0 or kA <= 0.- See Also:
- https://github.com/wpilibsuite/sysid
-
createDrivetrainVelocitySystem
public static LinearSystem<N2,N2,N2> createDrivetrainVelocitySystem(DCMotor motor, double massKg, double rMeters, double rbMeters, double JKgMetersSquared, double gearing)Create a state-space model of a differential drive drivetrain. In this model, the states are [left velocity, right velocity]ᵀ, inputs are [left voltage, right voltage]ᵀ, and outputs are [left velocity, right velocity]ᵀ.- Parameters:
motor
- The motor (or gearbox) driving the drivetrain.massKg
- The mass of the robot in kilograms.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.gearing
- 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 gearing <= 0.
-
createSingleJointedArmSystem
public static LinearSystem<N2,N1,N1> createSingleJointedArmSystem(DCMotor motor, double JKgSquaredMeters, double gearing)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.gearing
- 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
Create a state-space model for a 1 DOF velocity system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²). 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.The parameters provided by the user are from this feedforward model:
u = K_v v + K_a a
- Parameters:
kV
- The velocity gain, in volts/(unit/sec)kA
- The acceleration gain, in volts/(unit/sec²)- Returns:
- A LinearSystem representing the given characterized constants.
- Throws:
IllegalArgumentException
- if kV < 0 or kA <= 0.- See Also:
- https://github.com/wpilibsuite/sysid
-
identifyPositionSystem
Create a state-space model for a 1 DOF position system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²). 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.The parameters provided by the user are from this feedforward model:
u = K_v v + K_a a
- Parameters:
kV
- The velocity gain, in volts/(unit/sec)kA
- The acceleration gain, in volts/(unit/sec²)- 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 differential drive drivetrain given the drivetrain's kV and kA in both linear {(volts/(meter/sec), (volts/(meter/sec²))} and angular {(volts/(radian/sec)), (volts/(radian/sec²))} cases. These constants can be found using SysId.States: [[left velocity], [right velocity]]
Inputs: [[left voltage], [right voltage]]
Outputs: [[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:
- 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 differential drive drivetrain given the drivetrain's kV and kA in both linear {(volts/(meter/sec)), (volts/(meter/sec²))} and angular {(volts/(radian/sec)), (volts/(radian/sec²))} cases. This can be found using SysId.States: [[left velocity], [right velocity]]
Inputs: [[left voltage], [right voltage]]
Outputs: [[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:
- 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
-