WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
frc::LinearSystemId Class Reference

Linear system ID utility functions. More...

#include <frc/system/plant/LinearSystemId.h>

Public Types

template<typename Distance >
using Velocity_t
 
template<typename Distance >
using Acceleration_t
 

Static Public Member Functions

static constexpr LinearSystem< 2, 1, 2 > ElevatorSystem (DCMotor motor, units::kilogram_t mass, units::meter_t radius, double gearing)
 Create a state-space model of the elevator system.
 
static constexpr LinearSystem< 2, 1, 2 > SingleJointedArmSystem (DCMotor motor, units::kilogram_square_meter_t J, 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].
 
template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 1, 1, 1 > IdentifyVelocitySystem (decltype(1_V/Velocity_t< Distance >(1)) kV, decltype(1_V/Acceleration_t< Distance >(1)) kA)
 Create a state-space model for a 1 DOF velocity system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).
 
template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 2, 1, 1 > IdentifyPositionSystem (decltype(1_V/Velocity_t< Distance >(1)) kV, decltype(1_V/Acceleration_t< Distance >(1)) kA)
 Create a state-space model for a 1 DOF position system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).
 
static constexpr LinearSystem< 2, 2, 2 > IdentifyDrivetrainSystem (decltype(1_V/1_mps) kVLinear, decltype(1_V/1_mps_sq) kALinear, decltype(1_V/1_mps) kVAngular, decltype(1_V/1_mps_sq) 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 constexpr LinearSystem< 2, 2, 2 > IdentifyDrivetrainSystem (decltype(1_V/1_mps) kVLinear, decltype(1_V/1_mps_sq) kALinear, decltype(1_V/1_rad_per_s) kVAngular, decltype(1_V/1_rad_per_s_sq) kAAngular, units::meter_t 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 constexpr LinearSystem< 1, 1, 1 > FlywheelSystem (DCMotor motor, units::kilogram_square_meter_t J, 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].
 
static constexpr LinearSystem< 2, 1, 2 > DCMotorSystem (DCMotor motor, units::kilogram_square_meter_t J, double gearing)
 Create a state-space model of a DC motor system.
 
template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 2, 1, 2 > DCMotorSystem (decltype(1_V/Velocity_t< Distance >(1)) kV, decltype(1_V/Acceleration_t< Distance >(1)) kA)
 Create a state-space model of a DC motor system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).
 
static constexpr LinearSystem< 2, 2, 2 > DrivetrainVelocitySystem (const DCMotor &motor, units::kilogram_t mass, units::meter_t r, units::meter_t rb, units::kilogram_square_meter_t J, double gearing)
 Create a state-space model of differential drive drivetrain.
 

Detailed Description

Linear system ID utility functions.

Member Typedef Documentation

◆ Acceleration_t

template<typename Distance >
using frc::LinearSystemId::Acceleration_t
Initial value:
Container for values which represent quantities of a given unit.
Definition base.h:1930
typename units::detail::inverse_impl< U >::type inverse
represents the inverse unit type of class U.
Definition base.h:1138
typename units::detail::compound_impl< U, Us... >::type compound_unit
Represents a unit type made up from other units.
Definition base.h:1438

◆ Velocity_t

Member Function Documentation

◆ DCMotorSystem() [1/2]

static constexpr LinearSystem< 2, 1, 2 > frc::LinearSystemId::DCMotorSystem ( DCMotor motor,
units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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
motorThe motor (or gearbox) attached to the system.
Jthe moment of inertia J of the DC motor.
gearingGear ratio from motor to output.
Throws:
std::domain_error if J <= 0 or gearing <= 0.
See also
https://github.com/wpilibsuite/sysid

◆ DCMotorSystem() [2/2]

template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 2, 1, 2 > frc::LinearSystemId::DCMotorSystem ( decltype(1_V/Velocity_t< Distance >(1)) kV,
decltype(1_V/Acceleration_t< Distance >(1)) kA )
inlinestaticconstexpr

Create a state-space model of a DC motor system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).

These constants can be found using SysId. the states of the system are [position, velocity], inputs are [voltage], and outputs are [position].

You MUST use an SI unit (i.e. meters or radians) for the Distance template argument. You may still use non-SI units (such as feet or inches) for the actual method arguments; they will automatically be converted to SI internally.

The parameters provided by the user are from this feedforward model:

u = K_v v + K_a a

Parameters
kVThe velocity gain, in volts/(unit/sec).
kAThe acceleration gain, in volts/(unit/sec²).
Throws:
std::domain_error if kV < 0 or kA <= 0.

◆ DrivetrainVelocitySystem()

static constexpr LinearSystem< 2, 2, 2 > frc::LinearSystemId::DrivetrainVelocitySystem ( const DCMotor & motor,
units::kilogram_t mass,
units::meter_t r,
units::meter_t rb,
units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

Create a state-space model of differential drive drivetrain.

In this model, the states are [left velocity, right velocity], the inputs are [left voltage, right voltage], and the outputs are [left velocity, right velocity]

Parameters
motorThe motor (or gearbox) driving the drivetrain.
massThe mass of the robot in kilograms.
rThe radius of the wheels in meters.
rbThe radius of the base (half of the track width), in meters.
JThe moment of inertia of the robot.
gearingGear ratio from motor to wheel.
Throws:
std::domain_error if mass <= 0, r <= 0, rb <= 0, J <= 0, or gearing <= 0.

◆ ElevatorSystem()

static constexpr LinearSystem< 2, 1, 2 > frc::LinearSystemId::ElevatorSystem ( DCMotor motor,
units::kilogram_t mass,
units::meter_t radius,
double gearing )
inlinestaticconstexpr

Create a state-space model of the elevator system.

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

Parameters
motorThe motor (or gearbox) attached to the carriage.
massThe mass of the elevator carriage, in kilograms.
radiusThe radius of the elevator's driving drum, in meters.
gearingGear ratio from motor to carriage.
Throws:
std::domain_error if mass <= 0, radius <= 0, or gearing <= 0.

◆ FlywheelSystem()

static constexpr LinearSystem< 1, 1, 1 > frc::LinearSystemId::FlywheelSystem ( DCMotor motor,
units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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
motorThe motor (or gearbox) attached to the flywheel.
JThe moment of inertia J of the flywheel.
gearingGear ratio from motor to flywheel.
Throws:
std::domain_error if J <= 0 or gearing <= 0.

◆ IdentifyDrivetrainSystem() [1/2]

static constexpr LinearSystem< 2, 2, 2 > frc::LinearSystemId::IdentifyDrivetrainSystem ( decltype(1_V/1_mps) kVLinear,
decltype(1_V/1_mps_sq) kALinear,
decltype(1_V/1_mps) kVAngular,
decltype(1_V/1_mps_sq) kAAngular )
inlinestaticconstexpr

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
kVLinearThe linear velocity gain in volts per (meters per second).
kALinearThe linear acceleration gain in volts per (meters per second squared).
kVAngularThe angular velocity gain in volts per (meters per second).
kAAngularThe angular acceleration gain in volts per (meters per second squared).
Throws:
domain_error if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, or kAAngular <= 0.
See also
https://github.com/wpilibsuite/sysid

◆ IdentifyDrivetrainSystem() [2/2]

static constexpr LinearSystem< 2, 2, 2 > frc::LinearSystemId::IdentifyDrivetrainSystem ( decltype(1_V/1_mps) kVLinear,
decltype(1_V/1_mps_sq) kALinear,
decltype(1_V/1_rad_per_s) kVAngular,
decltype(1_V/1_rad_per_s_sq) kAAngular,
units::meter_t trackwidth )
inlinestaticconstexpr

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
kVLinearThe linear velocity gain in volts per (meters per second).
kALinearThe linear acceleration gain in volts per (meters per second squared).
kVAngularThe angular velocity gain in volts per (radians per second).
kAAngularThe angular acceleration gain in volts per (radians per second squared).
trackwidthThe distance between the differential drive's left and right wheels, in meters.
Throws:
domain_error if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, kAAngular <= 0, or trackwidth <= 0.
See also
https://github.com/wpilibsuite/sysid

◆ IdentifyPositionSystem()

template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 2, 1, 1 > frc::LinearSystemId::IdentifyPositionSystem ( decltype(1_V/Velocity_t< Distance >(1)) kV,
decltype(1_V/Acceleration_t< Distance >(1)) kA )
inlinestaticconstexpr

Create a state-space model for a 1 DOF position system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).

These constants can be found using SysId. the states of the system are [position, velocity], inputs are [voltage], and outputs are [position].

You MUST use an SI unit (i.e. meters or radians) for the Distance template argument. You may still use non-SI units (such as feet or inches) for the actual method arguments; they will automatically be converted to SI internally.

The parameters provided by the user are from this feedforward model:

u = K_v v + K_a a

Parameters
kVThe velocity gain, in volts/(unit/sec).
kAThe acceleration gain, in volts/(unit/sec²).
Throws:
std::domain_error if kV < 0 or kA <= 0.
See also
https://github.com/wpilibsuite/sysid

◆ IdentifyVelocitySystem()

template<typename Distance >
requires std::same_as<units::meter, Distance> || std::same_as<units::radian, Distance>
static constexpr LinearSystem< 1, 1, 1 > frc::LinearSystemId::IdentifyVelocitySystem ( decltype(1_V/Velocity_t< Distance >(1)) kV,
decltype(1_V/Acceleration_t< Distance >(1)) kA )
inlinestaticconstexpr

Create a state-space model for a 1 DOF velocity system from its kV (volts/(unit/sec)) and kA (volts/(unit/sec²)).

These constants can be found using SysId. The states of the system are [velocity], inputs are [voltage], and outputs are [velocity].

You MUST use an SI unit (i.e. meters or radians) for the Distance template argument. You may still use non-SI units (such as feet or inches) for the actual method arguments; they will automatically be converted to SI internally.

The parameters provided by the user are from this feedforward model:

u = K_v v + K_a a

Parameters
kVThe velocity gain, in volts/(unit/sec).
kAThe acceleration gain, in volts/(unit/sec²).
Throws:
std::domain_error if kV < 0 or kA <= 0.
See also
https://github.com/wpilibsuite/sysid

◆ SingleJointedArmSystem()

static constexpr LinearSystem< 2, 1, 2 > frc::LinearSystemId::SingleJointedArmSystem ( DCMotor motor,
units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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
motorThe motor (or gearbox) attached to the arm.
JThe moment of inertia J of the arm.
gearingGear ratio from motor to arm.
Throws:
std::domain_error if J <= 0 or gearing <= 0.

The documentation for this class was generated from the following file: