Class Elevator

Direct Known Subclasses:
Elevator, Elevator

public class Elevator extends SmartPositionalMechanism
Elevator mechanism.

This core class holds elevator state, physics simulation, and measurement/predicate logic only. Command and Trigger factories live on Elevator, which extends this class and has a full usage example in its Javadoc.

  • Constructor Details

  • Method Details

    • updateTelemetry

      public void updateTelemetry()
      Description copied from class: SmartMechanism
      Update the mechanism's telemetry.
      Specified by:
      updateTelemetry in class SmartMechanism
    • simIterate

      public void simIterate()
      Description copied from class: SmartMechanism
      Iterate sim
      Specified by:
      simIterate in class SmartMechanism
    • visualizationUpdate

      public void visualizationUpdate()
      Updates the length of the mechanism ligament to match the current height of the elevator in meters.
      Specified by:
      visualizationUpdate in class SmartMechanism
      Throws:
      SmartMotorControllerConfigurationException - if a mechanism position setpoint is present and the mechanism circumference is not configured.
    • getPose3d

      public org.wpilib.math.geometry.Pose3d getPose3d()
      Get the carriage's pose, for publishing to AdvantageScope as a component of a robot model: where the elevator is mounted, as set in its MechanismPositionConfig, moved up the elevator by its height, at the elevator's angle in its movement plane.
      Specified by:
      getPose3d in class SmartMechanism
      Returns:
      The carriage's Pose3d, relative to the robot.
    • getCascadePose3d

      public List<org.wpilib.math.geometry.Pose3d> getCascadePose3d()
      Get the pose of each moving stage of a cascade elevator, for publishing to AdvantageScope as components of a robot model. A cascade elevator's stages all move at once, each by its share of the carriage's height: a stage that travels a third of the elevator's total travel moves a third of the carriage's height relative to the stage below it.

      The stages are set with ElevatorConfig.withStages(Distance...).

      Returns:
      Each moving stage's Pose3d, relative to the robot, from the stage nearest the fixed stage to the carriage. The last is the carriage, getPose3d().
      Throws:
      ElevatorConfigurationException - if the stages are not set, or there are fewer than 2.
    • getContinuousPose3d

      public List<org.wpilib.math.geometry.Pose3d> getContinuousPose3d(boolean carriageFirst)
      Get the pose of each moving stage of a continuous elevator, for publishing to AdvantageScope as components of a robot model. A continuous elevator's stages move one at a time. Which moves first depends on how it is rigged: watch it move to see which it is.
      • Carriage first: the carriage rises the whole of its travel first, then the stage below it, and so on out to the stage nearest the fixed stage. Going down, the stage nearest the fixed stage lowers first.
      • Carriage last: the stage nearest the fixed stage rises the whole of its travel first, then the next, and so on out to the carriage. Going down, the carriage lowers first.

      The stages are set with ElevatorConfig.withStages(Distance...).

      Parameters:
      carriageFirst - True if the carriage moves first, false if it moves last.
      Returns:
      Each moving stage's Pose3d, relative to the robot, from the stage nearest the fixed stage to the carriage. The last is the carriage, getPose3d().
      Throws:
      ElevatorConfigurationException - if the stages are not set, or there are fewer than 2.
    • getName

      public String getName()
      Description copied from class: SmartMechanism
      Get the name of the mechanism.
      Specified by:
      getName in class SmartMechanism
      Returns:
      String name.
    • getHeight

      public org.wpilib.units.measure.Distance getHeight()
      Get the Height of the Elevator.
      Returns:
      Distance of the Elevator.
    • getVelocity

      public org.wpilib.units.measure.LinearVelocity getVelocity()
      Get the linear velocity of the Elevator.
      Returns:
      LinearVelocity of the elevator.
    • isNear

      public boolean isNear(org.wpilib.units.measure.Distance height, org.wpilib.units.measure.Distance within)
      Elevator is near a height.
      Parameters:
      height - Distance to be near.
      within - Distance within.
      Returns:
      True if the elevator is near another height.
    • isAtMax

      public boolean isAtMax()
      Whether the elevator is at or above its maximum height, defined by the motor controller upper soft limit if present, otherwise the elevator maximum height.
      Specified by:
      isAtMax in class SmartPositionalMechanism
      Returns:
      True if the elevator is at its configured maximum.
      Throws:
      ElevatorConfigurationException - if neither a motor controller upper soft limit nor an elevator maximum height is configured.
      SmartMotorControllerConfigurationException - if a motor controller upper soft limit is configured but the mechanism circumference is not.
    • isAtMin

      public boolean isAtMin()
      Whether the elevator is at or below its minimum height, defined by the motor controller lower soft limit if present, otherwise the elevator minimum height.
      Specified by:
      isAtMin in class SmartPositionalMechanism
      Returns:
      True if the elevator is at its configured minimum.
      Throws:
      ElevatorConfigurationException - if neither a motor controller lower soft limit nor an elevator minimum height is configured.
      SmartMotorControllerConfigurationException - if a motor controller lower soft limit is configured but the mechanism circumference is not.
    • isBetween

      public boolean isBetween(org.wpilib.units.measure.Distance start, org.wpilib.units.measure.Distance end)
      Between two heights.
      Parameters:
      start - Start height.
      end - End height.
      Returns:
      True if the elevator is between the given heights.
    • isLte

      public boolean isLte(org.wpilib.units.measure.Distance height)
      Less than or equal to height
      Parameters:
      height - Distance to check against
      Returns:
      True if the elevator's height is less than or equal to the given height.
    • isGte

      public boolean isGte(org.wpilib.units.measure.Distance height)
      Greater than or equal to height.
      Parameters:
      height - Height to check against.
      Returns:
      True if the elevator's height is greater than or equal to the given height.
    • getConfig

      public ElevatorConfig getConfig()
      Get the ElevatorConfig for this Elevator
      Returns:
      ElevatorConfig for this Elevator