Models

class wpimath.Models

Bases: pybind11_object

Linear system factories.

static differentialDriveFromPhysicalConstants(motor: wpimath._wpimath.DCMotor, mass: wpimath.units.kilograms, r: wpimath.units.meters, rb: wpimath.units.meters, J: wpimath.units.kilogram_square_meters, gearing: SupportsFloat | SupportsIndex) wpimath._wpimath.LinearSystem_2_2_2

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). @throws std::domain_error if mass <= 0, r <= 0, rb <= 0, J <= 0, or gearing <= 0.

static differentialDriveFromSysId(*args, **kwargs)

Overloaded function.

  1. differentialDriveFromSysId(kVLinear: wpimath.units.volt_seconds_per_meter, kALinear: wpimath.units.volt_seconds_squared_per_meter, kVAngular: wpimath.units.volt_seconds_per_meter, kAAngular: wpimath.units.volt_seconds_squared_per_meter) -> wpimath._wpimath.LinearSystem_2_2_2

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). @throws domain_error if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, or kAAngular <= 0. @see <a href=”https://github.com/wpilibsuite/allwpilib/tree/main/sysid”>https://github.com/wpilibsuite/allwpilib/tree/main/sysid</a>

  1. differentialDriveFromSysId(kVLinear: wpimath.units.volt_seconds_per_meter, kALinear: wpimath.units.volt_seconds_squared_per_meter, kVAngular: wpimath.units.volt_seconds_per_radian, kAAngular: wpimath.units.volt_seconds_squared_per_radian, trackwidth: wpimath.units.meters) -> wpimath._wpimath.LinearSystem_2_2_2

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. @throws domain_error if kVLinear <= 0, kALinear <= 0, kVAngular <= 0, kAAngular <= 0, or trackwidth <= 0. @see <a href=”https://github.com/wpilibsuite/allwpilib/tree/main/sysid”>https://github.com/wpilibsuite/allwpilib/tree/main/sysid</a>

static elevatorFromPhysicalConstants(motor: wpimath._wpimath.DCMotor, mass: wpimath.units.kilograms, radius: wpimath.units.meters, gearing: SupportsFloat | SupportsIndex) wpimath._wpimath.LinearSystem_2_1_2

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). @throws std::domain_error if mass <= 0, radius <= 0, or gearing <= 0.

static elevatorFromSysId(kV: wpimath.units.volt_seconds_per_meter, kA: wpimath.units.volt_seconds_squared_per_meter) wpimath._wpimath.LinearSystem_2_1_2

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].

@throws std::domain_error if kV < 0 or kA <= 0. @see <a href=”https://github.com/wpilibsuite/allwpilib/tree/main/sysid”>https://github.com/wpilibsuite/allwpilib/tree/main/sysid</a>

Parameters:
  • kV – The velocity gain, in V/(m/s).

  • kA – The acceleration gain, in V/(m/s²).

static flywheelFromPhysicalConstants(motor: wpimath._wpimath.DCMotor, J: wpimath.units.kilogram_square_meters, gearing: SupportsFloat | SupportsIndex) wpimath._wpimath.LinearSystem_1_1_1

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). @throws std::domain_error if J <= 0 or gearing <= 0.

static flywheelFromSysId(kV: wpimath.units.volt_seconds_per_radian, kA: wpimath.units.volt_seconds_squared_per_radian) wpimath._wpimath.LinearSystem_1_1_1

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²). @throws std::domain_error if kV < 0 or kA <= 0. @see <a href=”https://github.com/wpilibsuite/allwpilib/tree/main/sysid”>https://github.com/wpilibsuite/allwpilib/tree/main/sysid</a>

static singleJointedArmFromPhysicalConstants(motor: wpimath._wpimath.DCMotor, J: wpimath.units.kilogram_square_meters, gearing: SupportsFloat | SupportsIndex) wpimath._wpimath.LinearSystem_2_1_2

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). @throws std::domain_error if J <= 0 or gearing <= 0.

static singleJointedArmFromSysId(kV: wpimath.units.volt_seconds_per_radian, kA: wpimath.units.volt_seconds_squared_per_radian) wpimath._wpimath.LinearSystem_2_1_2

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].

@throws std::domain_error if kV < 0 or kA <= 0. @see <a href=”https://github.com/wpilibsuite/allwpilib/tree/main/sysid”>https://github.com/wpilibsuite/allwpilib/tree/main/sysid</a>

Parameters:
  • kV – The velocity gain, in volts/(unit/sec).

  • kA – The acceleration gain, in volts/(unit/sec²).