Class DoubleJointedArm
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.positional.SmartPositionalMechanism
yams.core.mechanisms.positional.DoubleJointedArm
yams.commands3.mechanisms.DoubleJointedArm
- All Implemented Interfaces:
CommandMechanism
Command-based extension of
DoubleJointedArm that adds
the Mechanism binding and Command factories.
Control Examples
// Set explicit joint angles: shoulder at 45°, elbow at 90°.
Command positionCommand = arm.setAngle(Degrees.of(45), Degrees.of(90));
// Move to a Cartesian target (0.4 m forward, 0.6 m up) using inverse kinematics.
Command ikCommand = arm.setPosition(new Translation2d(0.4, 0.6), false);
// Continuously track a target while within 5 cm tolerance, then finish.
Command trackCommand = arm.runTo(new Translation2d(0.5, 0.7), false, Centimeters.of(5));
-
Field Summary
Fields inherited from class SmartPositionalMechanism
m_mechanismLigament, m_mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsConstructorDescriptionDoubleJointedArm(ArmConfig lowerConfig, SmartMotorController lowerSMC, ArmConfig upperConfig, SmartMotorController upperSMC) Constructor for the Arm mechanism. -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.command3.MechanismMechanism the mechanism's commands should require.org.wpilib.command3.CommandSet the position of the DoubleJointedArm to be at pose in meters.org.wpilib.command3.Commandrun(org.wpilib.math.geometry.Translation2d translation2d, boolean invert) Set the position of the DoubleJointedArm to be at pose in meters.org.wpilib.command3.CommandrunTo(Supplier<org.wpilib.math.geometry.Translation2d> translation, Supplier<Boolean> invert, org.wpilib.units.measure.Distance tolerance) Runs to the given target and stops the command.org.wpilib.command3.CommandrunTo(org.wpilib.math.geometry.Translation2d translation2d, boolean invert, org.wpilib.units.measure.Distance tolerance) Runs to the given target and stops the command.org.wpilib.command3.CommandSimple duty cycle command.org.wpilib.command3.CommandsetAngle(org.wpilib.units.measure.Angle lowerAngle, org.wpilib.units.measure.Angle upperAngle) Set the shoulder and elbow angle of the DoubleJointedArm.org.wpilib.command3.CommandsetPosition(org.wpilib.math.geometry.Translation2d translation, boolean invert) Set the position of the DoubleJointedArm to be at pose in meters.Methods inherited from class DoubleJointedArm
getAnglesForPosition, getLowerAngle, getLowerArmConfig, getLowerMotorController, getName, getPose3d, getPosition, getUpperAngle, getUpperArmConfig, getUpperMotorController, getUpperPose3d, isAtMax, isAtMin, isNear, simIterate, updateTelemetry, visualizationUpdateMethods inherited from class SmartPositionalMechanism
getMechanismLigament, getMechanismRoot, getMotorMethods inherited from class SmartMechanism
getMeasurementSetpoint, getMechanismSetpoint, getMechanismWindow, getMotorController, publishMechanismWindow, setDutyCycleSetpoint, setMeasurementPositionSetpoint, setMeasurementVelocitySetpoint, setMechanismPositionSetpoint, setMechanismVelocitySetpoint, setVoltageSetpointMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommandMechanism
getMotorController, set, set, setVoltage, setVoltage
-
Constructor Details
-
DoubleJointedArm
public 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 either motor controller's starting position is not configured.DoubleJointedArmConfigurationException- if either arm length is not configured.DoubleJointedArmConfigurationException- if running in simulation and any arm lower or upper hard limit is not configured.DoubleJointedArmConfigurationException- if the two motor controllers' configs do not share the sameMechanism.SmartMotorControllerConfigurationException- if either motor controller's config does not have aMechanismset viawithMechanism(Mechanism).- Implementation Note:
- Both motor controllers' configs must be
SmartMotorControllerConfigs that share the sameMechanismset viawithMechanism(Mechanism).
-
-
Method Details
-
getMechanism
public org.wpilib.command3.Mechanism getMechanism()Description copied from interface:CommandMechanismMechanism the mechanism's commands should require.- Specified by:
getMechanismin interfaceCommandMechanism- Returns:
Mechanismfor the mechanism.
-
setPosition
public org.wpilib.command3.Command setPosition(org.wpilib.math.geometry.Translation2d translation, boolean invert) Set the position of the DoubleJointedArm to be at pose in meters.- Parameters:
translation-Translation2dwhere X is away from root, and Y is up.invert- Invert the eblow.- Returns:
Commandthat will reach the specified goal.
-
run
public org.wpilib.command3.Command run(org.wpilib.math.geometry.Translation2d translation2d, boolean invert) Set the position of the DoubleJointedArm to be at pose in meters.- Parameters:
translation2d-Translation2dwhere X is away from root, and Y is up.invert- Invert the eblow.- Returns:
Commandthat will reach the specified goal.
-
run
-
runTo
public org.wpilib.command3.Command runTo(org.wpilib.math.geometry.Translation2d translation2d, boolean invert, org.wpilib.units.measure.Distance tolerance) Runs to the given target and stops the command. Note, if you have a default command it will take over.- Parameters:
translation2d- Target positioninvert- Invert the elbow direction.tolerance- Tolerance- Returns:
Commandthat will reach the specified goal.
-
runTo
public org.wpilib.command3.Command runTo(Supplier<org.wpilib.math.geometry.Translation2d> translation, Supplier<Boolean> invert, org.wpilib.units.measure.Distance tolerance) Runs to the given target and stops the command. Note, if you have a default command it will take over.- Parameters:
translation- Target positioninvert- Invert the elbow direction.tolerance- Tolerance- Returns:
Commandthat will reach the specified goal.
-
setAngle
public org.wpilib.command3.Command setAngle(org.wpilib.units.measure.Angle lowerAngle, org.wpilib.units.measure.Angle upperAngle) Set the shoulder and elbow angle of the DoubleJointedArm.- Parameters:
lowerAngle-Angleof the shoulder.upperAngle-Angleof the elbow.- Returns:
Commandthat will set the angles.
-
set
-