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; private Slides slides;
GamepadEx controller2 = new GamepadEx(gamepad2); GamepadEx controller2 = new GamepadEx(gamepad2);
GamepadEx controller1 = new GamepadEx(gamepad1);
public Robot init(HardwareMap hardwareMap) { public Robot init(HardwareMap hardwareMap) {
this.drive = new MecanumDrive(hardwareMap); this.drive = new MecanumDrive(hardwareMap);
this.hang = new Hang().init(hardwareMap); // this.hang = new Hang().init(hardwareMap);
this.arm = new Arm().init(hardwareMap); // this.arm = new Arm().init(hardwareMap);
this.wrist = new Wrist().init(hardwareMap); // this.wrist = new Wrist().init(hardwareMap);
this.claw = new Claw().init(hardwareMap); // this.claw = new Claw().init(hardwareMap);
this.camera = new Camera(hardwareMap); // this.camera = new Camera(hardwareMap);
this.plane = new Plane().init(hardwareMap); // this.plane = new Plane().init(hardwareMap);
this.slides= new Slides().init(hardwareMap); // this.slides= new Slides().init(hardwareMap);
this.led = new Led().init(hardwareMap); // this.led = new Led().init(hardwareMap);
return this; 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.ProfileAccelerationConstraint;
import com.acmerobotics.roadrunner.trajectory.constraints.TrajectoryAccelerationConstraint; import com.acmerobotics.roadrunner.trajectory.constraints.TrajectoryAccelerationConstraint;
import com.acmerobotics.roadrunner.trajectory.constraints.TrajectoryVelocityConstraint; 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.lynx.LynxModule;
import com.qualcomm.hardware.rev.RevHubOrientationOnRobot; import com.qualcomm.hardware.rev.RevHubOrientationOnRobot;
import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx; import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.Gamepad;
import com.qualcomm.robotcore.hardware.HardwareMap; import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.IMU; import com.qualcomm.robotcore.hardware.IMU;
import com.qualcomm.robotcore.hardware.PIDFCoefficients; import com.qualcomm.robotcore.hardware.PIDFCoefficients;
@ -323,15 +324,15 @@ public class MecanumDrive extends com.acmerobotics.roadrunner.drive.MecanumDr
return new ProfileAccelerationConstraint(maxAccel); return new ProfileAccelerationConstraint(maxAccel);
} }
public void setInput(Gamepad gamepad1, Gamepad gamepad2) { public void setInput(GamepadEx controller1, GamepadEx controller2) {
double speedScale = gamepad1.y ? SLOWMODE_SPEED : SPEED; double speedScale = controller1.isDown(GamepadKeys.Button.Y) ? SLOWMODE_SPEED : SPEED;
double turnScale = gamepad1.y ? SLOWMODE_TURN : TURN; double turnScale = controller1.isDown(GamepadKeys.Button.Y) ? SLOWMODE_TURN : TURN;
this.setWeightedDrivePower( this.setWeightedDrivePower(
new Pose2d( new Pose2d(
gamepad1.left_stick_y* -1 * speedScale, controller1.getLeftY()* -1 * speedScale,
gamepad1.left_stick_x*-1 * speedScale, controller1.getLeftX()*-1 * speedScale,
-gamepad1.right_stick_x * turnScale -controller1.getRightX() * turnScale
)); ));
} }
} }

View File

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