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 carriage.
massKg - The mass of the elevator carriage, in kilograms.
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 flywheel.
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.
• createDCMotorSystem

public static LinearSystem<N2,​N1,​N2> createDCMotorSystem​(DCMotor motor, double JKgMetersSquared, double G)
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.
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 [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.
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)
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^2)
Returns:
A LinearSystem representing the given characterized constants.
Throws:
IllegalArgumentException - if kV <= 0 or kA <= 0.
https://github.com/wpilibsuite/sysid
• identifyPositionSystem

public 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²). 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.
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.
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.