Class ElevatorConfig

java.lang.Object
yams.core.mechanisms.config.ElevatorConfig

public class ElevatorConfig extends Object
Elevator configuration class.

Configuration Example

SmartMotorControllerConfig motorConfig = new SmartMotorControllerConfig()
    .withClosedLoopController(0.5,0,0)
    .withFeedforward(new ElevatorFeedforward(0.1,0.4,0.12)
    .withStatorCurrentLimit(Amps.of(40));
SmartMotorController motor = new TalonFXWrapper(
    new TalonFX(4), DCMotor.getKrakenX60(1), motorConfig);

ElevatorConfig config = new ElevatorConfig()
    .withCarriageWeight(Kilograms.of(4.0))
    .withTelemetry("Elevator", TelemetryVerbosity.HIGH)
    .withHardLimits(Meters.of(0), Meters.of(2));

Elevator elevator = new Elevator(config, motor);
  • Constructor Details

    • ElevatorConfig

      public ElevatorConfig()
      Elevator Configuration class
  • Method Details

    • clone

      public ElevatorConfig clone()
      Overrides:
      clone in class Object
    • withSimColor

      public ElevatorConfig withSimColor(org.wpilib.util.Color8Bit simColor)
      Publish the color in sim as this.
      Parameters:
      simColor - Color8Bit to show.
      Returns:
      ElevatorConfig for chaining.
    • withAngle

      public ElevatorConfig withAngle(org.wpilib.units.measure.Angle angle)
      Configure the Elevators angle for simulation.
      Parameters:
      angle - Angle of the Elevator.
      Returns:
      ElevatorConfig for chaining.
    • withCarriageWeight

      public ElevatorConfig withCarriageWeight(org.wpilib.units.measure.Mass mass)
      Configure the Elevators Mass for simulation.
      Parameters:
      mass - Mass of the Elevator
      Returns:
      ElevatorConfig for chaining.
    • withTelemetry

      public ElevatorConfig withTelemetry(String telemetryName, TelemetryVerbosity telemetryVerbosity)
      Configure telemetry for the Elevator mechanism.
      Parameters:
      telemetryName - Telemetry NetworkTable name to appear under "SmartDashboard/"
      telemetryVerbosity - Telemetry verbosity to apply.
      Returns:
      ElevatorConfig for chaining.
    • withMechanismPositionConfig

      public ElevatorConfig withMechanismPositionConfig(MechanismPositionConfig mechanismPositionConfig)
      Set the elevator mechanism position configuration.
      Parameters:
      mechanismPositionConfig - MechanismPositionConfig for the Elevator
      Returns:
      ElevatorConfig for chaining
    • withHardLimits

      public ElevatorConfig withHardLimits(org.wpilib.units.measure.Distance min, org.wpilib.units.measure.Distance max)
      Set the Hard Limits for simulation
      Parameters:
      min - Height where the physical stop appears.
      max - Height where the physical stop appears
      Returns:
      ElevatorConfig for chaining.
    • withHorizontalElevator

      public ElevatorConfig withHorizontalElevator()
      Set elevator as horizontal to avoid gravity simulation
      Returns:
      ElevatorConfig for chaining.
    • getAngle

      public org.wpilib.units.measure.Angle getAngle()
      Get the Angle of the Elevator
      Returns:
      Angle of the Elevator.
    • withStages

      public ElevatorConfig withStages(org.wpilib.units.measure.Distance... stageHeights)
      Set the elevator's moving stages, for the pose of each stage from Elevator.getCascadePose3d() or Elevator.getContinuousPose3d(boolean).

      The stage heights must add up to the elevator's maximum height, from withHardLimits(Distance, Distance): the Elevator throws if they do not. Without hard limits, the elevator's height is from 0 to the stage heights' total.

      Parameters:
      stageHeights - How far each moving stage travels relative to the stage below it, from the stage nearest the fixed stage to the carriage, which is the last. One for each stage that moves.
      Returns:
      ElevatorConfig for chaining.
      Throws:
      IllegalArgumentException - if no height is given, or a height is not positive.
    • getStages

      public OptionalInt getStages()
      Get the number of stages that move, counting the carriage as the last.
      Returns:
      The number of moving stages, or empty if withStages(Distance...) was not called.
    • getStageHeights

      public List<org.wpilib.units.measure.Distance> getStageHeights()
      Get how far each moving stage travels relative to the stage below it.
      Returns:
      Each moving stage's height, from the stage nearest the fixed stage to the carriage, or an empty list if withStages(Distance...) was not called.
    • getStageHeightTotal

      public Optional<org.wpilib.units.measure.Distance> getStageHeightTotal()
      Get how far the stages travel together, the sum of the stage heights.
      Returns:
      The total of the stage heights, or empty if withStages(Distance...) was not called.
    • getMaximumHeight

      public Optional<org.wpilib.units.measure.Distance> getMaximumHeight()
      Get the Upper hard limit of the Elevator: the maximum height from withHardLimits(Distance, Distance), or the stage heights' total without hard limits, as the stages carry the carriage to the top.
      Returns:
      Distance hard limit.
    • getMinimumHeight

      public Optional<org.wpilib.units.measure.Distance> getMinimumHeight()
      Get the lower hard limit of the Elevator: the minimum height from withHardLimits(Distance, Distance), or 0 without hard limits when the stages are set, as the stages start at the bottom.
      Returns:
      Distance hard limit.
    • getTelemetryVerbosity

      public Optional<TelemetryVerbosity> getTelemetryVerbosity()
      Get the telemetry verbosity of the Elevator
      Returns:
      TelemetryVerbosity of the Elevator
    • getTelemetryName

      public Optional<String> getTelemetryName()
      Network Tables name for the Elevator
      Returns:
      Network Tables name.
    • getSimColor

      public org.wpilib.util.Color8Bit getSimColor()
      Get sim color
      Returns:
      sim color
    • getCarriageMass

      public Optional<org.wpilib.units.measure.Mass> getCarriageMass()
      Get the Mass of the Elevator carriage.
      Returns:
      Carriage mass.
    • getIsElevatorHorizontal

      public boolean getIsElevatorHorizontal()
      Get if the elevator is horizontal
      Returns:
      if elevator is horizontal.
    • getMechanismPositionConfig

      public MechanismPositionConfig getMechanismPositionConfig()
      Get the mechanism position configuration of the elevator.
      Returns:
      Optional containing the mechanism position configuration if set, otherwise an empty Optional.