ElevatorSim
- class wpilib.simulation.ElevatorSim(*args, **kwargs)
Bases:
LinearSystemSim_2_1_2Represents a simulated elevator mechanism.
Overloaded function.
__init__(self: wpilib.simulation._simulation.ElevatorSim, plant: wpimath._wpimath.LinearSystem_2_1_2, gearbox: wpimath._wpimath.DCMotor, min_height: wpimath.units.meters, max_height: wpimath.units.meters, simulate_gravity: bool, starting_height: wpimath.units.meters, measurement_std_devs: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], “FixedSize(2)”] = [0.0, 0.0]) -> None
Constructs a simulated elevator mechanism.
- Parameters:
plant – The linear system that represents the elevator. This system can be created with wpi::math::Models::ElevatorFromPhysicalConstants().
gearbox – The type of and number of motors in your elevator gearbox.
min_height – The minimum allowed height of the elevator.
max_height – The maximum allowed height of the elevator.
simulate_gravity – Whether gravity should be simulated or not.
starting_height – The starting height of the elevator.
measurement_std_devs – The standard deviation of the measurements.
__init__(self: wpilib.simulation._simulation.ElevatorSim, gearbox: wpimath._wpimath.DCMotor, gearing: typing.SupportsFloat | typing.SupportsIndex, carriage_mass: wpimath.units.kilograms, drum_radius: wpimath.units.meters, min_height: wpimath.units.meters, max_height: wpimath.units.meters, simulate_gravity: bool, starting_height: wpimath.units.meters, measurement_std_devs: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], “FixedSize(2)”] = [0.0, 0.0]) -> None
Constructs a simulated elevator mechanism.
- Parameters:
gearbox – The type of and number of motors in your elevator gearbox.
gearing – The gearing of the elevator (numbers greater than 1 represent reductions).
carriage_mass – The mass of the elevator carriage.
drum_radius – The radius of the drum that your cable is wrapped around.
min_height – The minimum allowed height of the elevator.
max_height – The maximum allowed height of the elevator.
simulate_gravity – Whether gravity should be simulated or not.
starting_height – The starting height of the elevator.
measurement_std_devs – The standard deviation of the measurements.
- get_current_draw() wpimath.units.amperes
Returns the elevator current draw.
- Returns:
The elevator current draw.
- get_position() wpimath.units.meters
Returns the position of the elevator.
- Returns:
The position of the elevator.
- get_position_feet() wpimath.units.feet
- get_position_inches() wpimath.units.inches
- get_velocity() wpimath.units.meters_per_second
Returns the velocity of the elevator.
- Returns:
The velocity of the elevator.
- get_velocity_fps() wpimath.units.feet_per_second
- has_hit_lower_limit() bool
Returns whether the elevator has hit the lower limit.
- Returns:
Whether the elevator has hit the lower limit.
- has_hit_upper_limit() bool
Returns whether the elevator has hit the upper limit.
- Returns:
Whether the elevator has hit the upper limit.
- set_input_voltage(voltage: wpimath.units.volts) None
Sets the input voltage for the elevator.
- Parameters:
voltage – The input voltage.
- set_state(position: wpimath.units.meters, velocity: wpimath.units.meters_per_second) None
Sets the elevator’s state. The new position will be limited between the minimum and maximum allowed heights.
- Parameters:
position – The new position
velocity – The new velocity
- would_hit_lower_limit(elevator_height: wpimath.units.meters) bool
Returns whether the elevator would hit the lower limit.
- Parameters:
elevator_height – The elevator height.
- Returns:
Whether the elevator would hit the lower limit.
- would_hit_upper_limit(elevator_height: wpimath.units.meters) bool
Returns whether the elevator would hit the upper limit.
- Parameters:
elevator_height – The elevator height.
- Returns:
Whether the elevator would hit the upper limit.