SingleJointedArmSim
- class wpilib.simulation.SingleJointedArmSim(*args, **kwargs)
Bases:
LinearSystemSim_2_1_1
Represents a simulated arm mechanism.
Overloaded function.
__init__(self: wpilib.simulation._simulation.SingleJointedArmSim, system: wpimath._controls._controls.system.LinearSystem_2_1_1, gearbox: wpimath._controls._controls.plant.DCMotor, gearing: float, armLength: wpimath.units.meters, minAngle: wpimath.units.radians, maxAngle: wpimath.units.radians, simulateGravity: bool, startingAngle: wpimath.units.radians, measurementStdDevs: Annotated[list[float], FixedSize(1)] = [0.0]) -> None
Creates a simulated arm mechanism.
- Parameters:
system – The system representing this arm. This system can be created with LinearSystemId::SingleJointedArmSystem().
gearbox – The type and number of motors on the arm gearbox.
gearing – The gear ratio of the arm (numbers greater than 1 represent reductions).
armLength – The length of the arm.
minAngle – The minimum angle that the arm is capable of.
maxAngle – The maximum angle that the arm is capable of.
simulateGravity – Whether gravity should be simulated or not.
startingAngle – The initial position of the arm.
measurementStdDevs – The standard deviations of the measurements.
__init__(self: wpilib.simulation._simulation.SingleJointedArmSim, gearbox: wpimath._controls._controls.plant.DCMotor, gearing: float, moi: wpimath.units.kilogram_square_meters, armLength: wpimath.units.meters, minAngle: wpimath.units.radians, maxAngle: wpimath.units.radians, simulateGravity: bool, startingAngle: wpimath.units.radians, measurementStdDevs: Annotated[list[float], FixedSize(1)] = [0.0]) -> None
Creates a simulated arm mechanism.
- Parameters:
gearbox – The type and number of motors on the arm gearbox.
gearing – The gear ratio of the arm (numbers greater than 1 represent reductions).
moi – The moment of inertia of the arm. This can be calculated from CAD software.
armLength – The length of the arm.
minAngle – The minimum angle that the arm is capable of.
maxAngle – The maximum angle that the arm is capable of.
simulateGravity – Whether gravity should be simulated or not.
startingAngle – The initial position of the arm.
measurementStdDevs – The standard deviation of the measurement noise.
- static estimateMOI(length: wpimath.units.meters, mass: wpimath.units.kilograms) wpimath.units.kilogram_square_meters
Calculates a rough estimate of the moment of inertia of an arm given its length and mass.
- Parameters:
length – The length of the arm.
mass – The mass of the arm.
- Returns:
The calculated moment of inertia.
- getAngle() wpimath.units.radians
Returns the current arm angle.
- Returns:
The current arm angle.
- getAngleDegrees() wpimath.units.degrees
- getCurrentDraw() wpimath.units.amperes
Returns the arm current draw.
- Returns:
The arm current draw.
- getVelocity() wpimath.units.radians_per_second
Returns the current arm velocity.
- Returns:
The current arm velocity.
- getVelocityDps() wpimath.units.degrees_per_second
- hasHitLowerLimit() bool
Returns whether the arm has hit the lower limit.
- Returns:
Whether the arm has hit the lower limit.
- hasHitUpperLimit() bool
Returns whether the arm has hit the upper limit.
- Returns:
Whether the arm has hit the upper limit.
- setInputVoltage(voltage: wpimath.units.volts) None
Sets the input voltage for the arm.
- Parameters:
voltage – The input voltage.
- setState(angle: wpimath.units.radians, velocity: wpimath.units.radians_per_second) None
Sets the arm’s state. The new angle will be limited between the minimum and maximum allowed limits.
- Parameters:
angle – The new angle.
velocity – The new angular velocity.
- wouldHitLowerLimit(armAngle: wpimath.units.radians) bool
Returns whether the arm would hit the lower limit.
- Parameters:
armAngle – The arm height.
- Returns:
Whether the arm would hit the lower limit.
- wouldHitUpperLimit(armAngle: wpimath.units.radians) bool
Returns whether the arm would hit the upper limit.
- Parameters:
armAngle – The arm height.
- Returns:
Whether the arm would hit the upper limit.