Class ArmBotFF
java.lang.Object
MRILib.managers.Bot
MRILib.managers.ArmBotFF
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MRILib.managers.PivotArmController
Controller instance for managing pivot arm movements, potentially with feedforward.private Thread
Thread dedicated to running the armController logic concurrently.private com.qualcomm.robotcore.hardware.Servo
The servo controlling the claw grip.private com.qualcomm.robotcore.hardware.Servo
The servo controlling the pitch (up/down tilt) of the claw.private com.qualcomm.robotcore.hardware.Servo
The servo controlling the roll (side-to-side rotation) of the claw.private com.qualcomm.robotcore.hardware.DcMotorEx
The motor controlling the arm pivot rotation.(package private) int
Current encoder position of the pivot motor.(package private) int
Previous encoder position of the pivot motor (from the last update).private com.qualcomm.robotcore.hardware.DcMotorEx
The motor controlling the linear slide extension.(package private) int
Current encoder position of the slide motor.(package private) int
Previous encoder position of the slide motor (from the last update).Fields inherited from class MRILib.managers.Bot
backLeftPos, backLeftPosPrev, backRightPos, backRightPosPrev, frontLeftPos, frontLeftPosPrev, frontRightPos, frontRightPosPrev, imu, odo
-
Constructor Summary
ConstructorsConstructorDescriptionArmBotFF
(com.qualcomm.robotcore.hardware.HardwareMap hm, org.firstinspires.ftc.robotcore.external.Telemetry telemetry) Constructor: Initializes the ArmBotFF. -
Method Summary
Modifier and TypeMethodDescriptioncom.qualcomm.robotcore.hardware.Servo
getClaw()
com.qualcomm.robotcore.hardware.Servo
double
double
com.qualcomm.robotcore.hardware.Servo
double
com.qualcomm.robotcore.hardware.DcMotorEx
int
double
com.qualcomm.robotcore.hardware.DcMotorEx
int
double
private void
initMotors
(com.qualcomm.robotcore.hardware.HardwareMap hm) Initializes slide and pivot motors from the hardware map.private void
initServos
(com.qualcomm.robotcore.hardware.HardwareMap hm) Initializes claw servos from the hardware map.void
Resets encoders for drive motors (via superclass) and arm motors.void
Resets the internal previous encoder position trackers for arm motors.void
setArm
(int pivotTarget, int slideTarget) Sets both pivot and slide motors to run to target positions simultaneously.void
setArmMode
(com.qualcomm.robotcore.hardware.DcMotor.RunMode mode) Sets theDcMotor.RunMode
for both slide and pivot motors.void
setClaw
(double pos) Sets the target position for the claw grip servo.void
setClawPitch
(double pos) Sets the target position for the claw pitch servo.void
setClawRoll
(double pos) Sets the target position for the claw roll servo.void
setPivot
(int target) Sets the pivot motor to run to a target encoder position.void
setPivotPower
(double pow) Sets the pivot motor power directly.void
setSlides
(int target) Sets the slide motor to run to a target encoder position.void
Stops the background arm controller thread safely.void
Updates the arm controller with current pivot state.void
Updates current and previous encoder positions for drive and arm motors.Methods inherited from class MRILib.managers.Bot
driveFieldXYW, driveXYW, enableBrakeMode, getBL, getBLPos, getBLPosPrev, getBR, getBRPos, getBRPosPrev, getFL, getFLPos, getFLPosPrev, getFR, getFRPos, getFRPosPrev, getHeading, getIMUHeading, getLastPosition, getPosition, getVoltage, getX, getY, initIMU, initIMU, initOdo, initOdo, resetIMUHeading, setDirections, setMode, setPosition, setPosition, update
-
Field Details
-
slide
private com.qualcomm.robotcore.hardware.DcMotorEx slideThe motor controlling the linear slide extension. -
pivot
private com.qualcomm.robotcore.hardware.DcMotorEx pivotThe motor controlling the arm pivot rotation. -
claw
private com.qualcomm.robotcore.hardware.Servo clawThe servo controlling the claw grip. -
claw_pitch
private com.qualcomm.robotcore.hardware.Servo claw_pitchThe servo controlling the pitch (up/down tilt) of the claw. -
claw_roll
private com.qualcomm.robotcore.hardware.Servo claw_rollThe servo controlling the roll (side-to-side rotation) of the claw. -
armController
private MRILib.managers.PivotArmController armControllerController instance for managing pivot arm movements, potentially with feedforward. -
armThread
Thread dedicated to running the armController logic concurrently. -
slidePos
int slidePosCurrent encoder position of the slide motor. -
pivotPos
int pivotPosCurrent encoder position of the pivot motor. -
slidePosPrev
int slidePosPrevPrevious encoder position of the slide motor (from the last update). -
pivotPosPrev
int pivotPosPrevPrevious 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 theDcMotor.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 classBot
-
resetPrevEncoders
public void resetPrevEncoders()Resets the internal previous encoder position trackers for arm motors.- Overrides:
resetPrevEncoders
in classBot
-
updateControllerState
public void updateControllerState()Updates the arm controller with current pivot state. Should be called in the main OpMode loop afterupdateEncoders()
. -
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 classBot
-
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.
-