Class DoubleJointedArm

Direct Known Subclasses:
DoubleJointedArm, DoubleJointedArm

public class DoubleJointedArm extends SmartPositionalMechanism
A two-segment arm where each joint has its own independent motor controller.

Unlike a differential mechanism, the joints in a DoubleJointedArm are driven individually: the lower (shoulder) motor directly controls the first segment and the upper (elbow) motor directly controls the second segment. Kinematics are applied in software to convert between Cartesian end-effector positions and the required joint angles.

This mechanism is well-suited to FRC scoring subsystems that require both high reach and precise end-effector placement. A long lower segment provides reach, while the upper segment allows the end-effector to be folded back under frame perimeter when traveling or extended far over field elements when scoring.

Construction Example

// Each ArmConfig must specify the motor, gearing, arm length, hard limits,
// and starting angle before the DoubleJointedArm can be constructed.
ArmConfig lowerConfig = new ArmConfig(lowerSMC)
    .withLength(Inches.of(24))
    .withHardLimits(Degrees.of(0), Degrees.of(120))
    .withStartingPosition(Degrees.of(0))
    .withTelemetry("Shoulder", TelemetryVerbosity.HIGH);

ArmConfig upperConfig = new ArmConfig(upperSMC)
    .withLength(Inches.of(20))
    .withHardLimits(Degrees.of(0), Degrees.of(120))
    .withStartingPosition(Degrees.of(90))
    .withTelemetry("Elbow", TelemetryVerbosity.HIGH);

DoubleJointedArm arm = new DoubleJointedArm(lowerConfig, upperConfig);

This core class holds arm state, kinematics, and physics simulation only. Command and Trigger factories live on DoubleJointedArm, which extends this class and has control examples in its Javadoc.

  • Constructor Details

  • Method Details

    • getPosition

      public org.wpilib.math.geometry.Translation2d getPosition()
      Get the Translation2d of the double jointed arm.
      Returns:
      Translation2d of the double jointed arm.
    • getAnglesForPosition

      public org.wpilib.util.Pair<org.wpilib.units.measure.Angle, org.wpilib.units.measure.Angle> getAnglesForPosition(org.wpilib.math.geometry.Translation2d translation, boolean invert)
      Inverse Kinematics for a DoubleJointedArm
      Parameters:
      translation - Translations from root in Meters.
      invert - Invert the elbow.
      Returns:
      Pair with the shoulder angle then elbow angle.
    • getLowerMotorController

      public SmartMotorController getLowerMotorController()
      Get the lower (shoulder) SmartMotorController.
      Returns:
      Lower SmartMotorController.
    • getUpperMotorController

      public SmartMotorController getUpperMotorController()
      Get the upper (elbow) SmartMotorController.
      Returns:
      Upper SmartMotorController.
    • getLowerArmConfig

      public ArmConfig getLowerArmConfig()
      Get the lower (shoulder) ArmConfig.
      Returns:
      Lower ArmConfig.
    • getUpperArmConfig

      public ArmConfig getUpperArmConfig()
      Get the upper (elbow) ArmConfig.
      Returns:
      Upper ArmConfig.
    • isNear

      public boolean isNear(org.wpilib.math.geometry.Translation2d target, org.wpilib.units.measure.Distance tolerance)
      Is near the target within tolerance
      Parameters:
      target - Target to check
      tolerance - Tolerance
      Returns:
      Boolean
    • 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 mechanism ligament with the current angle of the arm.
      Specified by:
      visualizationUpdate in class SmartMechanism
      See Also:
    • getPose3d

      public org.wpilib.math.geometry.Pose3d getPose3d()
      Get the lower arm's pose, for publishing to AdvantageScope as a component of a robot model: where it is mounted, as set in the lower arm's MechanismPositionConfig, turned to its angle.
      Specified by:
      getPose3d in class SmartMechanism
      Returns:
      The lower arm's Pose3d, relative to the robot.
      See Also:
    • getUpperPose3d

      public org.wpilib.math.geometry.Pose3d getUpperPose3d()
      Get the upper arm's pose, for publishing to AdvantageScope as a component of a robot model: at the end of the lower arm, turned to the upper arm's angle. Both angles are from the lower arm's mount, as getPosition() takes them.
      Returns:
      The upper arm's Pose3d, relative to the robot.
    • getName

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

      public org.wpilib.units.measure.Angle getLowerAngle()
      Get the shoulder angle of the DoubleJointedArm.
      Returns:
      Angle of the shoulder.
    • getUpperAngle

      public org.wpilib.units.measure.Angle getUpperAngle()
      Get the elbow angle of the DoubleJointedArm
      Returns:
      Angle of the elbow.
    • isAtMax

      public boolean isAtMax()
      Not supported for DoubleJointedArm.
      Specified by:
      isAtMax in class SmartPositionalMechanism
      Returns:
      Never returns.
      Throws:
      RuntimeException - always, since max limits are not supported for this mechanism.
    • isAtMin

      public boolean isAtMin()
      Not supported for DoubleJointedArm.
      Specified by:
      isAtMin in class SmartPositionalMechanism
      Returns:
      Never returns.
      Throws:
      RuntimeException - always, since min limits are not supported for this mechanism.