more gamepadissues

This commit is contained in:
sihan 2024-03-04 10:46:16 -06:00
parent a8e3634faf
commit 58bbd69a21
3 changed files with 75 additions and 71 deletions

View File

@ -71,17 +71,19 @@ public class Robot {
private Slides slides;
GamepadEx controller2 = new GamepadEx(gamepad2);
GamepadEx controller1 = new GamepadEx(gamepad1);
public Robot init(HardwareMap hardwareMap) {
this.drive = new MecanumDrive(hardwareMap);
this.hang = new Hang().init(hardwareMap);
this.arm = new Arm().init(hardwareMap);
this.wrist = new Wrist().init(hardwareMap);
this.claw = new Claw().init(hardwareMap);
this.camera = new Camera(hardwareMap);
this.plane = new Plane().init(hardwareMap);
this.slides= new Slides().init(hardwareMap);
this.led = new Led().init(hardwareMap);
// this.hang = new Hang().init(hardwareMap);
// this.arm = new Arm().init(hardwareMap);
// this.wrist = new Wrist().init(hardwareMap);
// this.claw = new Claw().init(hardwareMap);
// this.camera = new Camera(hardwareMap);
// this.plane = new Plane().init(hardwareMap);
// this.slides= new Slides().init(hardwareMap);
// this.led = new Led().init(hardwareMap);
return this;
}

View File

@ -32,11 +32,12 @@ import com.acmerobotics.roadrunner.trajectory.constraints.MinVelocityConstraint;
import com.acmerobotics.roadrunner.trajectory.constraints.ProfileAccelerationConstraint;
import com.acmerobotics.roadrunner.trajectory.constraints.TrajectoryAccelerationConstraint;
import com.acmerobotics.roadrunner.trajectory.constraints.TrajectoryVelocityConstraint;
import com.arcrobotics.ftclib.gamepad.GamepadEx;
import com.arcrobotics.ftclib.gamepad.GamepadKeys;
import com.qualcomm.hardware.lynx.LynxModule;
import com.qualcomm.hardware.rev.RevHubOrientationOnRobot;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.Gamepad;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.IMU;
import com.qualcomm.robotcore.hardware.PIDFCoefficients;
@ -323,15 +324,15 @@ public class MecanumDrive extends com.acmerobotics.roadrunner.drive.MecanumDr
return new ProfileAccelerationConstraint(maxAccel);
}
public void setInput(Gamepad gamepad1, Gamepad gamepad2) {
double speedScale = gamepad1.y ? SLOWMODE_SPEED : SPEED;
double turnScale = gamepad1.y ? SLOWMODE_TURN : TURN;
public void setInput(GamepadEx controller1, GamepadEx controller2) {
double speedScale = controller1.isDown(GamepadKeys.Button.Y) ? SLOWMODE_SPEED : SPEED;
double turnScale = controller1.isDown(GamepadKeys.Button.Y) ? SLOWMODE_TURN : TURN;
this.setWeightedDrivePower(
new Pose2d(
gamepad1.left_stick_y* -1 * speedScale,
gamepad1.left_stick_x*-1 * speedScale,
-gamepad1.right_stick_x * turnScale
controller1.getLeftY()* -1 * speedScale,
controller1.getLeftX()*-1 * speedScale,
-controller1.getRightX() * turnScale
));
}
}

View File

