Skip to content

Commit

Permalink
danna - added bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelv committed Jun 14, 2024
1 parent c77895a commit ce41118
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
package org.firstinspires.ftc.teamcode;

import com.arcrobotics.ftclib.gamepad.GamepadEx;
import com.arcrobotics.ftclib.gamepad.GamepadKeys;
import com.qualcomm.robotcore.hardware.Gamepad;

import org.firstinspires.ftc.teamcode.subsystems.wrist.WristCommands;
import org.firstinspires.ftc.teamcode.subsystems.wrist.WristState;

public class Bindings {

private static GamepadEx MAIN_GAMEPAD;
private static GamepadEx SECOND_GAMEPAD;

public static void wristBindings(Gamepad gamepad1, Gamepad gamepad2){
MAIN_GAMEPAD = new GamepadEx(gamepad1);
SECOND_GAMEPAD = new GamepadEx(gamepad2);

MAIN_GAMEPAD.getGamepadButton(GamepadKeys.Button.B).whenPressed(WristCommands.moveToStateCommand(WristState.SCORE));
MAIN_GAMEPAD.getGamepadButton(GamepadKeys.Button.X).whenPressed(WristCommands.moveToStateCommand(WristState.INTAKE));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.firstinspires.ftc.teamcode.opmodes.testers;

import com.qualcomm.robotcore.eventloop.opmode.TeleOp;

import org.firstinspires.ftc.teamcode.Bindings;
import org.firstinspires.ftc.teamcode.opmodes.DefaultRaz;

@TeleOp(name = "Wrist Test")
public class WristTest extends DefaultRaz {
@Override
public void initialize() {

}

@Override
public void execute() {

}

@Override
public void configureBindings() {
Bindings.wristBindings(gamepad1, gamepad2);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public Wrist(HardwareMap hardwareMap){

public void setState(WristState state){
currentState = state;
wristServo.setPosition(currentState.positionZeroToOne);
wristServo.setPosition(currentState.targetPosition);
}

public boolean isAtTargetState(WristState targetState){
return Math.abs(targetState.positionZeroToOne - wristServo.getPosition()) < WristConstants.POSITION_TOLERANCE;
return Math.abs(targetState.targetPosition - wristServo.getPosition()) < WristConstants.POSITION_TOLERANCE;
}

public void stop(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ public enum WristState {
INTAKE(WristConstants.INTAKE_POSITION),
SCORE(WristConstants.SCORE_POSITION);

public final double positionZeroToOne;
WristState(double positionZeroToOne){
this.positionZeroToOne = positionZeroToOne;
public final double targetPosition;
WristState(double targetPosition){
this.targetPosition = targetPosition;
}

}

0 comments on commit ce41118

Please sign in to comment.