Class DoubleJointedArm
- Direct Known Subclasses:
DoubleJointedArm, DoubleJointedArm
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.
-
Field Summary
Fields inherited from class SmartPositionalMechanism
m_mechanismLigament, m_mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDoubleJointedArm(ArmConfig lowerConfig, SmartMotorController lowerSMC, ArmConfig upperConfig, SmartMotorController upperSMC) Constructor for the Arm mechanism. -
Method Summary
Modifier and TypeMethodDescriptionorg.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 DoubleJointedArmorg.wpilib.units.measure.AngleGet the shoulder angle of the DoubleJointedArm.Get the lower (shoulder)ArmConfig.Get the lower (shoulder)SmartMotorController.getName()Get the name of the mechanism.org.wpilib.math.geometry.Pose3dGet 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'sMechanismPositionConfig, turned to its angle.org.wpilib.math.geometry.Translation2dGet theTranslation2dof the double jointed arm.org.wpilib.units.measure.AngleGet the elbow angle of the DoubleJointedArmGet the upper (elbow)ArmConfig.Get the upper (elbow)SmartMotorController.org.wpilib.math.geometry.Pose3dGet 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.booleanisAtMax()Not supported forDoubleJointedArm.booleanisAtMin()Not supported forDoubleJointedArm.booleanisNear(org.wpilib.math.geometry.Translation2d target, org.wpilib.units.measure.Distance tolerance) Is near the target within tolerancevoidIterate simvoidUpdate the mechanism's telemetry.voidUpdates the mechanism ligament with the current angle of the arm.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
-
DoubleJointedArm
protected DoubleJointedArm(ArmConfig lowerConfig, SmartMotorController lowerSMC, ArmConfig upperConfig, SmartMotorController upperSMC) Constructor for the Arm mechanism.- Parameters:
lowerConfig- LowerArmConfigto use.lowerSMC-SmartMotorControllerdriving the lower joint.upperConfig- UpperArmConfigto use.upperSMC-SmartMotorControllerdriving the upper joint.- Throws:
DoubleJointedArmConfigurationException- if eitherSmartMotorControllerConfighas no starting position.DoubleJointedArmConfigurationException- if eitherArmConfighas no length.DoubleJointedArmConfigurationException- if running in simulation and eitherArmConfigis missing its lower or upper hard limit.- Implementation Note:
- Protected so only
DoubleJointedArmcan construct this.
-
-
Method Details
-
getPosition
public org.wpilib.math.geometry.Translation2d getPosition()Get theTranslation2dof the double jointed arm.- Returns:
Translation2dof 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:
Pairwith the shoulder angle then elbow angle.
-
getLowerMotorController
Get the lower (shoulder)SmartMotorController.- Returns:
- Lower
SmartMotorController.
-
getUpperMotorController
Get the upper (elbow)SmartMotorController.- Returns:
- Upper
SmartMotorController.
-
getLowerArmConfig
-
getUpperArmConfig
-
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 checktolerance- Tolerance- Returns:
- Boolean
-
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 mechanism ligament with the current angle of the arm.- Specified by:
visualizationUpdatein classSmartMechanism- 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'sMechanismPositionConfig, turned to its angle.- Specified by:
getPose3din classSmartMechanism- 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, asgetPosition()takes them.- Returns:
- The upper arm's
Pose3d, relative to the robot.
-
getName
Description copied from class:SmartMechanismGet the name of the mechanism.- Specified by:
getNamein classSmartMechanism- Returns:
Stringname.
-
getLowerAngle
public org.wpilib.units.measure.Angle getLowerAngle()Get the shoulder angle of the DoubleJointedArm.- Returns:
Angleof the shoulder.
-
getUpperAngle
public org.wpilib.units.measure.Angle getUpperAngle()Get the elbow angle of the DoubleJointedArm- Returns:
Angleof the elbow.
-
isAtMax
public boolean isAtMax()Not supported forDoubleJointedArm.- Specified by:
isAtMaxin classSmartPositionalMechanism- Returns:
- Never returns.
- Throws:
RuntimeException- always, since max limits are not supported for this mechanism.
-
isAtMin
public boolean isAtMin()Not supported forDoubleJointedArm.- Specified by:
isAtMinin classSmartPositionalMechanism- Returns:
- Never returns.
- Throws:
RuntimeException- always, since min limits are not supported for this mechanism.
-