WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::math::Models Class Reference

Linear system factories. More...

#include <wpi/math/system/Models.hpp>

Public Types

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

Static Public Member Functions

static constexpr LinearSystem< 1, 1, 1 > FlywheelFromPhysicalConstants (DCMotor motor, wpi::units::kilogram_square_meter_t J, double gearing)
 Creates a flywheel state-space model from physical constants.
static constexpr LinearSystem< 1, 1, 1 > FlywheelFromSysId (decltype(1_V/1_rad_per_s) kV, decltype(1_V/1_rad_per_s_sq) 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.
static constexpr LinearSystem< 2, 1, 2 > ElevatorFromPhysicalConstants (DCMotor motor, wpi::units::kilogram_t mass, wpi::units::meter_t radius, double gearing)
 Creates an elevator state-space model from physical constants.
static constexpr LinearSystem< 2, 1, 2 > ElevatorFromSysId (decltype(1_V/1_mps) kV, decltype(1_V/1_mps_sq) 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.
static constexpr LinearSystem< 2, 1, 2 > SingleJointedArmFromPhysicalConstants (DCMotor motor, wpi::units::kilogram_square_meter_t J, double gearing)
 Create a single-jointed arm state-space model from physical constants.
static constexpr LinearSystem< 2, 1, 2 > SingleJointedArmFromSysId (decltype(1_V/1_rad_per_s) kV, decltype(1_V/1_rad_per_s_sq) 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.
static constexpr LinearSystem< 2, 2, 2 > DifferentialDriveFromPhysicalConstants (const DCMotor &motor, wpi::units::kilogram_t mass, wpi::units::meter_t r, wpi::units::meter_t rb, wpi::units::kilogram_square_meter_t J, double gearing)
 Creates a differential drive state-space model from physical constants.
static constexpr LinearSystem< 2, 2, 2 > DifferentialDriveFromSysId (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)
 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.
static constexpr LinearSystem< 2, 2, 2 > DifferentialDriveFromSysId (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, wpi::units::meter_t 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.

Detailed Description

Linear system factories.

Member Typedef Documentation

◆ Acceleration_t

template<typename Distance>
using wpi::math::Models::Acceleration_t
Initial value:
wpi::units::unit_t<wpi::units::compound_unit<
wpi::units::compound_unit<Distance,
wpi::units::inverse<wpi::units::seconds>>,
wpi::units::inverse<wpi::units::seconds>>>

◆ Velocity_t

template<typename Distance>
using wpi::math::Models::Velocity_t
Initial value:
wpi::units::unit_t<wpi::units::compound_unit<
Distance, wpi::units::inverse<wpi::units::seconds>>>

Member Function Documentation

◆ DifferentialDriveFromPhysicalConstants()

constexpr LinearSystem< 2, 2, 2 > wpi::math::Models::DifferentialDriveFromPhysicalConstants ( const DCMotor & motor,
wpi::units::kilogram_t mass,
wpi::units::meter_t r,
wpi::units::meter_t rb,
wpi::units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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
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 trackwidth), in meters.
JThe moment of inertia of the robot.
gearingGear ratio from motor to wheel (greater than 1 is a reduction).
Throws:
std::domain_error if mass <= 0, r <= 0, rb <= 0, J <= 0, or gearing <= 0.

◆ DifferentialDriveFromSysId() [1/2]

constexpr LinearSystem< 2, 2, 2 > wpi::math::Models::DifferentialDriveFromSysId ( 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

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
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/allwpilib/tree/main/sysid

◆ DifferentialDriveFromSysId() [2/2]

constexpr LinearSystem< 2, 2, 2 > wpi::math::Models::DifferentialDriveFromSysId ( 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,
wpi::units::meter_t trackwidth )
inlinestaticconstexpr

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
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/allwpilib/tree/main/sysid

◆ ElevatorFromPhysicalConstants()

constexpr LinearSystem< 2, 1, 2 > wpi::math::Models::ElevatorFromPhysicalConstants ( DCMotor motor,
wpi::units::kilogram_t mass,
wpi::units::meter_t radius,
double gearing )
inlinestaticconstexpr

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
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 (greater than 1 is a reduction).
Throws:
std::domain_error if mass <= 0, radius <= 0, or gearing <= 0.

◆ ElevatorFromSysId()

constexpr LinearSystem< 2, 1, 2 > wpi::math::Models::ElevatorFromSysId ( decltype(1_V/1_mps) kV,
decltype(1_V/1_mps_sq) kA )
inlinestaticconstexpr

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
kVThe velocity gain, in V/(m/s).
kAThe acceleration gain, in V/(m/s²).
Throws:
std::domain_error if kV < 0 or kA <= 0.
See also
https://github.com/wpilibsuite/allwpilib/tree/main/sysid

◆ FlywheelFromPhysicalConstants()

constexpr LinearSystem< 1, 1, 1 > wpi::math::Models::FlywheelFromPhysicalConstants ( DCMotor motor,
wpi::units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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

◆ FlywheelFromSysId()

constexpr LinearSystem< 1, 1, 1 > wpi::math::Models::FlywheelFromSysId ( decltype(1_V/1_rad_per_s) kV,
decltype(1_V/1_rad_per_s_sq) kA )
inlinestaticconstexpr

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
kVThe velocity gain, in V/(rad/s).
kAThe acceleration gain, in V/(rad/s²).
Throws:
std::domain_error if kV < 0 or kA <= 0.
See also
https://github.com/wpilibsuite/allwpilib/tree/main/sysid

◆ SingleJointedArmFromPhysicalConstants()

constexpr LinearSystem< 2, 1, 2 > wpi::math::Models::SingleJointedArmFromPhysicalConstants ( DCMotor motor,
wpi::units::kilogram_square_meter_t J,
double gearing )
inlinestaticconstexpr

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

◆ SingleJointedArmFromSysId()

constexpr LinearSystem< 2, 1, 2 > wpi::math::Models::SingleJointedArmFromSysId ( decltype(1_V/1_rad_per_s) kV,
decltype(1_V/1_rad_per_s_sq) kA )
inlinestaticconstexpr

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
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/allwpilib/tree/main/sysid

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