Class DoubleJointedArm

All Implemented Interfaces:
CommandMechanism

public class DoubleJointedArm extends DoubleJointedArm implements CommandMechanism
Command-based extension of DoubleJointedArm that adds the Subsystem binding and Command/Trigger 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));
  • 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(org.wpilib.math.geometry.Translation2d translation, boolean invert)
      Set the position of the DoubleJointedArm to be at pose in meters.
      Parameters:
      translation - Translation2d where X is away from root, and Y is up.
      invert - Invert the eblow.
      Returns:
      Command that will reach the specified goal.
    • run

      public org.wpilib.command2.Command run(org.wpilib.math.geometry.Translation2d translation2d, boolean invert)
      Set the position of the DoubleJointedArm to be at pose in meters.
      Parameters:
      translation2d - Translation2d where X is away from root, and Y is up.
      invert - Invert the eblow.
      Returns:
      Command that will reach the specified goal.
    • run

      public org.wpilib.command2.Command run(Supplier<org.wpilib.math.geometry.Translation2d> translation, Supplier<Boolean> invert)
      Set the position of the DoubleJointedArm to be at pose in meters.
      Parameters:
      translation - Supplier<org.wpilib.math.geometry.Translation2d> where X is away from root, and Y is up.
      invert - Supplier<Boolean> Invert the eblow.
      Returns:
      Command that will reach the specified goal.
    • runTo

      public org.wpilib.command2.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 position
      invert - Invert the elbow direction.
      tolerance - Tolerance
      Returns:
      Command that will reach the specified goal.
    • runTo

      public org.wpilib.command2.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 position
      invert - Invert the elbow direction.
      tolerance - Tolerance
      Returns:
      Command that will reach the specified goal.
    • setAngle

      public org.wpilib.command2.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 - Angle of the shoulder.
      upperAngle - Angle of the elbow.
      Returns:
      Command that will set the angles.
    • set

      public org.wpilib.command2.Command set(Double lowerDutycycle, Double upperDutycycle)
      Simple duty cycle command.
      Parameters:
      lowerDutycycle - Dutycycle of the shoulder.
      upperDutycycle - DutyCycle of the elbow.
      Returns:
      Command to set the DutyCycle.