MotorToPositionAction
Overview
MotorToPositionAction
is a RR Action
that commands a DcMotorEx
or an AdvancedDcMotor
to move to a specific encoder position using the RUN_TO_POSITION
mode. The action completes once the motor reached the target within the tolerance, or if an overcurrent is detected (via AdvancedDcMotor
).
Usage
MotorToPositionAction(DcMotorEx, int)
// You can use either an AdvancedDcMotor (recommended) or DcMotorEx
DcMotorEx armMotor = hardwareMap.get(DcMotorEx.class, "arm");
armMotor.setTargetPositionTolerance(10); // Optional: adjust tolerance (default: 10)
runBlocking(
new SequentialAction(
new MotorToPositionAction(armMotor, 1000), // Extend arm
new ServoToPositionAction(claw, 0.0) // Open claw after arm is extended
)
);
Last updated