Class SmartPositionalMechanism

java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.positional.SmartPositionalMechanism
Direct Known Subclasses:
Arm, DifferentialMechanism, DoubleJointedArm, Elevator, Pivot

public abstract class SmartPositionalMechanism extends SmartMechanism
Abstract intermediate base class for all closed-loop positional mechanisms in YAMS.

SmartPositionalMechanism sits between SmartMechanism and the concrete positional mechanism implementations such as Arm, Elevator, Pivot, and DifferentialMechanism. It provides the shared infrastructure required for closed-loop position control:

Concrete mechanisms extend this class and supply the physics-specific details: how to read the current position, how to drive the simulation model, and how to update visualization and telemetry. The setpoint infrastructure and WPILib subsystem integration live here so that all positional mechanisms share a consistent, command-based API without code duplication.

Conceptual subclass pattern: A concrete positional mechanism extends SmartPositionalMechanism, provides a typed command factory, and calls into the base-class setpoint methods:

// A concrete mechanism delegates setpoint management to this base class:
public Command setAngle(Angle target) {
    return Commands.startRun(
        () -> setMechanismPositionSetpoint(target),
        () -> {},
        m_subsystem
    ).withName(getName() + " SetAngle");
}

For Subclass Authors

Every concrete subclass of SmartPositionalMechanism must implement the following abstract methods inherited from SmartMechanism:

  • Field Details

    • m_mechanismRoot

      protected org.wpilib.smartdashboard.MechanismRoot2d m_mechanismRoot
      The root point of the Mechanism.
    • m_mechanismLigament

      protected org.wpilib.smartdashboard.MechanismLigament2d m_mechanismLigament
      The ligament that is being moved.
  • Constructor Details

    • SmartPositionalMechanism

      protected SmartPositionalMechanism()
      Create the positional mechanism, subclasses set up the motor and telemetry.
  • Method Details

    • isAtMax

      public abstract boolean isAtMax()
      SmartPositionalMechanism is at max, defined by the soft limit or hard limit on the SmartPositionalMechanism.
      Returns:
      True if the mechanism is at its configured maximum.
    • isAtMin

      public abstract boolean isAtMin()
      Minimum angle of the SmartPositionalMechanism given by the soft limit or hard limit of the SmartPositionalMechanism.
      Returns:
      True if the mechanism is at its configured minimum.
    • getMechanismLigament

      public org.wpilib.smartdashboard.MechanismLigament2d getMechanismLigament()
      Get the ligament of the 2D mechanism model. Used to change the position of the mechanism model in the SmartDashboard.
      Returns:
      Ligament of the 2D mechanism model.
    • getMechanismRoot

      public org.wpilib.smartdashboard.MechanismRoot2d getMechanismRoot()
      The root of the 2D mechanism model.
      Returns:
      Root of the 2D mechanism model.
    • getMotor

      public SmartMotorController getMotor()
      Get the motor controller which is moving the mechanism.
      Returns:
      Motor controller which is moving the mechanism.