Class DifferentialMechanism
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.positional.SmartPositionalMechanism
yams.core.mechanisms.positional.DifferentialMechanism
yams.commands3.mechanisms.DifferentialMechanism
- All Implemented Interfaces:
CommandMechanism
Command-based extension of
DifferentialMechanism that
adds the Mechanism binding and Command factories.
Usage Example
DifferentialMechanismConfig config = new DifferentialMechanismConfig(leftSMC, rightSMC)
.withStartingPosition(Degrees.of(30), Degrees.of(0)) // tilt=30°, twist=0°
.withLength(Inches.of(14))
.withMOI(Inches.of(14), Pounds.of(2))
.withTelemetry("DifferentialWrist", TelemetryVerbosity.HIGH);
DifferentialMechanism wrist = new DifferentialMechanism(config);
// Command: tilt to 60° and twist to 45°.
Command scoreCommand = wrist.setPosition(Degrees.of(60), Degrees.of(45));
// Command: continuously follow a joystick (suppliers).
Command manualCommand = wrist.run(
() -> Degrees.of(driverController.getLeftY() * 90),
() -> Degrees.of(driverController.getRightX() * 90));
-
Field Summary
Fields inherited from class SmartPositionalMechanism
m_mechanismLigament, m_mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsConstructorDescriptionDifferentialMechanism(DifferentialMechanismConfig diffConfig) Constructor for the Differential mechanism. -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.command3.MechanismMechanism the mechanism's commands should require.org.wpilib.command3.CommandRun the differential mechanism to a position.org.wpilib.command3.Commandrun(org.wpilib.units.measure.Angle tilt, org.wpilib.units.measure.Angle twist) Set the position of the differential mechanism.org.wpilib.command3.Commandset(double tilt, double twist) Set the dutycycle of the differential mechanism.org.wpilib.command3.CommandsetPosition(Supplier<org.wpilib.units.measure.Angle> tilt, Supplier<org.wpilib.units.measure.Angle> twist) Set the position of the differential mechanism using suppliers.org.wpilib.command3.CommandsetPosition(org.wpilib.units.measure.Angle tilt, org.wpilib.units.measure.Angle twist) Set the position of the differential mechanism.Methods inherited from class DifferentialMechanism
getDifferentialMechanismConfig, getLeftMotorController, getName, getPose3d, getRightMotorController, getTiltPosition, getTwistPosition, isAtMax, isAtMin, 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
-
DifferentialMechanism
Constructor for the Differential mechanism.- Parameters:
diffConfig- LowerDifferentialMechanismConfigto use.- Throws:
DifferentialMechanismConfigurationException- if the starting tilt or twist angle is not configured.DifferentialMechanismConfigurationException- if the length is not configured.DifferentialMechanismConfigurationException- if running in simulation and the MOI is not configured.DifferentialMechanismConfigurationException- if the left and right motor controllers' configs do not share the sameMechanism.NoSuchElementException- if the left or rightSmartMotorControllerwas never set ondiffConfig.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(Supplier<org.wpilib.units.measure.Angle> tilt, Supplier<org.wpilib.units.measure.Angle> twist) Set the position of the differential mechanism using suppliers.- Parameters:
tilt- Tilt of the Differential Mechanism.twist- Twist of the Differential Mechanism.- Returns:
Commandto set the position.
-
set
public org.wpilib.command3.Command set(double tilt, double twist) Set the dutycycle of the differential mechanism.- Parameters:
tilt- Tilt dutycycle.twist- Twist dutycycle.- Returns:
Commandto set the differential mechanism duty cycle.
-
setPosition
public org.wpilib.command3.Command setPosition(org.wpilib.units.measure.Angle tilt, org.wpilib.units.measure.Angle twist) Set the position of the differential mechanism.- Parameters:
tilt- Tilt of the differential mechanism.twist- Twist of the differential mechanism.- Returns:
Commandto set the position.
-
run
public org.wpilib.command3.Command run(org.wpilib.units.measure.Angle tilt, org.wpilib.units.measure.Angle twist) Set the position of the differential mechanism.- Parameters:
tilt- Tilt of the differential mechanism.twist- Twist of the differential mechanism.- Returns:
Commandto set the position.
-
run
public org.wpilib.command3.Command run(Supplier<org.wpilib.units.measure.Angle> tilt, Supplier<org.wpilib.units.measure.Angle> twist) Run the differential mechanism to a position.- Parameters:
tilt- Supplier of the tilt angle.twist- Supplier of the twist angle.- Returns:
Commandto run the differential mechanism to the position.
-