Compare commits
14 Commits
branch-rc-
...
10e6bed4ca
Author | SHA1 | Date | |
---|---|---|---|
10e6bed4ca | |||
6ccedc49b0 | |||
345ea7d185 | |||
d2c64a7d91 | |||
80d542d6fc | |||
97942e9b65 | |||
4328e5bf6d | |||
9106511f2f | |||
555078478c | |||
399a21c547 | |||
90bcfbb787 | |||
00a828cfb9 | |||
bb10d3efc1 | |||
5b3c92c82c |
@ -0,0 +1,12 @@
|
|||||||
|
# Controller 1
|
||||||
|
|
||||||
|
## Motor Controls
|
||||||
|
|
||||||
|
- Left Joystick
|
||||||
|
- Forward & Backwards
|
||||||
|
- Right Joystick
|
||||||
|
- Strafe & Turning
|
||||||
|
|
||||||
|
## Arm Controls
|
||||||
|
|
||||||
|
-
|
@ -1,35 +1,35 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
//package org.firstinspires.ftc.teamcode;
|
||||||
|
//
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
//import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
//import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
//
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.runmodes.Auto;
|
//import org.firstinspires.ftc.teamcode.runmodes.Auto;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autonomous(name = "CometBot Auto", group = "Debug")
|
//@Autonomous(name = "CometBot Auto", group = "Competition")
|
||||||
public class CometBotAuto extends OpMode {
|
//public class CometBotAuto extends OpMode {
|
||||||
public Auto auto;
|
// public Auto auto;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void init() {
|
// public void init() {
|
||||||
auto = new Auto(hardwareMap, telemetry, new Follower(hardwareMap));
|
// auto = new Auto(hardwareMap, telemetry, new Follower(hardwareMap));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void start() {
|
// public void start() {
|
||||||
auto.start();
|
// auto.start();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void loop() {
|
// public void loop() {
|
||||||
auto.update();
|
// auto.update();
|
||||||
telemetry.addData("Arm State", auto.arm.getState());
|
// telemetry.addData("Arm State", auto.arm.getState());
|
||||||
telemetry.addData("Arm Position", auto.arm.getPosition());
|
// telemetry.addData("Arm Position", auto.arm.getPosition());
|
||||||
telemetry.addData("Claw State", auto.claw.getState());
|
// telemetry.addData("Claw State", auto.claw.getState());
|
||||||
telemetry.addData("Wrist State", auto.wrist.getState());
|
// telemetry.addData("Wrist State", auto.wrist.getState());
|
||||||
telemetry.addData("Wrist Position", auto.wrist.getPosition());
|
// telemetry.addData("Wrist Position", auto.wrist.getPosition());
|
||||||
telemetry.update();
|
// telemetry.update();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
@ -1,31 +1,26 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.util.action.FieldConstants.blueBucketStartPose;
|
|
||||||
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
import org.firstinspires.ftc.teamcode.runmodes.CometBotTeleopCompetition;
|
||||||
import org.firstinspires.ftc.teamcode.runmodes.Teleop;
|
import org.firstinspires.ftc.teamcode.runmodes.DevTeleopRunModeCompetition;
|
||||||
|
|
||||||
@TeleOp(name="ComeBot Drive", group="Debug")
|
@TeleOp(name = "ComeBot Drive", group = "Competition")
|
||||||
@Disabled
|
|
||||||
public class CometBotDrive extends OpMode {
|
public class CometBotDrive extends OpMode {
|
||||||
|
|
||||||
private Teleop teleop;
|
public CometBotTeleopCompetition runMode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
teleop = new Teleop(hardwareMap,
|
this.runMode = new CometBotTeleopCompetition(hardwareMap, telemetry, gamepad1, gamepad2);
|
||||||
telemetry,
|
this.runMode.init();
|
||||||
new Follower(hardwareMap),
|
|
||||||
gamepad1);
|
|
||||||
teleop.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loop() {
|
public void loop() {
|
||||||
teleop.update();
|
this.runMode.update();
|
||||||
|
telemetry.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,97 +1,97 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
//package org.firstinspires.ftc.teamcode;
|
||||||
|
//
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
//import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
//import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
//import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
//import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
//
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
|
//
|
||||||
@TeleOp(name = "Dev Teleop Remix", group = "Debug")
|
//@TeleOp(name = "Dev Teleop Remix", group = "Debug")
|
||||||
@Disabled
|
//@Disabled
|
||||||
public class DevTeleOpRemix extends OpMode {
|
//public class DevTeleOpRemix extends OpMode {
|
||||||
|
//
|
||||||
public ClawSubsystem claw;
|
// public ClawSubsystem claw;
|
||||||
public ArmSubsystem arm;
|
// public ArmSubsystem arm;
|
||||||
public WristSubsystem wrist;
|
// public WristSubsystem wrist;
|
||||||
public LiftSubsystem lift;
|
// public LiftSubsystem lift;
|
||||||
public MotorsSubsystem motors;
|
// public MotorsSubsystem motors;
|
||||||
|
//
|
||||||
public Gamepad currentGamepad1;
|
// public Gamepad currentGamepad1;
|
||||||
public Gamepad previousGamepad1;
|
// public Gamepad previousGamepad1;
|
||||||
public Gamepad currentGamepad2;
|
// public Gamepad currentGamepad2;
|
||||||
public Gamepad previousGamepad2;
|
// public Gamepad previousGamepad2;
|
||||||
|
//
|
||||||
public double power = .6;
|
// public double power = .6;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void init() {
|
// public void init() {
|
||||||
|
//
|
||||||
claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.CLOSED);
|
// claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
arm = new ArmSubsystem(hardwareMap, ArmSubsystem.ArmState.PARK);
|
// arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
wrist = new WristSubsystem(hardwareMap, WristSubsystem.WristState.FLOOR);
|
// wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
lift = new LiftSubsystem(hardwareMap);
|
// lift = new LiftSubsystem(hardwareMap, telemetry);
|
||||||
motors = new MotorsSubsystem(hardwareMap, telemetry, power);
|
// motors = new MotorsSubsystem(hardwareMap, telemetry, power);
|
||||||
|
//
|
||||||
claw.init();
|
// claw.init();
|
||||||
arm.init();
|
// arm.init();
|
||||||
wrist.init();
|
// wrist.init();
|
||||||
lift.init();
|
// lift.init();
|
||||||
motors.init();
|
// motors.init();
|
||||||
|
//
|
||||||
currentGamepad1 = new Gamepad();
|
// currentGamepad1 = new Gamepad();
|
||||||
previousGamepad1 = new Gamepad();
|
// previousGamepad1 = new Gamepad();
|
||||||
currentGamepad2 = new Gamepad();
|
// currentGamepad2 = new Gamepad();
|
||||||
previousGamepad2 = new Gamepad();
|
// previousGamepad2 = new Gamepad();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
// public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
if (currentGamepad1.a && !previousGamepad1.a) {
|
// if (currentGamepad1.a && !previousGamepad1.a) {
|
||||||
wrist.floorWrist();
|
// wrist.toFloorPosition();
|
||||||
arm.engageArm();
|
// arm.toFloorPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void thePickup(ClawSubsystem claw) {
|
// public void thePickup(ClawSubsystem claw) {
|
||||||
if (currentGamepad1.x && !previousGamepad1.x) {
|
// if (currentGamepad1.x && !previousGamepad1.x) {
|
||||||
claw.switchState();
|
// claw.switchState();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
// public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
if (currentGamepad1.b && !previousGamepad1.b) {
|
// if (currentGamepad1.b && !previousGamepad1.b) {
|
||||||
arm.parkArm();
|
// arm.toParkPosition();
|
||||||
wrist.bucketWrist();
|
// wrist.toBucketPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
// public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
||||||
if (currentGamepad1.y && !previousGamepad1.y) {
|
// if (currentGamepad1.y && !previousGamepad1.y) {
|
||||||
lift.toLowBucket();
|
// lift.toLowBucket();
|
||||||
wrist.bucketWrist();
|
// wrist.toBucketPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void loop() {
|
// public void loop() {
|
||||||
|
//
|
||||||
previousGamepad1.copy(currentGamepad1);
|
// previousGamepad1.copy(currentGamepad1);
|
||||||
currentGamepad1.copy(gamepad1);
|
// currentGamepad1.copy(gamepad1);
|
||||||
|
//
|
||||||
previousGamepad2.copy(currentGamepad2);
|
// previousGamepad2.copy(currentGamepad2);
|
||||||
currentGamepad2.copy(gamepad2);
|
// currentGamepad2.copy(gamepad2);
|
||||||
|
//
|
||||||
theDrop(arm, wrist);
|
// theDrop(arm, wrist);
|
||||||
thePickup(claw);
|
// thePickup(claw);
|
||||||
theLift(arm, wrist);
|
// theLift(arm, wrist);
|
||||||
theLowBucketScore(lift, wrist, arm);
|
// theLowBucketScore(lift, wrist, arm);
|
||||||
|
//
|
||||||
motors.calculateTrajectory(gamepad1);
|
// motors.calculateTrajectory(gamepad1);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,107 +1,107 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
//package org.firstinspires.ftc.teamcode;
|
||||||
|
//
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
//import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
//import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
//import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
//import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
//
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
|
//
|
||||||
@TeleOp(name = "Dev Teleop Remix Deux", group = "Debug")
|
//@TeleOp(name = "Dev Teleop Remix Deux", group = "Debug")
|
||||||
@Disabled
|
//@Disabled
|
||||||
public class DevTeleOpRemixDeux extends OpMode {
|
//public class DevTeleOpRemixDeux extends OpMode {
|
||||||
|
//
|
||||||
private Follower follower;
|
// private Follower follower;
|
||||||
|
//
|
||||||
public ClawSubsystem claw;
|
// public ClawSubsystem claw;
|
||||||
public ArmSubsystem arm;
|
// public ArmSubsystem arm;
|
||||||
public WristSubsystem wrist;
|
// public WristSubsystem wrist;
|
||||||
public LiftSubsystem lift;
|
// public LiftSubsystem lift;
|
||||||
public MotorsSubsystem motors;
|
// public MotorsSubsystem motors;
|
||||||
|
//
|
||||||
public Gamepad currentGamepad1;
|
// public Gamepad currentGamepad1;
|
||||||
public Gamepad previousGamepad1;
|
// public Gamepad previousGamepad1;
|
||||||
public Gamepad currentGamepad2;
|
// public Gamepad currentGamepad2;
|
||||||
public Gamepad previousGamepad2;
|
// public Gamepad previousGamepad2;
|
||||||
|
//
|
||||||
public double power = .6;
|
// public double power = .6;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void init() {
|
// public void init() {
|
||||||
|
//
|
||||||
follower = new Follower(hardwareMap);
|
// follower = new Follower(hardwareMap);
|
||||||
|
//
|
||||||
claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.CLOSED);
|
// claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
arm = new ArmSubsystem(hardwareMap, ArmSubsystem.ArmState.PARK);
|
// arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
wrist = new WristSubsystem(hardwareMap, WristSubsystem.WristState.FLOOR);
|
// wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
motors = new MotorsSubsystem(hardwareMap, telemetry);
|
// motors = new MotorsSubsystem(hardwareMap, telemetry);
|
||||||
lift = new LiftSubsystem(hardwareMap);
|
// lift = new LiftSubsystem(hardwareMap, telemetry);
|
||||||
|
//
|
||||||
claw.init();
|
// claw.init();
|
||||||
arm.init();
|
// arm.init();
|
||||||
wrist.init();
|
// wrist.init();
|
||||||
lift.init();
|
// lift.init();
|
||||||
motors.init();
|
// motors.init();
|
||||||
|
//
|
||||||
currentGamepad1 = new Gamepad();
|
// currentGamepad1 = new Gamepad();
|
||||||
previousGamepad1 = new Gamepad();
|
// previousGamepad1 = new Gamepad();
|
||||||
currentGamepad2 = new Gamepad();
|
// currentGamepad2 = new Gamepad();
|
||||||
previousGamepad2 = new Gamepad();
|
// previousGamepad2 = new Gamepad();
|
||||||
|
//
|
||||||
follower.setMaxPower(this.power);
|
// follower.setMaxPower(this.power);
|
||||||
follower.startTeleopDrive();
|
// follower.startTeleopDrive();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
// public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
if (currentGamepad1.a && !previousGamepad1.a) {
|
// if (currentGamepad1.a && !previousGamepad1.a) {
|
||||||
wrist.floorWrist();
|
// wrist.toFloorPosition();
|
||||||
arm.engageArm();
|
// arm.toFloorPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void thePickup(ClawSubsystem claw) {
|
// public void thePickup(ClawSubsystem claw) {
|
||||||
if (currentGamepad1.x && !previousGamepad1.x) {
|
// if (currentGamepad1.x && !previousGamepad1.x) {
|
||||||
claw.switchState();
|
// claw.switchState();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
// public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
if (currentGamepad1.b && !previousGamepad1.b) {
|
// if (currentGamepad1.b && !previousGamepad1.b) {
|
||||||
arm.parkArm();
|
// arm.toParkPosition();
|
||||||
wrist.bucketWrist();
|
// wrist.toBucketPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
// public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
||||||
if (currentGamepad1.y && !previousGamepad1.y) {
|
// if (currentGamepad1.y && !previousGamepad1.y) {
|
||||||
lift.toLowBucket();
|
// lift.toLowBucket();
|
||||||
wrist.bucketWrist();
|
// wrist.toBucketPosition();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void loop() {
|
// public void loop() {
|
||||||
|
//
|
||||||
previousGamepad1.copy(currentGamepad1);
|
// previousGamepad1.copy(currentGamepad1);
|
||||||
currentGamepad1.copy(gamepad1);
|
// currentGamepad1.copy(gamepad1);
|
||||||
|
//
|
||||||
previousGamepad2.copy(currentGamepad2);
|
// previousGamepad2.copy(currentGamepad2);
|
||||||
currentGamepad2.copy(gamepad2);
|
// currentGamepad2.copy(gamepad2);
|
||||||
|
//
|
||||||
theDrop(arm, wrist);
|
// theDrop(arm, wrist);
|
||||||
thePickup(claw);
|
// thePickup(claw);
|
||||||
theLift(arm, wrist);
|
// theLift(arm, wrist);
|
||||||
theLowBucketScore(lift, wrist, arm);
|
// theLowBucketScore(lift, wrist, arm);
|
||||||
|
//
|
||||||
follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
// follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
||||||
follower.update();
|
// follower.update();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,196 +1,24 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.LEFT_ENCODER;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.LEFT_ENCODER_DIRECTION;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER_DIRECTION;
|
|
||||||
|
|
||||||
import android.graphics.Point;
|
|
||||||
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
|
||||||
import com.qualcomm.robotcore.hardware.DcMotorEx;
|
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Encoder;
|
import org.firstinspires.ftc.teamcode.runmodes.DevTeleopRunModeCompetition;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
|
||||||
|
|
||||||
@TeleOp(name = "Dev Teleop", group = "Debug")
|
@TeleOp(name = "Dev Teleop RR Actions", group = "Debug")
|
||||||
public class DevTeleop extends OpMode {
|
public class DevTeleop extends OpMode {
|
||||||
|
|
||||||
public ClawSubsystem claw;
|
public DevTeleopRunModeCompetition runMode;
|
||||||
public ArmSubsystem arm;
|
|
||||||
public WristSubsystem wrist;
|
|
||||||
public LiftSubsystem lift;
|
|
||||||
public Gamepad currentGamepad1;
|
|
||||||
public Gamepad previousGamepad1;
|
|
||||||
public Gamepad currentGamepad2;
|
|
||||||
public Gamepad previousGamepad2;
|
|
||||||
public DcMotor frontLeftMotor;
|
|
||||||
public DcMotor backLeftMotor;
|
|
||||||
public DcMotor frontRightMotor;
|
|
||||||
public DcMotor backRightMotor;
|
|
||||||
|
|
||||||
private double MAX_POWER = .45;
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.CLOSED);
|
this.runMode = new DevTeleopRunModeCompetition(hardwareMap, telemetry, gamepad1, gamepad2);
|
||||||
arm = new ArmSubsystem(hardwareMap, ArmSubsystem.ArmState.PARK);
|
this.runMode.init();
|
||||||
wrist = new WristSubsystem(hardwareMap, WristSubsystem.WristState.FLOOR);
|
|
||||||
lift = new LiftSubsystem(hardwareMap);
|
|
||||||
claw.init();
|
|
||||||
arm.init();
|
|
||||||
wrist.init();
|
|
||||||
lift.init();
|
|
||||||
|
|
||||||
frontLeftMotor = hardwareMap.get(DcMotor.class, FRONT_LEFT_MOTOR);
|
|
||||||
backLeftMotor = hardwareMap.get(DcMotor.class, BACK_LEFT_MOTOR);
|
|
||||||
frontRightMotor = hardwareMap.get(DcMotor.class, FRONT_RIGHT_MOTOR);
|
|
||||||
backRightMotor = hardwareMap.get(DcMotor.class, BACK_RIGHT_MOTOR);
|
|
||||||
|
|
||||||
frontLeftMotor.setDirection(FRONT_LEFT_MOTOR_DIRECTION);
|
|
||||||
backLeftMotor.setDirection(BACK_LEFT_MOTOR_DIRECTION);
|
|
||||||
frontRightMotor.setDirection(FRONT_RIGHT_MOTOR_DIRECTION);
|
|
||||||
backRightMotor.setDirection(BACK_RIGHT_MOTOR_DIRECTION);
|
|
||||||
|
|
||||||
currentGamepad1 = new Gamepad();
|
|
||||||
previousGamepad1 = new Gamepad();
|
|
||||||
currentGamepad2 = new Gamepad();
|
|
||||||
previousGamepad2 = new Gamepad();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
|
||||||
//pick up
|
|
||||||
if (currentGamepad2.dpad_down && !previousGamepad2.dpad_down) {
|
|
||||||
wrist.floorWrist();
|
|
||||||
arm.engageArm();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public void thePickup(ClawSubsystem claw) {
|
|
||||||
//claw open close
|
|
||||||
if (currentGamepad2.right_bumper && !previousGamepad2.right_bumper) {
|
|
||||||
claw.switchState();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
|
||||||
|
|
||||||
if (currentGamepad1.b && !previousGamepad1.b) {
|
|
||||||
arm.parkArm();
|
|
||||||
wrist.bucketWrist();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
|
||||||
//low bucket
|
|
||||||
if (currentGamepad2.a && !previousGamepad2.a) {
|
|
||||||
lift.toLowBucket();
|
|
||||||
arm.bucketArm();
|
|
||||||
wrist.bucketWrist();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void theHighBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
|
||||||
//high basket
|
|
||||||
if (currentGamepad2.b && !previousGamepad2.b) {
|
|
||||||
lift.toHighBucket();
|
|
||||||
arm.bucketArm();
|
|
||||||
wrist.bucketWrist();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void theTravel(LiftSubsystem lift, ArmSubsystem arm, WristSubsystem wrist){
|
|
||||||
//
|
|
||||||
if (currentGamepad2.dpad_right && !previousGamepad2.dpad_right){
|
|
||||||
lift.toFloor();
|
|
||||||
arm.bucketArm();
|
|
||||||
wrist.floorWrist();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hoverState(ArmSubsystem arm, WristSubsystem wrist, LiftSubsystem lift){
|
|
||||||
if (currentGamepad1.dpad_left && !previousGamepad2.dpad_left){
|
|
||||||
lift.toHover();
|
|
||||||
wrist.floorWrist();
|
|
||||||
arm.engageArm();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loop() {
|
public void loop() {
|
||||||
previousGamepad1.copy(currentGamepad1);
|
this.runMode.update();
|
||||||
currentGamepad1.copy(gamepad1);
|
|
||||||
previousGamepad2.copy(currentGamepad2);
|
|
||||||
currentGamepad2.copy(gamepad2);
|
|
||||||
|
|
||||||
|
|
||||||
theDrop(arm, wrist);
|
|
||||||
thePickup(claw);
|
|
||||||
// theLift(arm, wrist);
|
|
||||||
theLowBucketScore(lift, wrist, arm);
|
|
||||||
theHighBucketScore(lift, wrist, arm);
|
|
||||||
theTravel(lift, arm, wrist);
|
|
||||||
|
|
||||||
double max;
|
|
||||||
|
|
||||||
// POV Mode uses left joystick to go forward & strafe, and right joystick to rotate.
|
|
||||||
double axial = -gamepad1.left_stick_y; // Note: pushing stick forward gives negative value
|
|
||||||
double lateral = gamepad1.left_stick_x;
|
|
||||||
double yaw = gamepad1.right_stick_x;
|
|
||||||
|
|
||||||
// Combine the joystick requests for each axis-motion to determine each wheel's power.
|
|
||||||
// Set up a variable for each drive wheel to save the power level for telemetry.
|
|
||||||
double leftFrontPower = axial + lateral + yaw;
|
|
||||||
double rightFrontPower = axial - lateral - yaw;
|
|
||||||
double leftBackPower = axial - lateral + yaw;
|
|
||||||
double rightBackPower = axial + lateral - yaw;
|
|
||||||
|
|
||||||
// Normalize the values so no wheel power exceeds 100%
|
|
||||||
// This ensures that the robot maintains the desired motion.
|
|
||||||
max = Math.max(Math.abs(leftFrontPower), Math.abs(rightFrontPower));
|
|
||||||
max = Math.max(max, Math.abs(leftBackPower));
|
|
||||||
max = Math.max(max, Math.abs(rightBackPower));
|
|
||||||
|
|
||||||
if (max > 1.0) {
|
|
||||||
leftFrontPower /= max;
|
|
||||||
rightFrontPower /= max;
|
|
||||||
leftBackPower /= max;
|
|
||||||
rightBackPower /= max;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Send calculated power to wheels
|
|
||||||
frontLeftMotor.setPower(leftFrontPower * MAX_POWER);
|
|
||||||
frontRightMotor.setPower(rightFrontPower * MAX_POWER);
|
|
||||||
backLeftMotor.setPower(leftBackPower * MAX_POWER);
|
|
||||||
backRightMotor.setPower(rightBackPower * MAX_POWER);
|
|
||||||
|
|
||||||
// Show the elapsed game time and wheel power.
|
|
||||||
telemetry.addData("Front left/Right", "%4.2f, %4.2f", leftFrontPower, rightFrontPower);
|
|
||||||
telemetry.addData("Back left/Right", "%4.2f, %4.2f", leftBackPower, rightBackPower);
|
|
||||||
telemetry.addData("Current Lift Position", lift.getPosition());
|
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,43 +8,69 @@ import org.firstinspires.ftc.teamcode.pedroPathing.localization.Encoder;
|
|||||||
public class PedroConstants {
|
public class PedroConstants {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Robot parameters
|
Motor configuration names
|
||||||
*/
|
*/
|
||||||
// Turn localizer - -0.003
|
|
||||||
|
|
||||||
|
|
||||||
// Robot motor configurations
|
|
||||||
public static final String BRAIN_ROT = "Sikidi rizz 360 no teleop tf2 mama mia 2cool 4skool yasyasy yasyasyasyasyasyasyaysy ohio yes heh me is moar skeebeedee than u walked and got tripped on by your aunt my very educaded mother just served us nine what? just kydinfoiwfowefwofwioefoiejfeoiwjfomdsklfnslefknesfklnkfenfenkfeknfenkfeknfenkefnk";
|
|
||||||
public static final String FRONT_LEFT_MOTOR = "Drive front lt";
|
public static final String FRONT_LEFT_MOTOR = "Drive front lt";
|
||||||
public static final String BACK_LEFT_MOTOR = "Drive back lt";
|
public static final String BACK_LEFT_MOTOR = "Drive back lt";
|
||||||
public static final String FRONT_RIGHT_MOTOR = "Drive front rt";
|
public static final String FRONT_RIGHT_MOTOR = "Drive front rt";
|
||||||
public static final String BACK_RIGHT_MOTOR = "Drive back rt";
|
public static final String BACK_RIGHT_MOTOR = "Drive back rt";
|
||||||
|
|
||||||
// Robot motor direction
|
/*
|
||||||
|
Motor directions
|
||||||
|
*/
|
||||||
public static final Direction FRONT_LEFT_MOTOR_DIRECTION = Direction.REVERSE;
|
public static final Direction FRONT_LEFT_MOTOR_DIRECTION = Direction.REVERSE;
|
||||||
public static final Direction BACK_LEFT_MOTOR_DIRECTION = Direction.REVERSE;
|
public static final Direction BACK_LEFT_MOTOR_DIRECTION = Direction.REVERSE;
|
||||||
public static final Direction FRONT_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
public static final Direction FRONT_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
||||||
public static final Direction BACK_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
public static final Direction BACK_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
||||||
|
|
||||||
// Robot IMU configuration
|
/*
|
||||||
public static final String IMU = "imu";
|
Motor Max Power
|
||||||
|
*/
|
||||||
|
public static final double MAX_POWER = .75;
|
||||||
|
|
||||||
// Robot IMU placement
|
/*
|
||||||
|
IMU
|
||||||
|
*/
|
||||||
|
public static final String IMU = "imu";
|
||||||
public static final RevHubOrientationOnRobot.LogoFacingDirection IMU_LOGO_FACING_DIRECTION
|
public static final RevHubOrientationOnRobot.LogoFacingDirection IMU_LOGO_FACING_DIRECTION
|
||||||
= RevHubOrientationOnRobot.LogoFacingDirection.DOWN;
|
= RevHubOrientationOnRobot.LogoFacingDirection.DOWN;
|
||||||
public static final RevHubOrientationOnRobot.UsbFacingDirection IMU_USB_FACING_DIRECTION
|
public static final RevHubOrientationOnRobot.UsbFacingDirection IMU_USB_FACING_DIRECTION
|
||||||
= RevHubOrientationOnRobot.UsbFacingDirection.LEFT;
|
= RevHubOrientationOnRobot.UsbFacingDirection.LEFT;
|
||||||
|
|
||||||
// Robot encoders
|
/*
|
||||||
|
Dead wheels
|
||||||
|
*/
|
||||||
public static final String LEFT_ENCODER = "encoder left";
|
public static final String LEFT_ENCODER = "encoder left";
|
||||||
public static final String RIGHT_ENCODER = "encoder right";
|
public static final String RIGHT_ENCODER = "encoder right";
|
||||||
public static final String BACK_ENCODER = "encoder back";
|
public static final String BACK_ENCODER = "encoder back";
|
||||||
|
|
||||||
// Robot encoder direction
|
/*
|
||||||
|
Dead wheel directions
|
||||||
|
*/
|
||||||
public static final double LEFT_ENCODER_DIRECTION = Encoder.FORWARD;
|
public static final double LEFT_ENCODER_DIRECTION = Encoder.FORWARD;
|
||||||
public static final double RIGHT_ENCODER_DIRECTION = Encoder.FORWARD;
|
public static final double RIGHT_ENCODER_DIRECTION = Encoder.FORWARD;
|
||||||
public static final double BACK_ENCODER_DIRECTION = Encoder.FORWARD;
|
public static final double BACK_ENCODER_DIRECTION = Encoder.FORWARD;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Arm configuration name
|
||||||
|
*/
|
||||||
|
public static final String ARM_NAME = "arm-servo";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Claw configuration name
|
||||||
|
*/
|
||||||
|
public static final String CLAW_NAME = "claw-servo";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Lift configuration name
|
||||||
|
*/
|
||||||
|
public static final String LIFT_NAME = "lift-motor";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Wrist configuration name
|
||||||
|
*/
|
||||||
|
public static final String WRIST_NAME = "wrist-servo";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Pedro's parameters
|
Pedro's parameters
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
|
||||||
|
|
||||||
public class BluenbAutov1 {
|
|
||||||
}
|
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -26,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AsherOrientBlue", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AsherOrientBlue", group = "Autonomous Pathing Tuning")
|
||||||
public class AsherOrientBlue extends OpMode {
|
public class AsherOrientBlue extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -26,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AsherPathBlueV1", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AsherPathBlueV1", group = "Autonomous Pathing Tuning")
|
||||||
public class AsherPathBlueV1 extends OpMode {
|
public class AsherPathBlueV1 extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -13,7 +14,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
|||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
import com.acmerobotics.roadrunner.SleepAction;
|
||||||
/**
|
/**
|
||||||
* This is the Circle autonomous OpMode. It runs the robot in a PathChain that's actually not quite
|
* This is the Circle autonomous OpMode. It runs the robot in a PathChain that's actually not quite
|
||||||
* a circle, but some Bezier curves that have control points set essentially in a square. However,
|
* a circle, but some Bezier curves that have control points set essentially in a square. However,
|
||||||
@ -26,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AsherPathV1", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AsherPathV1", group = "Autonomous Pathing Tuning")
|
||||||
public class AsherPathV1 extends OpMode {
|
public class AsherPathV1 extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -25,6 +26,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AutoExample - Straight Path", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AutoExample - Straight Path", group = "Autonomous Pathing Tuning")
|
||||||
public class AutoExample extends OpMode {
|
public class AutoExample extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -26,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AutoExample - 2 Curves/2 Lines", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AutoExample - 2 Curves/2 Lines", group = "Autonomous Pathing Tuning")
|
||||||
public class AutoExampleFour extends OpMode {
|
public class AutoExampleFour extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -25,6 +26,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AutoExampleSeason2025V1", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AutoExampleSeason2025V1", group = "Autonomous Pathing Tuning")
|
||||||
public class AutoExampleSeason2025V1 extends OpMode {
|
public class AutoExampleSeason2025V1 extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -26,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AutoExample - Curve and Line", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AutoExample - Curve and Line", group = "Autonomous Pathing Tuning")
|
||||||
public class AutoExampleThree extends OpMode {
|
public class AutoExampleThree extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,9 +1,10 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
@ -25,6 +26,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "AutoExample - Simple Curve", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "AutoExample - Simple Curve", group = "Autonomous Pathing Tuning")
|
||||||
public class AutoExampleTwo extends OpMode {
|
public class AutoExampleTwo extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -27,7 +27,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
||||||
@ -44,6 +44,7 @@ import static org.firstinspires.ftc.teamcode.PedroConstants.LEFT_ENCODER_DIRECTI
|
|||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER_DIRECTION;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.RIGHT_ENCODER_DIRECTION;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
@ -81,6 +82,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.localization.Encoder;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@TeleOp(name="Basic: Omni Linear OpMode", group="Linear OpMode")
|
@TeleOp(name="Basic: Omni Linear OpMode", group="Linear OpMode")
|
||||||
|
@Disabled
|
||||||
public class BasicOmniOpMode_Linear extends LinearOpMode {
|
public class BasicOmniOpMode_Linear extends LinearOpMode {
|
||||||
|
|
||||||
// Declare OpMode members for each of the 4 motors.
|
// Declare OpMode members for each of the 4 motors.
|
@ -1,5 +1,6 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
@ -27,6 +28,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "BlueBasketAuto", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "BlueBasketAuto", group = "Autonomous Pathing Tuning")
|
||||||
public class BlueBasketAuto extends OpMode {
|
public class BlueBasketAuto extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
@ -1,15 +1,17 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierPoint;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
@ -25,6 +27,7 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
|
@Disabled
|
||||||
@Autonomous(name = "BluebAutoV1", group = "Autonomous Pathing Tuning")
|
@Autonomous(name = "BluebAutoV1", group = "Autonomous Pathing Tuning")
|
||||||
public class BluebAutoV1 extends OpMode {
|
public class BluebAutoV1 extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
||||||
@ -225,6 +228,14 @@ public class BluebAutoV1 extends OpMode {
|
|||||||
)
|
)
|
||||||
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
|
||||||
|
|
||||||
|
follower.holdPoint(
|
||||||
|
new BezierPoint(
|
||||||
|
new Point(13.821, 134.839, Point.CARTESIAN)
|
||||||
|
),
|
||||||
|
90
|
||||||
|
);
|
||||||
|
|
||||||
follower.followPath(path);
|
follower.followPath(path);
|
||||||
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
telemetryA.update();
|
telemetryA.update();
|
||||||
@ -239,7 +250,7 @@ public class BluebAutoV1 extends OpMode {
|
|||||||
public void loop() {
|
public void loop() {
|
||||||
follower.update();
|
follower.update();
|
||||||
if (follower.atParametricEnd()) {
|
if (follower.atParametricEnd()) {
|
||||||
follower.followPath(path);
|
follower.followPath(path, true);
|
||||||
}
|
}
|
||||||
follower.telemetryDebug(telemetryA);
|
follower.telemetryDebug(telemetryA);
|
||||||
}
|
}
|
@ -34,7 +34,7 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
import com.qualcomm.robotcore.util.ElapsedTime;
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
import org.firstinspires.ftc.teamcode.subsystem.ArmActionsSubsystem;
|
||||||
|
|
||||||
@TeleOp(name = "Arm Test", group = "Debug")
|
@TeleOp(name = "Arm Test", group = "Debug")
|
||||||
public class ArmTest extends LinearOpMode {
|
public class ArmTest extends LinearOpMode {
|
||||||
@ -48,7 +48,7 @@ public class ArmTest extends LinearOpMode {
|
|||||||
/*
|
/*
|
||||||
* Instantiate Arm
|
* Instantiate Arm
|
||||||
*/
|
*/
|
||||||
ArmSubsystem arm = new ArmSubsystem(hardwareMap, ArmSubsystem.ArmState.PARK);
|
ArmActionsSubsystem arm = new ArmActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate gamepad state holders
|
* Instantiate gamepad state holders
|
||||||
@ -67,15 +67,11 @@ public class ArmTest extends LinearOpMode {
|
|||||||
currentGamepad1.copy(gamepad1);
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
arm.parkArm();
|
arm.toParkPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.square && !previousGamepad1.square) {
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
arm.engageArm();
|
arm.toBucketPosition();
|
||||||
}
|
|
||||||
|
|
||||||
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
|
||||||
arm.switchState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
@ -34,7 +34,8 @@ import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
|||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
import com.qualcomm.robotcore.util.ElapsedTime;
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
import org.firstinspires.ftc.teamcode.subsystem.ClawActionsSubsystem;
|
||||||
|
|
||||||
|
|
||||||
@TeleOp(name = "Claw Test", group = "Debug")
|
@TeleOp(name = "Claw Test", group = "Debug")
|
||||||
public class ClawTest extends LinearOpMode {
|
public class ClawTest extends LinearOpMode {
|
||||||
@ -48,7 +49,7 @@ public class ClawTest extends LinearOpMode {
|
|||||||
/*
|
/*
|
||||||
* Instantiate Claw
|
* Instantiate Claw
|
||||||
*/
|
*/
|
||||||
ClawSubsystem claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.OPEN);
|
ClawActionsSubsystem claw = new ClawActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate gamepad state holders
|
* Instantiate gamepad state holders
|
||||||
|
@ -29,32 +29,26 @@
|
|||||||
|
|
||||||
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
||||||
|
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
import com.qualcomm.robotcore.util.ElapsedTime;
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
import org.firstinspires.ftc.teamcode.subsystem.LiftActionsSubsystem;
|
||||||
|
|
||||||
@TeleOp(name = "Lift Test", group = "Debug")
|
@TeleOp(name = "Lift Test", group = "Debug")
|
||||||
public class LiftTest extends LinearOpMode {
|
public class LiftTest extends LinearOpMode {
|
||||||
|
|
||||||
// Declare OpMode members for each of the 4 motors.
|
|
||||||
private final ElapsedTime runtime = new ElapsedTime();
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
private final int MIN_POINT = 0;
|
|
||||||
// 2000 ~ 2500
|
|
||||||
|
|
||||||
// 3750 max
|
|
||||||
private final int MAX_POINT = 6500;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() {
|
public void runOpMode() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate Lift
|
* Instantiate Lift
|
||||||
*/
|
*/
|
||||||
LiftSubsystem lift = new LiftSubsystem(hardwareMap);
|
LiftActionsSubsystem lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate gamepad state holders
|
* Instantiate gamepad state holders
|
||||||
@ -74,21 +68,29 @@ public class LiftTest extends LinearOpMode {
|
|||||||
currentGamepad1.copy(gamepad1);
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
if (currentGamepad1.square && !previousGamepad1.square) {
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
lift.toFloor();
|
Actions.runBlocking(lift.toFloorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
||||||
lift.toHighBucket();
|
Actions.runBlocking(lift.toHighBucketPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
lift.toLowBucket();
|
Actions.runBlocking(lift.toLowBucketPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
lift.switchState();
|
lift.switchState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
||||||
|
lift.setPosition(lift.getPosition() + 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
lift.setPosition(lift.getPosition() - 25);
|
||||||
|
}
|
||||||
|
|
||||||
// Show the elapsed game time and wheel power.
|
// Show the elapsed game time and wheel power.
|
||||||
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
telemetry.addData("Lift Drive Position", lift.getPosition());
|
telemetry.addData("Lift Drive Position", lift.getPosition());
|
||||||
|
@ -31,29 +31,27 @@ package org.firstinspires.ftc.teamcode.cometbots.tests;
|
|||||||
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
|
||||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
import com.qualcomm.robotcore.util.ElapsedTime;
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
@TeleOp(name = "Lift Raw Test", group = "Debug")
|
import org.firstinspires.ftc.teamcode.subsystem.ArmActionsSubsystem;
|
||||||
public class LiftRawTest extends LinearOpMode {
|
import org.firstinspires.ftc.teamcode.subsystem.LiftActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristActionsSubsystem;
|
||||||
|
|
||||||
|
@TeleOp(name = "Lift Wrist Arm Test", group = "Debug")
|
||||||
|
public class LiftWristArmTest extends LinearOpMode {
|
||||||
|
|
||||||
// Declare OpMode members for each of the 4 motors.
|
|
||||||
private final ElapsedTime runtime = new ElapsedTime();
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
private final int MIN_POINT = 0;
|
|
||||||
private final int MAX_POINT = 3700;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() {
|
public void runOpMode() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate Lift
|
* Instantiate Lift
|
||||||
*/
|
*/
|
||||||
DcMotor liftDrive = hardwareMap.get(DcMotor.class, "lift-motor");
|
LiftActionsSubsystem lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
liftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
WristActionsSubsystem wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
liftDrive.setDirection(DcMotorSimple.Direction.REVERSE);
|
ArmActionsSubsystem arm = new ArmActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate gamepad state holders
|
* Instantiate gamepad state holders
|
||||||
@ -61,6 +59,9 @@ public class LiftRawTest extends LinearOpMode {
|
|||||||
Gamepad currentGamepad1 = new Gamepad();
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
Gamepad previousGamepad1 = new Gamepad();
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
lift.init();
|
||||||
|
wrist.init();
|
||||||
|
arm.init();
|
||||||
waitForStart();
|
waitForStart();
|
||||||
runtime.reset();
|
runtime.reset();
|
||||||
|
|
||||||
@ -71,53 +72,36 @@ public class LiftRawTest extends LinearOpMode {
|
|||||||
previousGamepad1.copy(currentGamepad1);
|
previousGamepad1.copy(currentGamepad1);
|
||||||
currentGamepad1.copy(gamepad1);
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
liftDrive.setPower(.5);
|
if (currentGamepad1.dpad_up && !previousGamepad1.dpad_up) {
|
||||||
|
arm.setPosition(arm.getPosition() + .05);
|
||||||
|
}
|
||||||
|
|
||||||
// Max position is 6800, safely setting to 6500
|
if (currentGamepad1.dpad_down && !previousGamepad1.dpad_down) {
|
||||||
|
arm.setPosition(arm.getPosition() - .05);
|
||||||
if (currentGamepad1.square && !previousGamepad1.square) {
|
|
||||||
liftDrive.setTargetPosition(MIN_POINT);
|
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
||||||
liftDrive.setTargetPosition(1500);
|
wrist.setPosition(wrist.getPosition() + .05);
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
|
||||||
liftDrive.setTargetPosition(2750);
|
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
liftDrive.setTargetPosition(MAX_POINT);
|
wrist.setPosition(wrist.getPosition() - .05);
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
|
||||||
int newPosition = liftDrive.getCurrentPosition() - 125;
|
|
||||||
if (newPosition < MIN_POINT) {
|
|
||||||
liftDrive.setTargetPosition(MIN_POINT);
|
|
||||||
} else {
|
|
||||||
liftDrive.setTargetPosition(newPosition);
|
|
||||||
}
|
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
||||||
int newPosition = liftDrive.getCurrentPosition() + 125;
|
lift.setPosition(lift.getPosition() + 175);
|
||||||
if (newPosition > MAX_POINT) {
|
|
||||||
liftDrive.setTargetPosition(MAX_POINT);
|
|
||||||
} else {
|
|
||||||
liftDrive.setTargetPosition(newPosition);
|
|
||||||
}
|
}
|
||||||
liftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
||||||
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
lift.setPosition(lift.getPosition() - 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the elapsed game time and wheel power.
|
// Show the elapsed game time and wheel power.
|
||||||
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
telemetry.addData("Lift Drive Position", liftDrive.getCurrentPosition());
|
telemetry.addData("Lift Drive Position", lift.getPosition());
|
||||||
|
telemetry.addData("Wrist Position", wrist.getPosition());
|
||||||
|
telemetry.addData("Arm Position", arm.getPosition());
|
||||||
|
|
||||||
telemetry.update();
|
telemetry.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,12 +29,13 @@
|
|||||||
|
|
||||||
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
||||||
|
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
import com.qualcomm.robotcore.util.ElapsedTime;
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
import org.firstinspires.ftc.teamcode.subsystem.WristActionsSubsystem;
|
||||||
|
|
||||||
@TeleOp(name = "Wrist Test", group = "Debug")
|
@TeleOp(name = "Wrist Test", group = "Debug")
|
||||||
public class WristTest extends LinearOpMode {
|
public class WristTest extends LinearOpMode {
|
||||||
@ -48,7 +49,7 @@ public class WristTest extends LinearOpMode {
|
|||||||
/*
|
/*
|
||||||
* Instantiate Wrist
|
* Instantiate Wrist
|
||||||
*/
|
*/
|
||||||
WristSubsystem wrist = new WristSubsystem(hardwareMap, WristSubsystem.WristState.FLOOR);
|
WristActionsSubsystem wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instantiate gamepad state holders
|
* Instantiate gamepad state holders
|
||||||
@ -67,11 +68,11 @@ public class WristTest extends LinearOpMode {
|
|||||||
currentGamepad1.copy(gamepad1);
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
if (currentGamepad1.square && !previousGamepad1.square) {
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
wrist.bucketWrist();
|
Actions.runBlocking(wrist.toBucketPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
wrist.floorWrist();
|
Actions.runBlocking(wrist.toFloorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
@ -4,19 +4,20 @@ import com.acmerobotics.dashboard.config.Config;
|
|||||||
|
|
||||||
@Config
|
@Config
|
||||||
public class RobotConstants {
|
public class RobotConstants {
|
||||||
public static double clawClose = 1.00;
|
public final static double clawClose = 1.00;
|
||||||
public static double clawOpen = 0.05;
|
public final static double clawOpen = 0.05;
|
||||||
|
|
||||||
public static double armEngage = 0.5;
|
public final static double armFloor = 0.45;
|
||||||
public static double armPark = 0.125;
|
public final static double armSubmarine = 0.375;
|
||||||
public static double armBucket = 0.175;
|
public final static double armPark = 0.0;
|
||||||
|
public final static double armBucket = 0.15;
|
||||||
|
|
||||||
public static double wristFloor = 0.625;
|
public final static double wristFloor = 0.7;
|
||||||
public static double wristBucket = 0.215;
|
public final static double wristBucket = 0.35;
|
||||||
public static int liftToFloorPos = 20;
|
|
||||||
public static int liftToFloatPos = 150;
|
public final static int liftToFloorPos = 0;
|
||||||
public static int liftToLowBucketPos = 2250;
|
public final static int liftToSubmarinePos = 250;
|
||||||
public static int liftToHighBucketPos = 3900;
|
public final static int liftToLowBucketPos = 2250;
|
||||||
public static double liftPower = .45;
|
public final static int liftToHighBucketPos = 3850;
|
||||||
public static int liftToHoverState = 60;
|
public final static double liftPower = .625;
|
||||||
}
|
}
|
@ -1,114 +1,103 @@
|
|||||||
package org.firstinspires.ftc.teamcode.runmodes;
|
//package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
//
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
//import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
//
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
//import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.util.Timer;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
//import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Path;
|
//import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
//import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
//
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.util.Timer;
|
//public class Auto {
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
//
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
// public ClawSubsystem claw;
|
||||||
import static org.firstinspires.ftc.teamcode.util.action.FieldConstants.*;
|
// public ArmSubsystem arm;
|
||||||
|
// public WristSubsystem wrist;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
//
|
||||||
import org.firstinspires.ftc.teamcode.util.action.Action;
|
// public Timer clawTimer = new Timer();
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
// public Timer armTimer = new Timer();
|
||||||
import org.firstinspires.ftc.teamcode.util.action.SequentialAction;
|
// public Timer wristTimer = new Timer();
|
||||||
import org.firstinspires.ftc.teamcode.util.action.SleepAction;
|
//
|
||||||
|
// public Follower follower;
|
||||||
public class Auto {
|
// public Telemetry telemetry;
|
||||||
|
//
|
||||||
public ClawSubsystem claw;
|
// public int caseState = 1;
|
||||||
public ArmSubsystem arm;
|
//
|
||||||
public WristSubsystem wrist;
|
// public Auto(HardwareMap hardwareMap, Telemetry telemetry, Follower follower) {
|
||||||
|
// claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
public Timer clawTimer = new Timer();
|
// arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
public Timer armTimer = new Timer();
|
// wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
public Timer wristTimer = new Timer();
|
//
|
||||||
|
// this.follower = follower;
|
||||||
public Follower follower;
|
// this.telemetry = telemetry;
|
||||||
public Telemetry telemetry;
|
//
|
||||||
|
// init();
|
||||||
public int caseState = 1;
|
// }
|
||||||
|
//
|
||||||
public Auto(HardwareMap hardwareMap, Telemetry telemetry, Follower follower) {
|
// public void init() {
|
||||||
claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.CLOSED);
|
// claw.init();
|
||||||
arm = new ArmSubsystem(hardwareMap, ArmSubsystem.ArmState.PARK);
|
// arm.init();
|
||||||
wrist = new WristSubsystem(hardwareMap, WristSubsystem.WristState.FLOOR);
|
// wrist.init();
|
||||||
|
// }
|
||||||
this.follower = follower;
|
//
|
||||||
this.telemetry = telemetry;
|
// public void start() {
|
||||||
|
// clawTimer.resetTimer();
|
||||||
init();
|
// armTimer.resetTimer();
|
||||||
}
|
// wristTimer.resetTimer();
|
||||||
|
//
|
||||||
public void init() {
|
// claw.start();
|
||||||
claw.init();
|
// arm.start();
|
||||||
arm.init();
|
// wrist.start();
|
||||||
wrist.init();
|
// }
|
||||||
}
|
//
|
||||||
|
// public void update() {
|
||||||
public void start() {
|
//
|
||||||
clawTimer.resetTimer();
|
// this.telemetry.addData("Current State", caseState);
|
||||||
armTimer.resetTimer();
|
// this.telemetry.addData("Claw Timer", clawTimer.getElapsedTimeSeconds());
|
||||||
wristTimer.resetTimer();
|
// this.telemetry.addData("Arm Timer", armTimer.getElapsedTimeSeconds());
|
||||||
|
// this.telemetry.addData("Wrist Timer", wristTimer.getElapsedTimeSeconds());
|
||||||
claw.start();
|
// this.telemetry.update();
|
||||||
arm.start();
|
//
|
||||||
wrist.start();
|
// switch (caseState) {
|
||||||
}
|
// case 1:
|
||||||
|
// claw.openClaw();
|
||||||
public void update() {
|
// caseState = 2;
|
||||||
|
// break;
|
||||||
this.telemetry.addData("Current State", caseState);
|
// case 2:
|
||||||
this.telemetry.addData("Claw Timer", clawTimer.getElapsedTimeSeconds());
|
// if (clawTimer.getElapsedTimeSeconds() > 2) {
|
||||||
this.telemetry.addData("Arm Timer", armTimer.getElapsedTimeSeconds());
|
// arm.toFloorPosition();
|
||||||
this.telemetry.addData("Wrist Timer", wristTimer.getElapsedTimeSeconds());
|
// caseState = 3;
|
||||||
this.telemetry.update();
|
// }
|
||||||
|
// break;
|
||||||
switch(caseState) {
|
// case 3:
|
||||||
case 1:
|
// if (armTimer.getElapsedTimeSeconds() > 4) {
|
||||||
claw.openClaw();
|
// wrist.toFloorPosition();
|
||||||
caseState = 2;
|
// caseState = 4;
|
||||||
break;
|
// }
|
||||||
case 2:
|
// break;
|
||||||
if (clawTimer.getElapsedTimeSeconds() > 2) {
|
// case 4:
|
||||||
arm.engageArm();
|
// if (clawTimer.getElapsedTimeSeconds() > 6) {
|
||||||
caseState = 3;
|
// claw.closeClaw();
|
||||||
}
|
// caseState = 5;
|
||||||
break;
|
// }
|
||||||
case 3:
|
// break;
|
||||||
if (armTimer.getElapsedTimeSeconds() > 4) {
|
// case 5:
|
||||||
wrist.floorWrist();
|
// if (armTimer.getElapsedTimeSeconds() > 8) {
|
||||||
caseState = 4;
|
// arm.toBucketPosition();
|
||||||
}
|
// wrist.toBucketPosition();
|
||||||
break;
|
// caseState = 6;
|
||||||
case 4:
|
// }
|
||||||
if (clawTimer.getElapsedTimeSeconds() > 6) {
|
// break;
|
||||||
claw.closeClaw();
|
// case 6:
|
||||||
caseState = 5;
|
// if (clawTimer.getElapsedTimeSeconds() > 10) {
|
||||||
}
|
// claw.openClaw();
|
||||||
break;
|
// caseState = 7;
|
||||||
case 5:
|
// }
|
||||||
if (armTimer.getElapsedTimeSeconds() > 8) {
|
// break;
|
||||||
arm.bucketArm();
|
// case 7:
|
||||||
wrist.bucketWrist();
|
// this.init();
|
||||||
caseState = 6;
|
// break;
|
||||||
}
|
// }
|
||||||
break;
|
// }
|
||||||
case 6:
|
//}
|
||||||
if (clawTimer.getElapsedTimeSeconds() > 10) {
|
|
||||||
claw.openClaw();
|
|
||||||
caseState = 7;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
this.init();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,187 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.MAX_POWER;
|
||||||
|
|
||||||
|
import com.acmerobotics.roadrunner.SequentialAction;
|
||||||
|
import com.acmerobotics.roadrunner.SleepAction;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.states.FieldStates;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ArmActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ClawActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.LiftActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristActionsSubsystem;
|
||||||
|
|
||||||
|
public class CometBotTeleopCompetition {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Subsystems
|
||||||
|
*/
|
||||||
|
private MotorsSubsystem motors;
|
||||||
|
public ClawActionsSubsystem claw;
|
||||||
|
public ArmActionsSubsystem arm;
|
||||||
|
public WristActionsSubsystem wrist;
|
||||||
|
public LiftActionsSubsystem lift;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controllers
|
||||||
|
*/
|
||||||
|
public Gamepad GP1;
|
||||||
|
public Gamepad GP2;
|
||||||
|
public Gamepad currentGP1;
|
||||||
|
public Gamepad previousGP1;
|
||||||
|
public Gamepad currentGP2;
|
||||||
|
public Gamepad previousGP2;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
public FieldStates fieldStates;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
public CometBotTeleopCompetition(HardwareMap hardwareMap, Telemetry telemetry, Gamepad gp1, Gamepad gp2) {
|
||||||
|
this.motors = new MotorsSubsystem(hardwareMap, telemetry, .55);
|
||||||
|
this.claw = new ClawActionsSubsystem(hardwareMap);
|
||||||
|
this.arm = new ArmActionsSubsystem(hardwareMap);
|
||||||
|
this.wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
|
this.lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
|
this.GP1 = gp1;
|
||||||
|
this.GP2 = gp2;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.currentGP1 = new Gamepad();
|
||||||
|
this.currentGP2 = new Gamepad();
|
||||||
|
this.previousGP1 = new Gamepad();
|
||||||
|
this.previousGP2 = new Gamepad();
|
||||||
|
this.fieldStates = new FieldStates();
|
||||||
|
this.follower = new Follower(hardwareMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.motors.init();
|
||||||
|
this.claw.init();
|
||||||
|
this.arm.init();
|
||||||
|
this.wrist.init();
|
||||||
|
this.lift.init();
|
||||||
|
this.fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
follower.setMaxPower(MAX_POWER);
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
this.previousGP1.copy(currentGP1);
|
||||||
|
this.currentGP1.copy(this.GP1);
|
||||||
|
this.previousGP2.copy(currentGP2);
|
||||||
|
this.currentGP2.copy(this.GP2);
|
||||||
|
|
||||||
|
this.toHighBucketScore();
|
||||||
|
this.toLowBucketScore();
|
||||||
|
this.toArmParkPosition();
|
||||||
|
this.toArmParkThenSwitchBetweenSubmarineAndFloorPosition();
|
||||||
|
this.clawControl();
|
||||||
|
|
||||||
|
follower.setTeleOpMovementVectors(-this.GP1.left_stick_y, -this.GP1.left_stick_x, -this.GP1.right_stick_x);
|
||||||
|
follower.update();
|
||||||
|
|
||||||
|
this.telemetry.addData("Field State", this.fieldStates.getFieldLocation());
|
||||||
|
this.telemetry.addData("Claw State", this.claw.getState());
|
||||||
|
this.telemetry.addData("Claw Position", this.claw.getPosition());
|
||||||
|
this.telemetry.addData("Wrist State", this.wrist.getState());
|
||||||
|
this.telemetry.addData("Arm State", this.arm.getState());
|
||||||
|
this.telemetry.addData("Lift State", this.lift.getState());
|
||||||
|
this.telemetry.addData("Lift Position", this.lift.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controller: 1
|
||||||
|
Button: A
|
||||||
|
Action: On button press, Arm hovers the floor with wrist parallel to arm
|
||||||
|
*/
|
||||||
|
public void toHighBucketScore() {
|
||||||
|
if (this.currentGP2.triangle && !this.previousGP2.triangle) {
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
Actions.runBlocking(new SequentialAction(
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toHighBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.claw.openClaw(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toFloorPosition()
|
||||||
|
));
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toLowBucketScore() {
|
||||||
|
if (this.currentGP2.circle && !this.previousGP2.circle) {
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
Actions.runBlocking(new SequentialAction(
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toLowBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.claw.openClaw(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toFloorPosition()
|
||||||
|
));
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clawControl() {
|
||||||
|
if (this.currentGP2.right_bumper && !this.previousGP2.right_bumper) {
|
||||||
|
this.claw.switchState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toArmParkPosition() {
|
||||||
|
if (this.currentGP2.square && !this.previousGP2.square) {
|
||||||
|
Actions.runBlocking(this.arm.toParkPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toArmParkThenSwitchBetweenSubmarineAndFloorPosition() {
|
||||||
|
if (this.currentGP2.cross && !previousGP2.cross) {
|
||||||
|
if (this.arm.getState() == ArmActionsSubsystem.ArmState.PARK) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toSubmarinePosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (this.arm.getState() == ArmActionsSubsystem.ArmState.SUBMARINE) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toFloorPosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (this.arm.getState() == ArmActionsSubsystem.ArmState.FLOOR) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toSubmarinePosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
//package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
//
|
||||||
|
//import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
//import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
//
|
||||||
|
//import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
//import org.firstinspires.ftc.teamcode.states.FieldStates;
|
||||||
|
//import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
|
//import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
|
//import org.firstinspires.ftc.teamcode.subsystem.LiftSubsystem;
|
||||||
|
//import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
|
//import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
|
//import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
|
//import org.firstinspires.ftc.teamcode.util.action.SequentialAction;
|
||||||
|
//import org.firstinspires.ftc.teamcode.util.action.SleepAction;
|
||||||
|
//
|
||||||
|
//public class DevTeleopRunMode {
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Subsystems
|
||||||
|
// */
|
||||||
|
// private MotorsSubsystem motors;
|
||||||
|
// public ClawSubsystem claw;
|
||||||
|
// public ArmSubsystem arm;
|
||||||
|
// public WristSubsystem wrist;
|
||||||
|
// public LiftSubsystem lift;
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controllers
|
||||||
|
// */
|
||||||
|
// public Gamepad GP1;
|
||||||
|
// public Gamepad GP2;
|
||||||
|
// public Gamepad currentGP1;
|
||||||
|
// public Gamepad previousGP1;
|
||||||
|
// public Gamepad currentGP2;
|
||||||
|
// public Gamepad previousGP2;
|
||||||
|
// private Telemetry telemetry;
|
||||||
|
// public FieldStates fieldStates;
|
||||||
|
//
|
||||||
|
// public DevTeleopRunMode(HardwareMap hardwareMap, Telemetry telemetry, Gamepad gp1, Gamepad gp2) {
|
||||||
|
// this.motors = new MotorsSubsystem(hardwareMap, telemetry, .55);
|
||||||
|
// this.claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
// this.arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
|
// this.wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
|
// this.lift = new LiftSubsystem(hardwareMap, telemetry);
|
||||||
|
// this.GP1 = gp1;
|
||||||
|
// this.GP2 = gp2;
|
||||||
|
// this.telemetry = telemetry;
|
||||||
|
// this.currentGP1 = new Gamepad();
|
||||||
|
// this.currentGP2 = new Gamepad();
|
||||||
|
// this.previousGP1 = new Gamepad();
|
||||||
|
// this.previousGP2 = new Gamepad();
|
||||||
|
// this.fieldStates = new FieldStates();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void init() {
|
||||||
|
// this.motors.init();
|
||||||
|
// this.claw.init();
|
||||||
|
// this.arm.init();
|
||||||
|
// this.wrist.init();
|
||||||
|
// this.lift.init();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void update() {
|
||||||
|
// this.previousGP1.copy(currentGP1);
|
||||||
|
// this.currentGP1.copy(this.GP1);
|
||||||
|
// this.previousGP2.copy(currentGP2);
|
||||||
|
// this.currentGP2.copy(this.GP2);
|
||||||
|
// this.toTravelfromField();
|
||||||
|
// this.thePickup();
|
||||||
|
// this.toFieldFromBucketScore();
|
||||||
|
// this.toLowBucketScore();
|
||||||
|
// this.toHighBucketScore();
|
||||||
|
// this.toHold();
|
||||||
|
// this.motors.calculateTrajectory(this.GP1);
|
||||||
|
// this.telemetry.addData("Field State", this.fieldStates.getFieldLocation());
|
||||||
|
// this.telemetry.addData("Claw State", this.claw.getState());
|
||||||
|
// this.telemetry.addData("Claw Position", this.claw.getPosition());
|
||||||
|
// this.telemetry.addData("Wrist State", this.wrist.getState());
|
||||||
|
// this.telemetry.addData("Arm State", this.arm.getState());
|
||||||
|
// this.telemetry.addData("Lift State", this.lift.getState());
|
||||||
|
// this.telemetry.addData("Lift Position", this.lift.getPosition());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 1
|
||||||
|
// Button: A
|
||||||
|
// Action: On button press, Arm hovers the floor with wrist parallel to arm
|
||||||
|
// */
|
||||||
|
// public void toTravelfromField() {
|
||||||
|
// if (this.currentGP1.dpad_down && !this.previousGP1.dpad_down) {
|
||||||
|
// if (fieldStates.getFieldLocation() == FieldStates.FieldLocation.TRAVELING &&
|
||||||
|
// this.lift.getPosition() < 40) {
|
||||||
|
// Actions.runBlocking(new SequentialAction(
|
||||||
|
// this.wrist.toFloorPosition,
|
||||||
|
// new SleepAction(.75),
|
||||||
|
// this.arm.toFloorPosition
|
||||||
|
// ));
|
||||||
|
// fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 1
|
||||||
|
// Button: Right Bumper
|
||||||
|
// Action: On button press, open and closes claw
|
||||||
|
// */
|
||||||
|
// public void thePickup() {
|
||||||
|
// if (this.currentGP1.right_bumper && !this.previousGP1.right_bumper) {
|
||||||
|
// this.claw.switchState();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 1
|
||||||
|
// Button: Right Bumper
|
||||||
|
// Action: On button press, open and closes claw
|
||||||
|
// */
|
||||||
|
// public void toHold() {
|
||||||
|
// if (this.currentGP1.left_bumper && !this.previousGP1.left_bumper) {
|
||||||
|
// Actions.runBlocking(new SequentialAction(
|
||||||
|
// arm.toParkPosition,
|
||||||
|
// wrist.toFloorPosition
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 2
|
||||||
|
// Button: Y
|
||||||
|
// Action: On button press, lift to low bucket height,
|
||||||
|
// arm to bucket position, wrist to bucket position
|
||||||
|
// */
|
||||||
|
// public void toLowBucketScore() {
|
||||||
|
// if (this.currentGP1.a && !this.previousGP1.a) {
|
||||||
|
// fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
// Actions.runBlocking(new SequentialAction(
|
||||||
|
// lift.toLowBucket,
|
||||||
|
// arm.toBucketPosition,
|
||||||
|
// wrist.toBucketPosition
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 2
|
||||||
|
// Button: A
|
||||||
|
// Action: On button press, lift to low bucket height,
|
||||||
|
// arm to bucket position, wrist to bucket position
|
||||||
|
// */
|
||||||
|
// public void toHighBucketScore() {
|
||||||
|
// if (this.currentGP1.b && !this.previousGP1.b) {
|
||||||
|
// fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
// Actions.runBlocking(new SequentialAction(
|
||||||
|
// lift.toHighBucket,
|
||||||
|
// arm.toBucketPosition,
|
||||||
|
// wrist.toBucketPosition
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*
|
||||||
|
// Controller: 2
|
||||||
|
// Button: Direction Pad DOWN
|
||||||
|
// Action: On directional press, lift to floor height,
|
||||||
|
// arm to bucket position, wrist to floor position
|
||||||
|
// */
|
||||||
|
// public void toFieldFromBucketScore() {
|
||||||
|
// if (this.currentGP1.dpad_right && !this.previousGP1.dpad_right) {
|
||||||
|
// if (fieldStates.getFieldLocation() == FieldStates.FieldLocation.BUCKET) {
|
||||||
|
// Actions.runBlocking(new SequentialAction(
|
||||||
|
// lift.toFloor,
|
||||||
|
// arm.toBucketPosition,
|
||||||
|
// wrist.toFloorPosition
|
||||||
|
// ));
|
||||||
|
//// fieldStates.setFieldLocation(FieldStates.FieldLocation.FIELD);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
@ -0,0 +1,185 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
|
||||||
|
import com.acmerobotics.roadrunner.SequentialAction;
|
||||||
|
import com.acmerobotics.roadrunner.SleepAction;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.states.FieldStates;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ArmActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ClawActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.LiftActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristActionsSubsystem;
|
||||||
|
|
||||||
|
public class DevTeleopRunModeCompetition {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Subsystems
|
||||||
|
*/
|
||||||
|
private MotorsSubsystem motors;
|
||||||
|
public ClawActionsSubsystem claw;
|
||||||
|
public ArmActionsSubsystem arm;
|
||||||
|
public WristActionsSubsystem wrist;
|
||||||
|
public LiftActionsSubsystem lift;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controllers
|
||||||
|
*/
|
||||||
|
public Gamepad GP1;
|
||||||
|
public Gamepad GP2;
|
||||||
|
public Gamepad currentGP1;
|
||||||
|
public Gamepad previousGP1;
|
||||||
|
public Gamepad currentGP2;
|
||||||
|
public Gamepad previousGP2;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
public FieldStates fieldStates;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
public DevTeleopRunModeCompetition(HardwareMap hardwareMap, Telemetry telemetry, Gamepad gp1, Gamepad gp2) {
|
||||||
|
this.motors = new MotorsSubsystem(hardwareMap, telemetry, .55);
|
||||||
|
this.claw = new ClawActionsSubsystem(hardwareMap);
|
||||||
|
this.arm = new ArmActionsSubsystem(hardwareMap);
|
||||||
|
this.wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
|
this.lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
|
this.GP1 = gp1;
|
||||||
|
this.GP2 = gp2;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.currentGP1 = new Gamepad();
|
||||||
|
this.currentGP2 = new Gamepad();
|
||||||
|
this.previousGP1 = new Gamepad();
|
||||||
|
this.previousGP2 = new Gamepad();
|
||||||
|
this.fieldStates = new FieldStates();
|
||||||
|
this.follower = new Follower(hardwareMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.motors.init();
|
||||||
|
this.claw.init();
|
||||||
|
this.arm.init();
|
||||||
|
this.wrist.init();
|
||||||
|
this.lift.init();
|
||||||
|
this.fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
follower.setMaxPower(.75);
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
this.previousGP1.copy(currentGP1);
|
||||||
|
this.currentGP1.copy(this.GP1);
|
||||||
|
this.previousGP2.copy(currentGP2);
|
||||||
|
this.currentGP2.copy(this.GP2);
|
||||||
|
|
||||||
|
this.toHighBucketScore();
|
||||||
|
this.toLowBucketScore();
|
||||||
|
this.toArmParkPosition();
|
||||||
|
this.toArmParkThenSwitchBetweenSubmarineAndFloorPosition();
|
||||||
|
this.clawControl();
|
||||||
|
|
||||||
|
// this.motors.calculateTrajectory(this.GP1);
|
||||||
|
follower.setTeleOpMovementVectors(-this.GP1.left_stick_y, -this.GP1.left_stick_x, -this.GP1.right_stick_x);
|
||||||
|
follower.update();
|
||||||
|
this.telemetry.addData("Field State", this.fieldStates.getFieldLocation());
|
||||||
|
this.telemetry.addData("Claw State", this.claw.getState());
|
||||||
|
this.telemetry.addData("Claw Position", this.claw.getPosition());
|
||||||
|
this.telemetry.addData("Wrist State", this.wrist.getState());
|
||||||
|
this.telemetry.addData("Arm State", this.arm.getState());
|
||||||
|
this.telemetry.addData("Lift State", this.lift.getState());
|
||||||
|
this.telemetry.addData("Lift Position", this.lift.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controller: 1
|
||||||
|
Button: A
|
||||||
|
Action: On button press, Arm hovers the floor with wrist parallel to arm
|
||||||
|
*/
|
||||||
|
public void toHighBucketScore() {
|
||||||
|
if (this.currentGP1.triangle && !this.previousGP1.triangle) {
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
Actions.runBlocking(new SequentialAction(
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toHighBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.claw.openClaw(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toFloorPosition()
|
||||||
|
));
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toLowBucketScore() {
|
||||||
|
if (this.currentGP1.circle && !this.previousGP1.circle) {
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
Actions.runBlocking(new SequentialAction(
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toLowBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toBucketPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.claw.openClaw(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.wrist.toFloorPosition(),
|
||||||
|
new SleepAction(.5),
|
||||||
|
this.arm.toParkPosition(),
|
||||||
|
this.lift.toFloorPosition()
|
||||||
|
));
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clawControl() {
|
||||||
|
if (this.currentGP1.right_bumper && !this.previousGP1.right_bumper) {
|
||||||
|
this.claw.switchState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toArmParkPosition() {
|
||||||
|
if (this.currentGP1.square && !this.previousGP1.square) {
|
||||||
|
Actions.runBlocking(this.arm.toParkPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toArmParkThenSwitchBetweenSubmarineAndFloorPosition() {
|
||||||
|
if (this.currentGP1.cross && !previousGP1.cross) {
|
||||||
|
if (this.arm.getState() == ArmActionsSubsystem.ArmState.PARK) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toSubmarinePosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (this.arm.getState() == ArmActionsSubsystem.ArmState.SUBMARINE) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toFloorPosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (this.arm.getState() == ArmActionsSubsystem.ArmState.FLOOR) {
|
||||||
|
Actions.runBlocking(
|
||||||
|
new SequentialAction(
|
||||||
|
this.arm.toSubmarinePosition(),
|
||||||
|
this.wrist.toFloorPosition()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,89 +1,89 @@
|
|||||||
package org.firstinspires.ftc.teamcode.runmodes;
|
//package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
//
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR_DIRECTION;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR_DIRECTION;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR_DIRECTION;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR_DIRECTION;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR_DIRECTION;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR_DIRECTION;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR_DIRECTION;
|
//import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR_DIRECTION;
|
||||||
|
//
|
||||||
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.Gamepad;
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
//import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
//
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
//import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
//import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
//import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
//import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
//
|
||||||
public class Teleop {
|
//public class Teleop {
|
||||||
|
//
|
||||||
private ClawSubsystem claw;
|
// private ClawSubsystem claw;
|
||||||
private Follower follower;
|
// private Follower follower;
|
||||||
private DcMotorEx leftFront;
|
// private DcMotorEx leftFront;
|
||||||
private DcMotorEx leftRear;
|
// private DcMotorEx leftRear;
|
||||||
private DcMotorEx rightFront;
|
// private DcMotorEx rightFront;
|
||||||
private DcMotorEx rightRear;
|
// private DcMotorEx rightRear;
|
||||||
private Telemetry telemetry;
|
// private Telemetry telemetry;
|
||||||
|
//
|
||||||
private Gamepad gamepad1;
|
// private Gamepad gamepad1;
|
||||||
private Gamepad currentGamepad1;
|
// private Gamepad currentGamepad1;
|
||||||
private Gamepad previousGamepad1;
|
// private Gamepad previousGamepad1;
|
||||||
|
//
|
||||||
public Teleop(HardwareMap hardwareMap, Telemetry telemetry, Follower follower, Gamepad gamepad1) {
|
// public Teleop(HardwareMap hardwareMap, Telemetry telemetry, Follower follower, Gamepad gamepad1) {
|
||||||
|
//
|
||||||
claw = new ClawSubsystem(hardwareMap, ClawSubsystem.ClawState.CLOSED);
|
// claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
initMotors(hardwareMap);
|
// initMotors(hardwareMap);
|
||||||
|
//
|
||||||
this.follower = follower;
|
// this.follower = follower;
|
||||||
|
//
|
||||||
this.telemetry = telemetry;
|
// this.telemetry = telemetry;
|
||||||
this.gamepad1 = gamepad1;
|
// this.gamepad1 = gamepad1;
|
||||||
|
//
|
||||||
this.currentGamepad1 = new Gamepad();
|
// this.currentGamepad1 = new Gamepad();
|
||||||
this.previousGamepad1 = new Gamepad();
|
// this.previousGamepad1 = new Gamepad();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void start() {
|
// public void start() {
|
||||||
claw.start();
|
// claw.start();
|
||||||
follower.startTeleopDrive();
|
// follower.startTeleopDrive();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void update() {
|
// public void update() {
|
||||||
previousGamepad1.copy(currentGamepad1);
|
// previousGamepad1.copy(currentGamepad1);
|
||||||
currentGamepad1.copy(gamepad1);
|
// currentGamepad1.copy(gamepad1);
|
||||||
|
//
|
||||||
if (currentGamepad1.a && !previousGamepad1.a)
|
// if (currentGamepad1.a && !previousGamepad1.a)
|
||||||
claw.switchState();
|
// claw.switchState();
|
||||||
|
//
|
||||||
follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
// follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
||||||
follower.update();
|
// follower.update();
|
||||||
|
//
|
||||||
telemetry.addData("X", follower.getPose().getX());
|
// telemetry.addData("X", follower.getPose().getX());
|
||||||
telemetry.addData("Y", follower.getPose().getY());
|
// telemetry.addData("Y", follower.getPose().getY());
|
||||||
telemetry.addData("Heading", Math.toDegrees(follower.getPose().getHeading()));
|
// telemetry.addData("Heading", Math.toDegrees(follower.getPose().getHeading()));
|
||||||
telemetry.addData("Claw State", claw.getState());
|
// telemetry.addData("Claw State", claw.getState());
|
||||||
telemetry.update();
|
// telemetry.update();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void initMotors(HardwareMap hardwareMap) {
|
// private void initMotors(HardwareMap hardwareMap) {
|
||||||
rightFront = hardwareMap.get(DcMotorEx.class, FRONT_RIGHT_MOTOR);
|
// rightFront = hardwareMap.get(DcMotorEx.class, FRONT_RIGHT_MOTOR);
|
||||||
rightRear = hardwareMap.get(DcMotorEx.class, BACK_RIGHT_MOTOR);
|
// rightRear = hardwareMap.get(DcMotorEx.class, BACK_RIGHT_MOTOR);
|
||||||
leftFront = hardwareMap.get(DcMotorEx.class, FRONT_LEFT_MOTOR);
|
// leftFront = hardwareMap.get(DcMotorEx.class, FRONT_LEFT_MOTOR);
|
||||||
leftRear = hardwareMap.get(DcMotorEx.class, BACK_LEFT_MOTOR);
|
// leftRear = hardwareMap.get(DcMotorEx.class, BACK_LEFT_MOTOR);
|
||||||
|
//
|
||||||
rightFront.setDirection(FRONT_RIGHT_MOTOR_DIRECTION);
|
// rightFront.setDirection(FRONT_RIGHT_MOTOR_DIRECTION);
|
||||||
rightRear.setDirection(BACK_RIGHT_MOTOR_DIRECTION);
|
// rightRear.setDirection(BACK_RIGHT_MOTOR_DIRECTION);
|
||||||
leftFront.setDirection(FRONT_LEFT_MOTOR_DIRECTION);
|
// leftFront.setDirection(FRONT_LEFT_MOTOR_DIRECTION);
|
||||||
leftRear.setDirection(BACK_LEFT_MOTOR_DIRECTION);
|
// leftRear.setDirection(BACK_LEFT_MOTOR_DIRECTION);
|
||||||
|
//
|
||||||
leftFront.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
// leftFront.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
leftRear.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
// leftRear.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
rightRear.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
// rightRear.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
rightFront.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
// rightFront.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.states;
|
||||||
|
|
||||||
|
public class FieldStates {
|
||||||
|
|
||||||
|
public enum FieldLocation {
|
||||||
|
BUCKET, SUBMARINE, FLOATING, TRAVELING
|
||||||
|
}
|
||||||
|
|
||||||
|
private FieldLocation fieldLocation;
|
||||||
|
|
||||||
|
public FieldLocation getFieldLocation() {
|
||||||
|
return fieldLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldLocation(FieldLocation fieldLocation) {
|
||||||
|
this.fieldLocation = fieldLocation;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.ARM_NAME;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armBucket;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armFloor;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armPark;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armSubmarine;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
||||||
|
|
||||||
|
public class ArmActionsSubsystem {
|
||||||
|
|
||||||
|
public enum ArmState {
|
||||||
|
PARK, FLOOR, BUCKET, SUBMARINE
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServoImplEx arm;
|
||||||
|
private ArmState state;
|
||||||
|
|
||||||
|
public ArmActionsSubsystem(HardwareMap hardwareMap) {
|
||||||
|
this.arm = hardwareMap.get(ServoImplEx.class, ARM_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MoveToPosition implements Action {
|
||||||
|
private double positionValue;
|
||||||
|
private ArmState positionState;
|
||||||
|
|
||||||
|
public MoveToPosition(double positionValue, ArmState positionState) {
|
||||||
|
this.positionValue = positionValue;
|
||||||
|
this.positionState = positionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
arm.setPosition(positionValue);
|
||||||
|
setState(positionState);
|
||||||
|
telemetryPacket.put("Arm State", positionState);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toParkPosition() {
|
||||||
|
return new MoveToPosition(armPark, ArmState.PARK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toSubmarinePosition() {
|
||||||
|
return new MoveToPosition(armSubmarine, ArmState.SUBMARINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toFloorPosition() {
|
||||||
|
return new MoveToPosition(armFloor, ArmState.FLOOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toBucketPosition() {
|
||||||
|
return new MoveToPosition(armBucket, ArmState.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ArmState armState) {
|
||||||
|
this.state = armState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArmState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.arm.resetDeviceConfigurationForOpMode();
|
||||||
|
Actions.runBlocking(this.toParkPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(this.toParkPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return this.arm.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(double position) {
|
||||||
|
this.arm.setPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,68 +1,65 @@
|
|||||||
package org.firstinspires.ftc.teamcode.subsystem;
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armEngage;
|
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armPark;
|
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armBucket;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armBucket;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armFloor;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armPark;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
public class ArmSubsystem {
|
public class ArmSubsystem {
|
||||||
|
|
||||||
public enum ArmState {
|
public enum ArmState {
|
||||||
PARK, ENGAGE, BUCKET
|
PARK, FLOOR, BUCKET
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServoImplEx arm;
|
private ServoImplEx arm;
|
||||||
public ArmState state;
|
private ArmState state;
|
||||||
public RunAction engageArm, parkArm, bucketArm;
|
public RunAction toFloorPosition, toParkPosition, toBucketPosition;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
|
||||||
public ArmSubsystem(HardwareMap hardwareMap, ArmState armState) {
|
public ArmSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
arm = hardwareMap.get(ServoImplEx.class, "arm-servo");
|
this.arm = hardwareMap.get(ServoImplEx.class, "arm-servo");
|
||||||
arm.resetDeviceConfigurationForOpMode();
|
this.toParkPosition = new RunAction(this::toParkPosition);
|
||||||
|
this.toFloorPosition = new RunAction(this::toFloorPosition);
|
||||||
this.state = armState;
|
this.toBucketPosition = new RunAction(this::toBucketPosition);
|
||||||
|
this.telemetry = telemetry;
|
||||||
parkArm = new RunAction(this::parkArm);
|
|
||||||
engageArm = new RunAction(this::engageArm);
|
|
||||||
bucketArm = new RunAction(this::bucketArm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(ArmState armState) {
|
public void setState(ArmState armState) {
|
||||||
if (armState == ArmState.ENGAGE) {
|
if (armState == ArmState.FLOOR) {
|
||||||
arm.setPosition(armEngage);
|
this.arm.setPosition(armFloor);
|
||||||
this.state = ArmState.ENGAGE;
|
|
||||||
} else if (armState == ArmState.PARK) {
|
} else if (armState == ArmState.PARK) {
|
||||||
arm.setPosition(armPark);
|
this.arm.setPosition(armPark);
|
||||||
this.state = ArmState.PARK;
|
|
||||||
} else if (armState == ArmState.BUCKET) {
|
} else if (armState == ArmState.BUCKET) {
|
||||||
arm.setPosition(armBucket);
|
this.arm.setPosition(armBucket);
|
||||||
this.state = ArmState.BUCKET;
|
|
||||||
}
|
}
|
||||||
|
this.state = armState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void engageArm() {
|
public void toFloorPosition() {
|
||||||
setState(ArmState.ENGAGE);
|
this.setState(ArmState.FLOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parkArm() {
|
public void toParkPosition() {
|
||||||
setState(ArmState.PARK);
|
this.setState(ArmState.PARK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bucketArm() {
|
public void toBucketPosition() {
|
||||||
setState(ArmState.BUCKET);
|
this.setState(ArmState.BUCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchState() {
|
public void switchState() {
|
||||||
if (state == ArmState.ENGAGE) {
|
if (this.state == ArmState.FLOOR) {
|
||||||
setState(ArmState.PARK);
|
this.setState(ArmState.PARK);
|
||||||
} else if (state == ArmState.PARK) {
|
} else if (this.state == ArmState.PARK) {
|
||||||
setState(ArmState.BUCKET);
|
this.setState(ArmState.BUCKET);
|
||||||
} else if (state == ArmState.BUCKET) {
|
} else if (this.state == ArmState.BUCKET) {
|
||||||
setState(ArmState.ENGAGE);
|
this.setState(ArmState.FLOOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +68,12 @@ public class ArmSubsystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
Actions.runBlocking(parkArm);
|
this.arm.resetDeviceConfigurationForOpMode();
|
||||||
|
Actions.runBlocking(this.toParkPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Actions.runBlocking(parkArm);
|
Actions.runBlocking(this.toParkPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPosition() {
|
public double getPosition() {
|
||||||
|
@ -0,0 +1,82 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.CLAW_NAME;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawClose;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawOpen;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
import com.qualcomm.robotcore.hardware.Servo;
|
||||||
|
|
||||||
|
public class ClawActionsSubsystem {
|
||||||
|
|
||||||
|
public enum ClawState {
|
||||||
|
CLOSED, OPEN
|
||||||
|
}
|
||||||
|
|
||||||
|
private Servo claw;
|
||||||
|
private ClawState state;
|
||||||
|
|
||||||
|
public ClawActionsSubsystem(HardwareMap hardwareMap) {
|
||||||
|
this.claw = hardwareMap.get(Servo.class, CLAW_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MoveToPosition implements Action {
|
||||||
|
private double positionValue;
|
||||||
|
private ClawState positionState;
|
||||||
|
|
||||||
|
public MoveToPosition(double positionValue, ClawState positionState) {
|
||||||
|
this.positionValue = positionValue;
|
||||||
|
this.positionState = positionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
setState(positionState);
|
||||||
|
claw.setPosition(positionValue);
|
||||||
|
telemetryPacket.put("Claw State", positionState);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action openClaw() {
|
||||||
|
return new MoveToPosition(clawOpen, ClawState.OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action closeClaw() {
|
||||||
|
return new MoveToPosition(clawClose, ClawState.CLOSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ClawState clawState) {
|
||||||
|
this.state = clawState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClawState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (state == ClawState.CLOSED) {
|
||||||
|
Actions.runBlocking(openClaw());
|
||||||
|
} else if (state == ClawState.OPEN) {
|
||||||
|
Actions.runBlocking(closeClaw());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
Actions.runBlocking(closeClaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(closeClaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return this.claw.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package org.firstinspires.ftc.teamcode.subsystem;
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawClose;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawOpen;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
import com.qualcomm.robotcore.hardware.Servo;
|
import com.qualcomm.robotcore.hardware.Servo;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawOpen;
|
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.clawClose;
|
|
||||||
|
|
||||||
public class ClawSubsystem {
|
public class ClawSubsystem {
|
||||||
|
|
||||||
@ -17,23 +19,22 @@ public class ClawSubsystem {
|
|||||||
private Servo claw;
|
private Servo claw;
|
||||||
private ClawState state;
|
private ClawState state;
|
||||||
public RunAction openClaw, closeClaw;
|
public RunAction openClaw, closeClaw;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
public ClawSubsystem(HardwareMap hardwareMap, ClawState clawState) {
|
public ClawSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
claw = hardwareMap.get(Servo.class, "claw-servo");
|
this.claw = hardwareMap.get(Servo.class, "claw-servo");
|
||||||
this.state = clawState;
|
this.openClaw = new RunAction(this::openClaw);
|
||||||
|
this.closeClaw = new RunAction(this::closeClaw);
|
||||||
openClaw = new RunAction(this::openClaw);
|
this.telemetry = telemetry;
|
||||||
closeClaw = new RunAction(this::closeClaw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(ClawState clawState) {
|
public void setState(ClawState clawState) {
|
||||||
if (clawState == ClawState.CLOSED) {
|
if (clawState == ClawState.CLOSED) {
|
||||||
claw.setPosition(clawClose);
|
claw.setPosition(clawClose);
|
||||||
this.state = ClawState.CLOSED;
|
|
||||||
} else if (clawState == ClawState.OPEN) {
|
} else if (clawState == ClawState.OPEN) {
|
||||||
claw.setPosition(clawOpen);
|
claw.setPosition(clawOpen);
|
||||||
this.state = ClawState.OPEN;
|
|
||||||
}
|
}
|
||||||
|
this.state = clawState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClawState getState() {
|
public ClawState getState() {
|
||||||
@ -64,4 +65,8 @@ public class ClawSubsystem {
|
|||||||
Actions.runBlocking(closeClaw);
|
Actions.runBlocking(closeClaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return this.claw.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.LIFT_NAME;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftPower;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToFloorPos;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToHighBucketPos;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToLowBucketPos;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
public class LiftActionsSubsystem {
|
||||||
|
|
||||||
|
public DcMotor lift;
|
||||||
|
|
||||||
|
public enum LiftState {
|
||||||
|
FLOOR, LOW_BUCKET, HIGH_BUCKET, FLOAT, SUBMARINE
|
||||||
|
}
|
||||||
|
|
||||||
|
private LiftState liftState;
|
||||||
|
|
||||||
|
public LiftActionsSubsystem(HardwareMap hardwareMap) {
|
||||||
|
lift = hardwareMap.get(DcMotor.class, LIFT_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MoveToPosition implements Action {
|
||||||
|
private int positionValue;
|
||||||
|
private LiftState positionState;
|
||||||
|
|
||||||
|
public MoveToPosition(int positionValue, LiftState positionState) {
|
||||||
|
this.positionValue = positionValue;
|
||||||
|
this.positionState = positionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
setState(positionState);
|
||||||
|
lift.setTargetPosition(positionValue);
|
||||||
|
lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||||
|
telemetryPacket.put("Lift State", positionState);
|
||||||
|
telemetryPacket.put("Lift Position", lift.getCurrentPosition());
|
||||||
|
boolean result = lift.getTargetPosition() - 15 < lift.getCurrentPosition() &&
|
||||||
|
lift.getCurrentPosition() < lift.getTargetPosition() + 15;
|
||||||
|
return !result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toFloorPosition() {
|
||||||
|
return new MoveToPosition(liftToFloorPos, LiftState.FLOOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toLowBucketPosition() {
|
||||||
|
return new MoveToPosition(liftToLowBucketPos, LiftState.LOW_BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toHighBucketPosition() {
|
||||||
|
return new MoveToPosition(liftToHighBucketPos, LiftState.HIGH_BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (this.liftState == LiftState.FLOOR) {
|
||||||
|
Actions.runBlocking(toLowBucketPosition());
|
||||||
|
} else if (this.liftState == LiftState.LOW_BUCKET) {
|
||||||
|
Actions.runBlocking(toHighBucketPosition());
|
||||||
|
} else if (this.liftState == LiftState.HIGH_BUCKET) {
|
||||||
|
Actions.runBlocking(toFloorPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
lift.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
lift.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||||
|
lift.setPower(liftPower);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setState(LiftState liftState) {
|
||||||
|
this.liftState = liftState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiftState getState() {
|
||||||
|
return this.liftState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return lift.getCurrentPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
lift.setTargetPosition(position);
|
||||||
|
lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(toFloorPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,34 +1,38 @@
|
|||||||
package org.firstinspires.ftc.teamcode.subsystem;
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftPower;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftPower;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToFloatPos;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToSubmarinePos;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToFloorPos;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToFloorPos;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToHighBucketPos;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToHighBucketPos;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToLowBucketPos;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToLowBucketPos;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToHoverState;
|
|
||||||
|
|
||||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
public class LiftSubsystem {
|
public class LiftSubsystem {
|
||||||
|
|
||||||
public DcMotor lift;
|
public DcMotor lift;
|
||||||
public RunAction toFloor, toLowBucket, toHighBucket;
|
public RunAction toFloor, toLowBucket, toHighBucket, toFloat;
|
||||||
|
|
||||||
public enum LiftState {
|
public enum LiftState {
|
||||||
FLOOR, LOW_BUCKET, HIGH_BUCKET, FLOAT, HOVER
|
FLOOR, LOW_BUCKET, HIGH_BUCKET, FLOAT
|
||||||
}
|
}
|
||||||
|
|
||||||
private LiftState liftState;
|
private LiftState liftState;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
|
||||||
public LiftSubsystem(HardwareMap hardwareMap) {
|
public LiftSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
lift = hardwareMap.get(DcMotor.class, "lift-motor");
|
lift = hardwareMap.get(DcMotor.class, "lift-motor");
|
||||||
toFloor = new RunAction(this::toFloor);
|
toFloor = new RunAction(this::toFloor);
|
||||||
toLowBucket = new RunAction(this::toLowBucket);
|
toLowBucket = new RunAction(this::toLowBucket);
|
||||||
toHighBucket = new RunAction(this::toHighBucket);
|
toHighBucket = new RunAction(this::toHighBucket);
|
||||||
|
toFloat = new RunAction(this::toFloat);
|
||||||
|
this.telemetry = telemetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(int b) {
|
public void setTarget(int b) {
|
||||||
@ -38,7 +42,7 @@ public class LiftSubsystem {
|
|||||||
|
|
||||||
public void switchState() {
|
public void switchState() {
|
||||||
if (this.liftState == LiftState.FLOOR) {
|
if (this.liftState == LiftState.FLOOR) {
|
||||||
this.toFloor();
|
this.toFloat();
|
||||||
} else if (this.liftState == LiftState.FLOAT) {
|
} else if (this.liftState == LiftState.FLOAT) {
|
||||||
this.toLowBucket();
|
this.toLowBucket();
|
||||||
} else if (this.liftState == LiftState.LOW_BUCKET) {
|
} else if (this.liftState == LiftState.LOW_BUCKET) {
|
||||||
@ -48,29 +52,24 @@ public class LiftSubsystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toHover() {
|
|
||||||
this.setTarget(liftToHoverState);
|
|
||||||
this.setState(LiftState.HOVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toFloor() {
|
public void toFloor() {
|
||||||
this.setTarget(liftToFloorPos);
|
|
||||||
this.setState(LiftState.FLOOR);
|
this.setState(LiftState.FLOOR);
|
||||||
|
this.setTarget(liftToFloorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toFloat() {
|
public void toFloat() {
|
||||||
this.setTarget(liftToFloatPos);
|
|
||||||
this.setState(LiftState.FLOAT);
|
this.setState(LiftState.FLOAT);
|
||||||
|
this.setTarget(liftToSubmarinePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toLowBucket() {
|
public void toLowBucket() {
|
||||||
this.setTarget(liftToLowBucketPos);
|
|
||||||
this.setState(LiftState.LOW_BUCKET);
|
this.setState(LiftState.LOW_BUCKET);
|
||||||
|
this.setTarget(liftToLowBucketPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toHighBucket() {
|
public void toHighBucket() {
|
||||||
this.setTarget(liftToHighBucketPos);
|
|
||||||
this.setState(LiftState.HIGH_BUCKET);
|
this.setState(LiftState.HIGH_BUCKET);
|
||||||
|
this.setTarget(liftToHighBucketPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -83,12 +82,14 @@ public class LiftSubsystem {
|
|||||||
this.liftState = liftState;
|
this.liftState = liftState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiftState getState() { return this.liftState; }
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return lift.getCurrentPosition();
|
return lift.getCurrentPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
this.toFloor();
|
Actions.runBlocking(toFloor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class MotorsSubsystem {
|
|||||||
public DcMotor backRightMotor;
|
public DcMotor backRightMotor;
|
||||||
|
|
||||||
public enum TravelState {
|
public enum TravelState {
|
||||||
PARKED, BUCKET, SUBMARINE
|
STOPPED, MOVING
|
||||||
}
|
}
|
||||||
|
|
||||||
public TravelState travelState;
|
public TravelState travelState;
|
||||||
@ -60,6 +60,8 @@ public class MotorsSubsystem {
|
|||||||
backLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
backLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
frontRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
frontRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
backRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
backRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
|
||||||
|
this.setState(TravelState.STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFrontLeftMotorPower(double power) {
|
public void setFrontLeftMotorPower(double power) {
|
||||||
@ -116,7 +118,7 @@ public class MotorsSubsystem {
|
|||||||
// Show the elapsed game time and wheel power.
|
// Show the elapsed game time and wheel power.
|
||||||
this.telemetry.addData("Front left/Right", "%4.2f, %4.2f", leftFrontPower, rightFrontPower);
|
this.telemetry.addData("Front left/Right", "%4.2f, %4.2f", leftFrontPower, rightFrontPower);
|
||||||
this.telemetry.addData("Back left/Right", "%4.2f, %4.2f", leftBackPower, rightBackPower);
|
this.telemetry.addData("Back left/Right", "%4.2f, %4.2f", leftBackPower, rightBackPower);
|
||||||
this.telemetry.update();
|
this.telemetry.addData("Current State", this.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(TravelState travelState) {
|
public void setState(TravelState travelState) {
|
||||||
@ -127,4 +129,12 @@ public class MotorsSubsystem {
|
|||||||
return this.travelState;
|
return this.travelState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPower(DcMotor motor, double power) {
|
||||||
|
motor.setPower(power);
|
||||||
|
if (power < 0.05) {
|
||||||
|
this.setState(TravelState.MOVING);
|
||||||
|
} else {
|
||||||
|
this.setState(TravelState.STOPPED);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristBucket;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristFloor;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
||||||
|
|
||||||
|
public class WristActionsSubsystem {
|
||||||
|
|
||||||
|
public enum WristState {
|
||||||
|
FLOOR, BUCKET
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServoImplEx wrist;
|
||||||
|
public WristState state;
|
||||||
|
|
||||||
|
public WristActionsSubsystem(HardwareMap hardwareMap) {
|
||||||
|
this.wrist = hardwareMap.get(ServoImplEx.class, "wrist-servo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MoveToPosition implements Action {
|
||||||
|
private double positionValue;
|
||||||
|
private WristState positionState;
|
||||||
|
|
||||||
|
public MoveToPosition(double positionValue, WristState positionState) {
|
||||||
|
this.positionValue = positionValue;
|
||||||
|
this.positionState = positionState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
setState(positionState);
|
||||||
|
wrist.setPosition(positionValue);
|
||||||
|
telemetryPacket.put("Wrist State", positionState);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toFloorPosition() {
|
||||||
|
return new MoveToPosition(wristFloor, WristState.FLOOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action toBucketPosition() {
|
||||||
|
return new MoveToPosition(wristBucket, WristState.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(WristState wristState) {
|
||||||
|
this.state = wristState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (state == WristState.FLOOR) {
|
||||||
|
Actions.runBlocking(this.toBucketPosition());
|
||||||
|
} else if (state == WristState.BUCKET) {
|
||||||
|
Actions.runBlocking(this.toFloorPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WristState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
wrist.resetDeviceConfigurationForOpMode();
|
||||||
|
Actions.runBlocking(this.toFloorPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(this.toFloorPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(double position) {
|
||||||
|
wrist.setPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return wrist.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,13 @@
|
|||||||
package org.firstinspires.ftc.teamcode.subsystem;
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.WRIST_NAME;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristBucket;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristBucket;
|
||||||
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristFloor;
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.wristFloor;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.hardware.HardwareMap;
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
import com.qualcomm.robotcore.hardware.ServoImplEx;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
@ -17,33 +19,30 @@ public class WristSubsystem {
|
|||||||
|
|
||||||
public ServoImplEx wrist;
|
public ServoImplEx wrist;
|
||||||
public WristState state;
|
public WristState state;
|
||||||
public RunAction floorWrist, bucketWrist;
|
public RunAction toFloorPosition, toBucketPosition;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
public WristSubsystem(HardwareMap hardwareMap, WristState wristState) {
|
public WristSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
wrist = hardwareMap.get(ServoImplEx.class, "wrist-servo");
|
this.wrist = hardwareMap.get(ServoImplEx.class, WRIST_NAME);
|
||||||
wrist.resetDeviceConfigurationForOpMode();
|
this.telemetry = telemetry;
|
||||||
|
toBucketPosition = new RunAction(this::toBucketPosition);
|
||||||
this.state = wristState;
|
toFloorPosition = new RunAction(this::toFloorPosition);
|
||||||
|
|
||||||
bucketWrist = new RunAction(this::bucketWrist);
|
|
||||||
floorWrist = new RunAction(this::floorWrist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(WristState wristState) {
|
public void setState(WristState wristState) {
|
||||||
if (wristState == WristState.FLOOR) {
|
if (wristState == WristState.FLOOR) {
|
||||||
wrist.setPosition(wristFloor);
|
wrist.setPosition(wristFloor);
|
||||||
this.state = WristState.FLOOR;
|
|
||||||
} else if (wristState == WristState.BUCKET) {
|
} else if (wristState == WristState.BUCKET) {
|
||||||
wrist.setPosition(wristBucket);
|
wrist.setPosition(wristBucket);
|
||||||
this.state = WristState.BUCKET;
|
|
||||||
}
|
}
|
||||||
|
this.state = wristState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void floorWrist() {
|
public void toFloorPosition() {
|
||||||
setState(WristState.FLOOR);
|
setState(WristState.FLOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bucketWrist() {
|
public void toBucketPosition() {
|
||||||
setState(WristState.BUCKET);
|
setState(WristState.BUCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,11 +59,12 @@ public class WristSubsystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
Actions.runBlocking(floorWrist);
|
wrist.resetDeviceConfigurationForOpMode();
|
||||||
|
Actions.runBlocking(toFloorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Actions.runBlocking(floorWrist);
|
Actions.runBlocking(toFloorPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPosition() {
|
public double getPosition() {
|
||||||
|
@ -15,9 +15,7 @@ public class Actions {
|
|||||||
while (b && !Thread.currentThread().isInterrupted()) {
|
while (b && !Thread.currentThread().isInterrupted()) {
|
||||||
TelemetryPacket p = new TelemetryPacket();
|
TelemetryPacket p = new TelemetryPacket();
|
||||||
p.fieldOverlay().getOperations().addAll(c.getOperations());
|
p.fieldOverlay().getOperations().addAll(c.getOperations());
|
||||||
|
|
||||||
b = a.run(p);
|
b = a.run(p);
|
||||||
|
|
||||||
dash.sendTelemetryPacket(p);
|
dash.sendTelemetryPacket(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,31 +2,30 @@ package org.firstinspires.ftc.teamcode.util.action;
|
|||||||
|
|
||||||
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class SleepAction implements Action {
|
public class SleepAction implements Action {
|
||||||
private final double dt;
|
private double dt;
|
||||||
private boolean isFinished = false;
|
private double beginTs = -1.0;
|
||||||
|
|
||||||
public SleepAction(double dt) {
|
public SleepAction(double dt) {
|
||||||
this.dt = dt;
|
this.dt = dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double now() {
|
||||||
|
return System.nanoTime() * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(TelemetryPacket p) {
|
public boolean run(TelemetryPacket p) {
|
||||||
if (!isFinished) {
|
double t;
|
||||||
Timer timer = new Timer();
|
if (beginTs < 0) {
|
||||||
timer.schedule(new TimerTask() {
|
beginTs = now();
|
||||||
@Override
|
t = 0.0;
|
||||||
public void run() {
|
|
||||||
isFinished = true;
|
|
||||||
}
|
|
||||||
}, (long) (dt * 1000));
|
|
||||||
} else {
|
} else {
|
||||||
isFinished = false; // Reset the flag after sleep is complete
|
t = now() - beginTs;
|
||||||
return false; // Indicate that the action is finished
|
|
||||||
}
|
}
|
||||||
return true; // Indicate that the action is still running
|
boolean output = t < dt;
|
||||||
|
System.out.println(t + ":" + now() + ":" + beginTs + ":" + output);
|
||||||
|
|
||||||
|
return t < dt;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,9 @@ dependencies {
|
|||||||
implementation 'org.firstinspires.ftc:Vision:10.1.0'
|
implementation 'org.firstinspires.ftc:Vision:10.1.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
|
|
||||||
implementation 'com.acmerobotics.dashboard:dashboard:0.4.5'
|
implementation "com.acmerobotics.roadrunner:ftc:0.1.14"
|
||||||
}
|
implementation "com.acmerobotics.roadrunner:core:1.0.0"
|
||||||
|
implementation "com.acmerobotics.roadrunner:actions:1.0.0"
|
||||||
|
implementation "com.acmerobotics.dashboard:dashboard:0.4.16"
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user