Class DifferentialMechanism

All Implemented Interfaces:
CommandMechanism

public class DifferentialMechanism extends DifferentialMechanism implements CommandMechanism
Command-based extension of DifferentialMechanism that adds the Subsystem binding and Command/Trigger 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));
  • Constructor Details

  • Method Details

    • getSubsystem

      public org.wpilib.command2.Subsystem getSubsystem()
      Description copied from interface: CommandMechanism
      Subsystem the mechanism's commands should require.
      Specified by:
      getSubsystem in interface CommandMechanism
      Returns:
      Subsystem for the mechanism.
    • setPosition

      public org.wpilib.command2.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:
      Command to set the position.
    • set

      public org.wpilib.command2.Command set(double tilt, double twist)
      Set the dutycycle of the differential mechanism.
      Parameters:
      tilt - Tilt dutycycle.
      twist - Twist dutycycle.
      Returns:
      Command to set the differential mechanism duty cycle.
    • setPosition

      public org.wpilib.command2.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:
      Command to set the position.
    • run

      public org.wpilib.command2.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:
      Command to set the position.
    • run

      public org.wpilib.command2.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:
      Command to run the differential mechanism to the position.