Class ArmBotFF

java.lang.Object
MRILib.managers.Bot
MRILib.managers.ArmBotFF

public class ArmBotFF extends Bot
Extends Bot to manage arm-specific hardware (motors, servos) for a Pivoting Slide Arm robot.

This class initializes and provides control methods for slide and pivot motors, and claw servos. It also integrates a PivotArmController running in a separate thread for complex arm control logic (like feedforward and motion profiling).

See Also:
  • Bot
  • PivotArmController
  • Field Details

    • slide

      private com.qualcomm.robotcore.hardware.DcMotorEx slide
      The motor controlling the linear slide extension.
    • pivot

      private com.qualcomm.robotcore.hardware.DcMotorEx pivot
      The motor controlling the arm pivot rotation.
    • claw

      private com.qualcomm.robotcore.hardware.Servo claw
      The servo controlling the claw grip.
    • claw_pitch

      private com.qualcomm.robotcore.hardware.Servo claw_pitch
      The servo controlling the pitch (up/down tilt) of the claw.
    • claw_roll

      private com.qualcomm.robotcore.hardware.Servo claw_roll
      The servo controlling the roll (side-to-side rotation) of the claw.
    • armController

      private MRILib.managers.PivotArmController armController
      Controller instance for managing pivot arm movements, potentially with feedforward.
    • armThread

      private Thread armThread
      Thread dedicated to running the armController logic concurrently.
    • slidePos

      int slidePos
      Current encoder position of the slide motor.
    • pivotPos

      int pivotPos
      Current encoder position of the pivot motor.
    • slidePosPrev

      int slidePosPrev
      Previous encoder position of the slide motor (from the last update).
    • pivotPosPrev

      int pivotPosPrev
      Previous encoder position of the pivot motor (from the last update).
  • Constructor Details

    • ArmBotFF

      public ArmBotFF(com.qualcomm.robotcore.hardware.HardwareMap hm, org.firstinspires.ftc.robotcore.external.Telemetry telemetry)
      Constructor: Initializes the ArmBotFF. Calls the parent Bot constructor, initializes arm motors and servos, and starts the PivotArmController thread.
      Parameters:
      hm - The HardwareMap from the OpMode.
      telemetry - The Telemetry object from the OpMode.
  • Method Details

    • initMotors

      private void initMotors(com.qualcomm.robotcore.hardware.HardwareMap hm)
      Initializes slide and pivot motors from the hardware map. Sets modes, directions, and resets encoders.
      Parameters:
      hm - The HardwareMap from the OpMode.
    • initServos

      private void initServos(com.qualcomm.robotcore.hardware.HardwareMap hm)
      Initializes claw servos from the hardware map.
      Parameters:
      hm - The HardwareMap from the OpMode.
    • setArmMode

      public void setArmMode(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode)
      Sets the DcMotor.RunMode for both slide and pivot motors.
      Parameters:
      mode - The desired RunMode (e.g., RUN_TO_POSITION, RUN_WITHOUT_ENCODER).
    • resetEncoders

      public void resetEncoders()
      Resets encoders for drive motors (via superclass) and arm motors. Preserves the current RunMode after resetting.
      Overrides:
      resetEncoders in class Bot
    • resetPrevEncoders

      public void resetPrevEncoders()
      Resets the internal previous encoder position trackers for arm motors.
      Overrides:
      resetPrevEncoders in class Bot
    • updateControllerState

      public void updateControllerState()
      Updates the arm controller with current pivot state. Should be called in the main OpMode loop after updateEncoders().
    • updateEncoders

      public void updateEncoders()
      Updates current and previous encoder positions for drive and arm motors. Should be called once per loop in the OpMode.
      Overrides:
      updateEncoders in class Bot
    • getSlideMotor

      public com.qualcomm.robotcore.hardware.DcMotorEx getSlideMotor()
      Returns:
      The slide motor instance.
    • getPivotMotor

      public com.qualcomm.robotcore.hardware.DcMotorEx getPivotMotor()
      Returns:
      The pivot motor instance.
    • getSlidePos

      public int getSlidePos()
      Returns:
      The current slide encoder position.
    • getPivotPos

      public int getPivotPos()
      Returns:
      The current pivot encoder position.
    • getSlideVelocity

      public double getSlideVelocity()
      Returns:
      The current slide motor velocity (encoder ticks per second).
    • getPivotVelocity

      public double getPivotVelocity()
      Returns:
      The current pivot motor velocity (encoder ticks per second).
    • getClawPitch

      public com.qualcomm.robotcore.hardware.Servo getClawPitch()
      Returns:
      The claw pitch servo instance.
    • getClawRoll

      public com.qualcomm.robotcore.hardware.Servo getClawRoll()
      Returns:
      The claw roll servo instance.
    • getClaw

      public com.qualcomm.robotcore.hardware.Servo getClaw()
      Returns:
      The claw grip servo instance.
    • getClawPitchPos

      public double getClawPitchPos()
      Returns:
      The current position of the claw pitch servo (0.0 to 1.0).
    • getClawRollPos

      public double getClawRollPos()
      Returns:
      The current position of the claw roll servo (0.0 to 1.0).
    • getClawPos

      public double getClawPos()
      Returns:
      The current position of the claw grip servo (0.0 to 1.0).
    • setClawPitch

      public void setClawPitch(double pos)
      Sets the target position for the claw pitch servo.
      Parameters:
      pos - Target position (0.0 to 1.0).
    • setClawRoll

      public void setClawRoll(double pos)
      Sets the target position for the claw roll servo.
      Parameters:
      pos - Target position (0.0 to 1.0).
    • setClaw

      public void setClaw(double pos)
      Sets the target position for the claw grip servo.
      Parameters:
      pos - Target position (0.0 to 1.0).
    • setPivot

      public void setPivot(int target)
      Sets the pivot motor to run to a target encoder position. Switches mode to RUN_TO_POSITION and sets a velocity.
      Parameters:
      target - The target encoder tick count.
    • setPivotPower

      public void setPivotPower(double pow)
      Sets the pivot motor power directly. Switches mode to RUN_WITHOUT_ENCODER.
      Parameters:
      pow - The desired power (-1.0 to 1.0).
    • setSlides

      public void setSlides(int target)
      Sets the slide motor to run to a target encoder position. Switches mode to RUN_TO_POSITION and sets a velocity.
      Parameters:
      target - The target encoder tick count.
    • setArm

      public void setArm(int pivotTarget, int slideTarget)
      Sets both pivot and slide motors to run to target positions simultaneously.
      Parameters:
      pivotTarget - The target encoder position for the pivot motor.
      slideTarget - The target encoder position for the slide motor.
    • stopMultiThread

      public void stopMultiThread()
      Stops the background arm controller thread safely. Should be called at the end of the OpMode to clean up resources.