SingleJointedArmSim
- class wpilib.simulation.SingleJointedArmSim(*args, **kwargs)
Bases:
LinearSystemSim_2_1_2Represents a simulated arm mechanism.
Overloaded function.
__init__(self: wpilib.simulation._simulation.SingleJointedArmSim, system: wpimath._wpimath.LinearSystem_2_1_2, gearbox: wpimath._wpimath.DCMotor, gearing: typing.SupportsFloat | typing.SupportsIndex, arm_length: wpimath.units.meters, min_angle: wpimath.units.radians, max_angle: wpimath.units.radians, simulate_gravity: bool, starting_angle: wpimath.units.radians, measurement_std_devs: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], “FixedSize(2)”] = [0.0, 0.0]) -> None
Creates a simulated arm mechanism.
- Parameters:
system – The system representing this arm. This system can be created with wpi::math::Models::SingleJointedArmFromPhysicalConstants().
gearbox – The type and number of motors on the arm gearbox.
gearing – The gear ratio of the arm (numbers greater than 1 represent reductions).
arm_length – The length of the arm.
min_angle – The minimum angle that the arm is capable of, with 0 being horizontal.
max_angle – The maximum angle that the arm is capable of, with 0 being horizontal.
simulate_gravity – Whether gravity should be simulated or not.
starting_angle – The initial position of the arm.
measurement_std_devs – The standard deviations of the measurements.
__init__(self: wpilib.simulation._simulation.SingleJointedArmSim, gearbox: wpimath._wpimath.DCMotor, gearing: typing.SupportsFloat | typing.SupportsIndex, moi: wpimath.units.kilogram_square_meters, arm_length: wpimath.units.meters, min_angle: wpimath.units.radians, max_angle: wpimath.units.radians, simulate_gravity: bool, starting_angle: wpimath.units.radians, measurement_std_devs: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], “FixedSize(2)”] = [0.0, 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.
arm_length – The length of the arm.
min_angle – The minimum angle that the arm is capable of, with 0 being horizontal.
max_angle – The maximum angle that the arm is capable of, with 0 being horizontal.
simulate_gravity – Whether gravity should be simulated or not.
starting_angle – The initial position of the arm.
measurement_std_devs – The standard deviation of the measurement noise.
- static estimate_moi(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.
- get_angle() wpimath.units.radians
Returns the current arm angle.
- Returns:
The current arm angle.
- get_angle_degrees() wpimath.units.degrees
- get_current_draw() wpimath.units.amperes
Returns the arm current draw.
- Returns:
The arm current draw.
- get_velocity() wpimath.units.radians_per_second
Returns the current arm velocity.
- Returns:
The current arm velocity.
- get_velocity_dps() wpimath.units.degrees_per_second
- has_hit_lower_limit() bool
Returns whether the arm has hit the lower limit.
- Returns:
Whether the arm has hit the lower limit.
- has_hit_upper_limit() bool
Returns whether the arm has hit the upper limit.
- Returns:
Whether the arm has hit the upper limit.
- set_input_voltage(voltage: wpimath.units.volts) None
Sets the input voltage for the arm.
- Parameters:
voltage – The input voltage.
- set_state(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.
- would_hit_lower_limit(arm_angle: wpimath.units.radians) bool
Returns whether the arm would hit the lower limit.
- Parameters:
arm_angle – The arm height.
- Returns:
Whether the arm would hit the lower limit.
- would_hit_upper_limit(arm_angle: wpimath.units.radians) bool
Returns whether the arm would hit the upper limit.
- Parameters:
arm_angle – The arm height.
- Returns:
Whether the arm would hit the upper limit.