Programming - Intake and Claw Toggle
Last updated
Last updated
When one of the triggers on the gamepad is pressed, it activates our GAMEPAD_INTAKE function. This simple if/then statement just checks which trigger is being pressed so our servo knows which way to rotate.
Because our servo is set to continuous mode in our configuration, we have the ability to tell our servo to set a power instead of moving by position increments!
When the right bumper is pressed on the gamepad, the claw on the robot either opens or closed. This prevents the driver from having to hold down the button to maintain control of a picked up specimen!
Because togglable control is not natively available in the FTC SDK, we have to make use of a couple of variables to help the robot check the state of the claw's servo and the right bumper.
Similar to what's used in our arm control's presets, lastBump checks if the right bumper is being held down and won't accept another input until its been released.
Meanwhile, clawOpen allows the servo to shift between the two set positions based on where it has last moved to. You can adjust these values based on your specific robot to have the claw open more or less.