Class Elevator
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.positional.SmartPositionalMechanism
yams.core.mechanisms.positional.Elevator
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.
-
Field Summary
Fields inherited from class SmartPositionalMechanism
m_mechanismLigament, m_mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedElevator(ElevatorConfig config, SmartMotorController smc) Construct theElevatorclass for easy manipulation of an elevator. -
Method Summary
Modifier and TypeMethodDescriptionList<org.wpilib.math.geometry.Pose3d> Get the pose of each moving stage of a cascade elevator, for publishing to AdvantageScope as components of a robot model.Get theElevatorConfigfor thisElevatorList<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.org.wpilib.units.measure.DistanceGet the Height of the Elevator.getName()Get the name of the mechanism.org.wpilib.math.geometry.Pose3dGet the carriage's pose, for publishing to AdvantageScope as a component of a robot model: where the elevator is mounted, as set in itsMechanismPositionConfig, moved up the elevator by its height, at the elevator's angle in its movement plane.org.wpilib.units.measure.LinearVelocityGet the linear velocity of the Elevator.booleanisAtMax()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.booleanisAtMin()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.booleanisBetween(org.wpilib.units.measure.Distance start, org.wpilib.units.measure.Distance end) Between two heights.booleanisGte(org.wpilib.units.measure.Distance height) Greater than or equal to height.booleanisLte(org.wpilib.units.measure.Distance height) Less than or equal to heightbooleanisNear(org.wpilib.units.measure.Distance height, org.wpilib.units.measure.Distance within) Elevator is near a height.voidIterate simvoidUpdate the mechanism's telemetry.voidUpdates the length of the mechanism ligament to match the current height of the elevator in meters.Methods inherited from class SmartPositionalMechanism
getMechanismLigament, getMechanismRoot, getMotorMethods inherited from class SmartMechanism
getMeasurementSetpoint, getMechanismSetpoint, getMechanismWindow, getMotorController, publishMechanismWindow, setDutyCycleSetpoint, setMeasurementPositionSetpoint, setMeasurementVelocitySetpoint, setMechanismPositionSetpoint, setMechanismVelocitySetpoint, setVoltageSetpoint
-
Constructor Details
-
Elevator
Construct theElevatorclass for easy manipulation of an elevator.- Parameters:
config-ElevatorConfigto set.smc-SmartMotorControllerto use for the Elevator- Throws:
ElevatorConfigurationException- if running in simulation and the carriage mass is not configured.ElevatorConfigurationException- if running in simulation and the minimum or maximum height is not configured.ElevatorConfigurationException- if the stage heights do not add up to the maximum height.SmartMotorControllerConfigurationException- if running in simulation and the starting position is not set on theSmartMotorControllerConfig.SmartMotorControllerConfigurationException- if running in simulation and the mechanism circumference is not configured.SmartMotorControllerConfigurationException- if running in simulation and the starting height is outside the minimum and maximum heights.- Implementation Note:
- Protected so only
Elevatorcan construct this.
-
-
Method Details
-
updateTelemetry
public void updateTelemetry()Description copied from class:SmartMechanismUpdate the mechanism's telemetry.- Specified by:
updateTelemetryin classSmartMechanism
-
simIterate
public void simIterate()Description copied from class:SmartMechanismIterate sim- Specified by:
simIteratein classSmartMechanism
-
visualizationUpdate
public void visualizationUpdate()Updates the length of the mechanism ligament to match the current height of the elevator in meters.- Specified by:
visualizationUpdatein classSmartMechanism- 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 itsMechanismPositionConfig, moved up the elevator by its height, at the elevator's angle in its movement plane.- Specified by:
getPose3din classSmartMechanism- Returns:
- The carriage's
Pose3d, relative to the robot.
-
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
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
Description copied from class:SmartMechanismGet the name of the mechanism.- Specified by:
getNamein classSmartMechanism- Returns:
Stringname.
-
getHeight
public org.wpilib.units.measure.Distance getHeight()Get the Height of the Elevator.- Returns:
Distanceof the Elevator.
-
getVelocity
public org.wpilib.units.measure.LinearVelocity getVelocity()Get the linear velocity of the Elevator.- Returns:
LinearVelocityof 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-Distanceto be near.within-Distancewithin.- 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:
isAtMaxin classSmartPositionalMechanism- 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:
isAtMinin classSmartPositionalMechanism- 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-Distanceto 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
Get theElevatorConfigfor thisElevator- Returns:
ElevatorConfigfor thisElevator
-