Class MechanismPositionConfig

java.lang.Object
yams.mechanisms.config.MechanismPositionConfig

public class MechanismPositionConfig extends Object
A configuration class for specifying the position and visualization properties of a mechanism relative to a robot in a 3D coordinate system. This class allows setting and retrieving details such as the mechanism's position relative to the robot, the robot's maximum dimensions, and the plane in which the mechanism operates.
  • Field Details

    • robotToMechanism

      protected Optional<Translation3d> robotToMechanism
      The translation from the robot to the mechanism (Optional)
    • maxRobotLength

      protected Optional<Distance> maxRobotLength
      The length of the robot in meters.
    • maxRobotHeight

      protected Optional<Distance> maxRobotHeight
      The height of the robot in meters.
    • plane

      The plane that the mechanism is on, used for position calculations.
  • Constructor Details

    • MechanismPositionConfig

      public MechanismPositionConfig()
  • Method Details

    • withRelativePosition

      public MechanismPositionConfig withRelativePosition(Translation3d robotToMechanism)
      Set the position of the SmartPositionalMechanism relative to the robot.
      Parameters:
      robotToMechanism - Pose3d of the SmartPositionalMechanism relative to the robot.
      Returns:
      The SmartPositionalMechanism, for easy chaining.
    • withMaxRobotLength

      public MechanismPositionConfig withMaxRobotLength(Distance robotLength)
      Set the length of the robot for visualization purposes.
      Parameters:
      robotLength - Length of the robot in meters.
      Returns:
      The SmartPositionalMechanism, for easy chaining.
    • withMaxRobotHeight

      public MechanismPositionConfig withMaxRobotHeight(Distance robotHeight)
      Set the height of the robot for visualization purposes.
      Parameters:
      robotHeight - Height of the robot in meters.
      Returns:
      The SmartPositionalMechanism, for easy chaining.
    • withMovementPlane

      public MechanismPositionConfig withMovementPlane(MechanismPositionConfig.Plane plane)
      Set the plane that the mechanism is on, used for position calculations.
      Parameters:
      plane - The plane that the mechanism is on. Default is X-Z plane.
      Returns:
      The SmartPositionalMechanism, for easy chaining.
    • getMechanismX

      public Distance getMechanismX(Distance length)
      Converts a given distance in the x-direction to a x-coordinate appropriate for visualizing on a Mechanism2d.
      Parameters:
      length - the distance in the x-direction
      Returns:
      the x-coordinate for visualizing on a Mechanism2d
    • getMechanismY

      public Distance getMechanismY(Distance y)
      Gets the distance in the y-direction appropriate for visualizing on a Mechanism2d, defaults to the given distance.
      Parameters:
      y - the default distance in the y-direction
      Returns:
      the y-coordinate for visualizing on a Mechanism2d
    • getWindowXDimension

      public Distance getWindowXDimension(Distance length)
      Returns the x dimension of the window in the Mechanism2d for visualization, either the max robot length if set, or twice the given length.
      Parameters:
      length - the length of the mechanism
      Returns:
      the x dimension of the window in the Mechanism2d
    • getWindowYDimension

      public Distance getWindowYDimension(Distance length)
      Returns the y dimension of the window in the Mechanism2d for visualization, either the max robot height if set, or twice the given length.
      Parameters:
      length - the length of the mechanism
      Returns:
      the y dimension of the window in the Mechanism2d
    • getRelativePosition

      public Optional<Translation3d> getRelativePosition()
      Get the relative position of the mechanism to the robot.
      Returns:
      Translation3d representing the relative position. Defaults to a zero translation if not set.
    • getMovementPlane

      public MechanismPositionConfig.Plane getMovementPlane()
      Get the plane that the mechanism is on.
      Returns:
      The MechanismPositionConfig.Plane that the mechanism is on.