ElevatorSim
- class wpilib.simulation.ElevatorSim(*args, **kwargs)
Bases:
LinearSystemSim_2_1_1
Represents a simulated elevator mechanism.
Overloaded function.
__init__(self: wpilib.simulation._simulation.ElevatorSim, plant: wpimath._controls._controls.system.LinearSystem_2_1_1, gearbox: wpimath._controls._controls.plant.DCMotor, minHeight: wpimath.units.meters, maxHeight: wpimath.units.meters, simulateGravity: bool, startingHeight: wpimath.units.meters, measurementStdDevs: Annotated[list[float], FixedSize(1)] = [0.0]) -> None
Constructs a simulated elevator mechanism.
- Parameters:
plant – The linear system that represents the elevator. This system can be created with LinearSystemId::ElevatorSystem().
gearbox – The type of and number of motors in your elevator gearbox.
minHeight – The minimum allowed height of the elevator.
maxHeight – The maximum allowed height of the elevator.
simulateGravity – Whether gravity should be simulated or not.
startingHeight – The starting height of the elevator.
measurementStdDevs – The standard deviation of the measurements.
__init__(self: wpilib.simulation._simulation.ElevatorSim, gearbox: wpimath._controls._controls.plant.DCMotor, gearing: float, carriageMass: wpimath.units.kilograms, drumRadius: wpimath.units.meters, minHeight: wpimath.units.meters, maxHeight: wpimath.units.meters, simulateGravity: bool, startingHeight: wpimath.units.meters, measurementStdDevs: Annotated[list[float], FixedSize(1)] = [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).
carriageMass – The mass of the elevator carriage.
drumRadius – The radius of the drum that your cable is wrapped around.
minHeight – The minimum allowed height of the elevator.
maxHeight – The maximum allowed height of the elevator.
simulateGravity – Whether gravity should be simulated or not.
startingHeight – The starting height of the elevator.
measurementStdDevs – The standard deviation of the measurements.
- getCurrentDraw() wpimath.units.amperes
Returns the elevator current draw.
- Returns:
The elevator current draw.
- getPosition() wpimath.units.meters
Returns the position of the elevator.
- Returns:
The position of the elevator.
- getPositionFeet() wpimath.units.feet
- getPositionInches() wpimath.units.inches
- getVelocity() wpimath.units.meters_per_second
Returns the velocity of the elevator.
- Returns:
The velocity of the elevator.
- getVelocityFps() wpimath.units.feet_per_second
- hasHitLowerLimit() bool
Returns whether the elevator has hit the lower limit.
- Returns:
Whether the elevator has hit the lower limit.
- hasHitUpperLimit() bool
Returns whether the elevator has hit the upper limit.
- Returns:
Whether the elevator has hit the upper limit.
- setInputVoltage(voltage: wpimath.units.volts) None
Sets the input voltage for the elevator.
- Parameters:
voltage – The input voltage.
- setState(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
- wouldHitLowerLimit(elevatorHeight: wpimath.units.meters) bool
Returns whether the elevator would hit the lower limit.
- Parameters:
elevatorHeight – The elevator height.
- Returns:
Whether the elevator would hit the lower limit.
- wouldHitUpperLimit(elevatorHeight: wpimath.units.meters) bool
Returns whether the elevator would hit the upper limit.
- Parameters:
elevatorHeight – The elevator height.
- Returns:
Whether the elevator would hit the upper limit.