Class Pivot
java.lang.Object
yams.core.mechanisms.SmartMechanism
yams.core.mechanisms.positional.SmartPositionalMechanism
yams.core.mechanisms.positional.Pivot
yams.commands3.mechanisms.Pivot
- All Implemented Interfaces:
CommandMechanism
Command-based extension of
Pivot that adds the
Mechanism binding and Command/Trigger factories.
Usage Example
// --- Instantiation ---
Pivot pivot = new Pivot(pivotConfig, motor);
// --- Commands ---
Command aimHigh = pivot.setAngle(Degrees.of(45));
Command stowPivot = pivot.runTo(Degrees.of(0), Degrees.of(1));
// --- Trigger bindings ---
pivot.near(Degrees.of(45), Degrees.of(2)).onTrue(shooter.runShooter());
-
Field Summary
Fields inherited from class SmartPositionalMechanism
m_mechanismLigament, m_mechanismRootFields inherited from class SmartMechanism
m_mechanismWindow, m_smc, m_telemetry -
Constructor Summary
ConstructorsConstructorDescriptionPivot(PivotConfig config, SmartMotorController smc) Construct the Pivot class -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.command3.Triggerbetween(org.wpilib.units.measure.Angle start, org.wpilib.units.measure.Angle end) Between two angles.org.wpilib.command3.MechanismMechanism the mechanism's commands should require.org.wpilib.command3.Triggergte(org.wpilib.units.measure.Angle angle) Greater than or equal to angle.org.wpilib.command3.Triggerlte(org.wpilib.units.measure.Angle angle) Less than or equal to angleorg.wpilib.command3.Triggermax()Pivotis at max, defined by the soft limit or hard limit on the pivot.org.wpilib.command3.Triggermin()Minimum angle of the pivot given by the soft limit or hard limit of the pivot.org.wpilib.command3.Triggernear(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle within) Pivot is near an angle.org.wpilib.command3.CommandSet the pivot to the given angle via a supplier.org.wpilib.command3.Commandrun(org.wpilib.units.measure.Angle angle) Set the pivot to the given angle.org.wpilib.command3.CommandSet the pivot to the given angle then end the command.org.wpilib.command3.CommandrunTo(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle tolerance) Set the pivot to the givenAnglethen end the command.org.wpilib.command3.CommandSet the pivot to the given angle.org.wpilib.command3.CommandsetAngle(org.wpilib.units.measure.Angle angle) Set the pivot to the given angle.Methods inherited from class Pivot
getAngle, getName, getPivotConfig, getPose3d, isAtMax, isAtMin, isBetween, isGte, isLte, 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
-
Pivot
Construct the Pivot class- Parameters:
config- Pivot configuration.smc-SmartMotorControllerdriving the pivot.- Throws:
PivotConfigurationException- if running in simulation and the pivot lower or upper hard limit is not configured.PivotConfigurationException- if running in simulation and the starting position is not configured.PivotConfigurationException- if running in simulation and the starting position is outside the hard limits.SmartMotorControllerConfigurationException- ifsmc's config does not have aMechanismset viawithMechanism(Mechanism).- Implementation Note:
smc's config must be aSmartMotorControllerConfigwith aMechanismset 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.
-
between
public org.wpilib.command3.Trigger between(org.wpilib.units.measure.Angle start, org.wpilib.units.measure.Angle end) Between two angles.- Parameters:
start- Start angle.end- End angle- Returns:
Trigger
-
gte
public org.wpilib.command3.Trigger gte(org.wpilib.units.measure.Angle angle) Greater than or equal to angle.- Parameters:
angle- Angle to check against.- Returns:
Triggerfor Pivot.
-
lte
public org.wpilib.command3.Trigger lte(org.wpilib.units.measure.Angle angle) Less than or equal to angle- Parameters:
angle-Angleto check against- Returns:
Trigger
-
setAngle
public org.wpilib.command3.Command setAngle(org.wpilib.units.measure.Angle angle) Set the pivot to the given angle.- Parameters:
angle- Pivot angle to go to.- Returns:
Commandthat sets the pivot to the desired angle.
-
setAngle
Set the pivot to the given angle.- Parameters:
angle- Pivot angle to go to.- Returns:
Commandthat sets the pivot to the desired angle.
-
run
public org.wpilib.command3.Command run(org.wpilib.units.measure.Angle angle) Set the pivot to the given angle.- Parameters:
angle- Pivot angle to go to.- Returns:
Commandthat sets the pivot to the desired angle.
-
run
Set the pivot to the given angle via a supplier.- Parameters:
angle- Supplier for the pivot angle to go to.- Returns:
Commandthat sets the pivot to the desired angle.
-
runTo
public org.wpilib.command3.Command runTo(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle tolerance) Set the pivot to the givenAnglethen end the command.- Parameters:
angle-Angleto go to.tolerance- ToleranceAngle- Returns:
Commandthat sets the pivot to the desired angle.- Implementation Note:
- This command will not stop. It should NOT be used when there is a default command on the Mechanism.
-
runTo
public org.wpilib.command3.Command runTo(Supplier<org.wpilib.units.measure.Angle> angle, org.wpilib.units.measure.Angle tolerance) Set the pivot to the given angle then end the command.- Parameters:
angle-Angleto go to.tolerance- ToleranceAngle- Returns:
Commandthat sets the pivot to the desired angle.- Implementation Note:
- This command will not stop. It should NOT be used when there is a default command on the Mechanism.
-
near
public org.wpilib.command3.Trigger near(org.wpilib.units.measure.Angle angle, org.wpilib.units.measure.Angle within) Pivot is near an angle.- Parameters:
angle-Angleto be near.within-Anglewithin.- Returns:
Triggeron when the pivot is near another angle.
-
max
public org.wpilib.command3.Trigger max()Pivotis at max, defined by the soft limit or hard limit on the pivot.- Returns:
Triggeron maximum of the pivot.- Throws:
PivotConfigurationException- when the returned trigger is evaluated, if neither a motor controller upper soft limit nor a pivot upper hard limit is configured.
-
min
public org.wpilib.command3.Trigger min()Minimum angle of the pivot given by the soft limit or hard limit of the pivot.- Returns:
Triggeron minimum of the pivot.- Throws:
PivotConfigurationException- when the returned trigger is evaluated, if neither a motor controller lower soft limit nor a pivot lower hard limit is configured.
-