@ -1,7 +1,6 @@
package org.firstinspires.ftc.teamcode.opmodes;
import com.arcrobotics.ftclib.gamepad.GamepadEx;
import com.arcrobotics.ftclib.gamepad.GamepadKeys;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import org.firstinspires.ftc.teamcode.hardware.Robot;
@ -18,63 +17,65 @@ public class MainTeleOp extends OpMode {
}
GamepadEx controller2 = new GamepadEx(gamepad2);
GamepadEx controller1 = new GamepadEx(gamepad1);
public void loop() {
boolean slideUp = controller2.isDown(GamepadKeys.Button.DPAD_UP);
boolean slideDown = controller2.isDown(GamepadKeys.Button.DPAD_LEFT);
boolean hang = gamepad2.left_bumper;
boolean hangRelease = gamepad2.right_bumper;
boolean hangPlane = gamepad2.y;
boolean plane = gamepad2.dpad_right;
// boolean slideUp = controller2.isDown(GamepadKeys.Button.DPAD_UP);
// boolean slideDown = controller2.isDown(GamepadKeys.Button.DPAD_LEFT);
// boolean hang = gamepad2.left_bumper;
// boolean hangRelease = gamepad2.right_bumper;
// boolean hangPlane = gamepad2.y;
// boolean plane = gamepad2.dpad_right;
//Drive
robot.getDrive().setInput(gamepad1, gamepad2);
robot.getDrive().setInput(controller1, controller2);
//slides
if (slideUp) {
this.robot.getSlides().slideUp();
} else if (slideDown) {
this.robot.getSlides().slideDown();
} else if (controller2.wasJustReleased(GamepadKeys.Button.DPAD_DOWN)
|| controller2.wasJustReleased(GamepadKeys.Button.DPAD_LEFT)) {
this.robot.getSlides().slideStop();
}
//Macros
this.robot.pickupMacro(controller2, getRuntime()); //DPADDOWN
//Arm and Wrist
if (controller2.wasJustPressed(GamepadKeys.Button.X)) {
this.robot.getArm().armSecondaryScore();
this.robot.getWrist().wristScore();
} else if (controller2.wasJustPressed(GamepadKeys.Button.A)) {
this.robot.getArm().armRest();
this.robot.getWrist().wristPickup();
}
//Claw
if (controller2.wasJustPressed(GamepadKeys.Button.B)) {
gamepad1.rumble(300);
} else if (controller2.isDown(GamepadKeys.Button.B)){
this.robot.getClaw().open();
} else if (controller2.wasJustReleased(GamepadKeys.Button.B)){
this.robot.getClaw().close();
}
//Hang
if (hang) {
this.robot.getHang().hang();
} else if (hangRelease){
this.robot.getHang().hangRelease();
} else if (hangPlane) {
this.robot.getHang().hangPlane();
}
int Position = this.robot.getHang().hangRight.getCurrentPosition();
telemetry.addData("position",(Position));
telemetry.update();
//Plane
if (plane) {
this.robot.getPlane().planeLaunch();
}else {
this.robot.getPlane().planeLock();
}
// if (slideUp) {
// this.robot.getSlides().slideUp();
// } else if (slideDown) {
// this.robot.getSlides().slideDown();
// } else if (controller2.wasJustReleased(GamepadKeys.Button.DPAD_UP)
// || controller2.wasJustReleased(GamepadKeys.Button.DPAD_LEFT)) {
// this.robot.getSlides().slideStop();
// }
////Macros
// this.robot.pickupMacro(controller2, getRuntime()); //DPADDOWN
//
////Arm and Wrist
// if (controller2.wasJustPressed(GamepadKeys.Button.X)) {
// this.robot.getArm().armSecondaryScore();
// this.robot.getWrist().wristScore();
// } else if (controller2.wasJustPressed(GamepadKeys.Button.A)) {
// this.robot.getArm().armRest();
// this.robot.getWrist().wristPickup();
// }
////Claw
// if (controller2.wasJustPressed(GamepadKeys.Button.B)) {
// gamepad1.rumble(300);
// } else if (controller2.isDown(GamepadKeys.Button.B)){
// this.robot.getClaw().open();
// } else if (controller2.wasJustReleased(GamepadKeys.Button.B)){
// this.robot.getClaw().close();
// }
////Hang
// if (hang) {
// this.robot.getHang().hang();
// } else if (hangRelease){
// this.robot.getHang().hangRelease();
// } else if (hangPlane) {
// this.robot.getHang().hangPlane();
// }
//
// int Position = this.robot.getHang().hangRight.getCurrentPosition();
// telemetry.addData("position",(Position));
// telemetry.update();
//
////Plane
// if (plane) {
// this.robot.getPlane().planeLaunch();
// }else {
// this.robot.getPlane().planeLock();
// }
//
}
}
}