Compare commits
57 Commits
branch-bla
...
80d542d6fc
Author | SHA1 | Date | |
---|---|---|---|
80d542d6fc | |||
97942e9b65 | |||
4328e5bf6d | |||
9106511f2f | |||
555078478c | |||
399a21c547 | |||
90bcfbb787 | |||
00a828cfb9 | |||
bb10d3efc1 | |||
5b3c92c82c | |||
7a42724b44 | |||
2c1f0d6c57 | |||
a55d1902d2 | |||
6fe6eab830 | |||
2a06f7e98d | |||
83da8e0de0 | |||
5c84d0d7c8 | |||
5c657ab926 | |||
a2fa3341b1 | |||
9b2a04013f | |||
19fcec1fcc | |||
edf0ec572a | |||
04b61d7aa7 | |||
0990edb038 | |||
417847a6b3 | |||
4351eb9720 | |||
0f42160c4f | |||
d979bd5bb2 | |||
b35cefe917 | |||
a606811969 | |||
39094d531e | |||
e8eff6367d | |||
1c922f025e | |||
3aed4b8676 | |||
b85f3b38df | |||
d985378ac4 | |||
78eb1cdfd2 | |||
600e63a52b | |||
8e99d1672e | |||
e8d316baee | |||
b5c6e03ef3 | |||
284263a43b | |||
eb0042a5f6 | |||
657ec8e624 | |||
c207070b1c | |||
173f934a22 | |||
28d7521ab0 | |||
a122832e76 | |||
1f7b3467c1 | |||
f7aa0c4319 | |||
308f301bd5 | |||
d383e2ca63 | |||
a3f1dfdf68 | |||
89f4c1b9a0 | |||
6f784936d2 | |||
945a77ca49 | |||
43c505e292 |
@ -0,0 +1,12 @@
|
|||||||
|
# Controller 1
|
||||||
|
|
||||||
|
## Motor Controls
|
||||||
|
|
||||||
|
- Left Joystick
|
||||||
|
- Forward & Backwards
|
||||||
|
- Right Joystick
|
||||||
|
- Strafe & Turning
|
||||||
|
|
||||||
|
## Arm Controls
|
||||||
|
|
||||||
|
-
|
@ -0,0 +1,35 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.runmodes.Auto;
|
||||||
|
|
||||||
|
|
||||||
|
@Autonomous(name = "CometBot Auto", group = "Competition")
|
||||||
|
public class CometBotAuto extends OpMode {
|
||||||
|
public Auto auto;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
auto = new Auto(hardwareMap, telemetry, new Follower(hardwareMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
auto.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
auto.update();
|
||||||
|
telemetry.addData("Arm State", auto.arm.getState());
|
||||||
|
telemetry.addData("Arm Position", auto.arm.getPosition());
|
||||||
|
telemetry.addData("Claw State", auto.claw.getState());
|
||||||
|
telemetry.addData("Wrist State", auto.wrist.getState());
|
||||||
|
telemetry.addData("Wrist Position", auto.wrist.getPosition());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.runmodes.CometBotTeleopCompetition;
|
||||||
|
import org.firstinspires.ftc.teamcode.runmodes.DevTeleopRunModeCompetition;
|
||||||
|
|
||||||
|
@TeleOp(name = "ComeBot Drive", group = "Competition")
|
||||||
|
public class CometBotDrive extends OpMode {
|
||||||
|
|
||||||
|
public CometBotTeleopCompetition runMode;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.runMode = new CometBotTeleopCompetition(hardwareMap, telemetry, gamepad1, gamepad2);
|
||||||
|
this.runMode.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
this.runMode.update();
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@TeleOp(name = "Dev Teleop Remix", group = "Debug")
|
||||||
|
@Disabled
|
||||||
|
public class DevTeleOpRemix extends OpMode {
|
||||||
|
|
||||||
|
public ClawSubsystem claw;
|
||||||
|
public ArmSubsystem arm;
|
||||||
|
public WristSubsystem wrist;
|
||||||
|
public LiftSubsystem lift;
|
||||||
|
public MotorsSubsystem motors;
|
||||||
|
|
||||||
|
public Gamepad currentGamepad1;
|
||||||
|
public Gamepad previousGamepad1;
|
||||||
|
public Gamepad currentGamepad2;
|
||||||
|
public Gamepad previousGamepad2;
|
||||||
|
|
||||||
|
public double power = .6;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
|
wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
|
lift = new LiftSubsystem(hardwareMap, telemetry);
|
||||||
|
motors = new MotorsSubsystem(hardwareMap, telemetry, power);
|
||||||
|
|
||||||
|
claw.init();
|
||||||
|
arm.init();
|
||||||
|
wrist.init();
|
||||||
|
lift.init();
|
||||||
|
motors.init();
|
||||||
|
|
||||||
|
currentGamepad1 = new Gamepad();
|
||||||
|
previousGamepad1 = new Gamepad();
|
||||||
|
currentGamepad2 = new Gamepad();
|
||||||
|
previousGamepad2 = new Gamepad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
|
if (currentGamepad1.a && !previousGamepad1.a) {
|
||||||
|
wrist.toFloorPosition();
|
||||||
|
arm.toFloorPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void thePickup(ClawSubsystem claw) {
|
||||||
|
if (currentGamepad1.x && !previousGamepad1.x) {
|
||||||
|
claw.switchState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
|
if (currentGamepad1.b && !previousGamepad1.b) {
|
||||||
|
arm.toParkPosition();
|
||||||
|
wrist.toBucketPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
||||||
|
if (currentGamepad1.y && !previousGamepad1.y) {
|
||||||
|
lift.toLowBucket();
|
||||||
|
wrist.toBucketPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
previousGamepad2.copy(currentGamepad2);
|
||||||
|
currentGamepad2.copy(gamepad2);
|
||||||
|
|
||||||
|
theDrop(arm, wrist);
|
||||||
|
thePickup(claw);
|
||||||
|
theLift(arm, wrist);
|
||||||
|
theLowBucketScore(lift, wrist, arm);
|
||||||
|
|
||||||
|
motors.calculateTrajectory(gamepad1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@TeleOp(name = "Dev Teleop Remix Deux", group = "Debug")
|
||||||
|
@Disabled
|
||||||
|
public class DevTeleOpRemixDeux extends OpMode {
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
public ClawSubsystem claw;
|
||||||
|
public ArmSubsystem arm;
|
||||||
|
public WristSubsystem wrist;
|
||||||
|
public LiftSubsystem lift;
|
||||||
|
public MotorsSubsystem motors;
|
||||||
|
|
||||||
|
public Gamepad currentGamepad1;
|
||||||
|
public Gamepad previousGamepad1;
|
||||||
|
public Gamepad currentGamepad2;
|
||||||
|
public Gamepad previousGamepad2;
|
||||||
|
|
||||||
|
public double power = .6;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
|
wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
|
motors = new MotorsSubsystem(hardwareMap, telemetry);
|
||||||
|
lift = new LiftSubsystem(hardwareMap, telemetry);
|
||||||
|
|
||||||
|
claw.init();
|
||||||
|
arm.init();
|
||||||
|
wrist.init();
|
||||||
|
lift.init();
|
||||||
|
motors.init();
|
||||||
|
|
||||||
|
currentGamepad1 = new Gamepad();
|
||||||
|
previousGamepad1 = new Gamepad();
|
||||||
|
currentGamepad2 = new Gamepad();
|
||||||
|
previousGamepad2 = new Gamepad();
|
||||||
|
|
||||||
|
follower.setMaxPower(this.power);
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theDrop(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
|
if (currentGamepad1.a && !previousGamepad1.a) {
|
||||||
|
wrist.toFloorPosition();
|
||||||
|
arm.toFloorPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void thePickup(ClawSubsystem claw) {
|
||||||
|
if (currentGamepad1.x && !previousGamepad1.x) {
|
||||||
|
claw.switchState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theLift(ArmSubsystem arm, WristSubsystem wrist) {
|
||||||
|
if (currentGamepad1.b && !previousGamepad1.b) {
|
||||||
|
arm.toParkPosition();
|
||||||
|
wrist.toBucketPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void theLowBucketScore(LiftSubsystem lift, WristSubsystem wrist, ArmSubsystem arm) {
|
||||||
|
if (currentGamepad1.y && !previousGamepad1.y) {
|
||||||
|
lift.toLowBucket();
|
||||||
|
wrist.toBucketPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
previousGamepad2.copy(currentGamepad2);
|
||||||
|
currentGamepad2.copy(gamepad2);
|
||||||
|
|
||||||
|
theDrop(arm, wrist);
|
||||||
|
thePickup(claw);
|
||||||
|
theLift(arm, wrist);
|
||||||
|
theLowBucketScore(lift, wrist, arm);
|
||||||
|
|
||||||
|
follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
||||||
|
follower.update();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.runmodes.DevTeleopRunMode;
|
||||||
|
import org.firstinspires.ftc.teamcode.runmodes.DevTeleopRunModeCompetition;
|
||||||
|
|
||||||
|
@TeleOp(name = "Dev Teleop RR Actions", group = "Debug")
|
||||||
|
public class DevTeleop extends OpMode {
|
||||||
|
|
||||||
|
public DevTeleopRunModeCompetition runMode;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.runMode = new DevTeleopRunModeCompetition(hardwareMap, telemetry, gamepad1, gamepad2);
|
||||||
|
this.runMode.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
this.runMode.update();
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ public class PedroConstants {
|
|||||||
|
|
||||||
|
|
||||||
// Robot motor configurations
|
// 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";
|
||||||
@ -58,7 +59,7 @@ public class PedroConstants {
|
|||||||
public static final double ROBOT_SPEED_LATERAL = 28.7119;
|
public static final double ROBOT_SPEED_LATERAL = 28.7119;
|
||||||
|
|
||||||
// Rate of deceleration when power is cut-off when the robot is moving forward
|
// Rate of deceleration when power is cut-off when the robot is moving forward
|
||||||
public static final double FORWARD_ZERO_POWER_ACCEL = -57.805;
|
public static final double FORWARD_ZERO_POWER_ACCEL = -59.805;
|
||||||
|
|
||||||
// Rate of deceleration when power is cut-off when the robot is moving to the right
|
// Rate of deceleration when power is cut-off when the robot is moving to the right
|
||||||
public static final double LATERAL_ZERO_POWER_ACCEL = -99.672;
|
public static final double LATERAL_ZERO_POWER_ACCEL = -99.672;
|
||||||
|
@ -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;
|
package org.firstinspires.ftc.teamcode.cometbots;
|
||||||
|
|
||||||
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;
|
||||||
@ -48,6 +48,7 @@ import com.qualcomm.robotcore.hardware.IMU;
|
|||||||
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
|
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
|
||||||
import org.firstinspires.ftc.robotcore.external.navigation.AngularVelocity;
|
import org.firstinspires.ftc.robotcore.external.navigation.AngularVelocity;
|
||||||
import org.firstinspires.ftc.robotcore.external.navigation.YawPitchRollAngles;
|
import org.firstinspires.ftc.robotcore.external.navigation.YawPitchRollAngles;
|
||||||
|
import org.firstinspires.ftc.teamcode.PedroConstants;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Encoder;
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Encoder;
|
||||||
|
|
||||||
/*
|
/*
|
@ -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,15 +27,16 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
@Autonomous(name = "AutoExampleTwo", group = "Autonomous Pathing Tuning")
|
@Disabled
|
||||||
public class AutoExampleTwo extends OpMode {
|
@Autonomous(name = "AsherOrientBlue", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AsherOrientBlue extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
private Follower follower;
|
private Follower follower;
|
||||||
|
|
||||||
private PathChain path;
|
private PathChain path;
|
||||||
|
|
||||||
private final Pose startPose = new Pose(10.0, 40, 90);
|
private final Pose startPose = new Pose(9.757, 84.983, 90);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
@ -49,30 +51,28 @@ public class AutoExampleTwo extends OpMode {
|
|||||||
follower.setStartingPose(startPose);
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
path = follower.pathBuilder()
|
path = follower.pathBuilder()
|
||||||
|
/*
|
||||||
|
* Only update this path
|
||||||
|
*/
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 1
|
// Line 1
|
||||||
new BezierLine(
|
new BezierLine(
|
||||||
new Point(10.000, 40.000, Point.CARTESIAN),
|
new Point(20.500, 7.800, Point.CARTESIAN),
|
||||||
new Point(60.000, 40.000, Point.CARTESIAN)
|
new Point(20.500, 87.500, Point.CARTESIAN)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setConstantHeadingInterpolation(Math.toRadians(90))
|
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 2
|
// Line 2
|
||||||
new BezierLine(
|
new BezierLine(
|
||||||
new Point(60.000, 40.000, Point.CARTESIAN),
|
new Point(20.500, 87.500, Point.CARTESIAN),
|
||||||
new Point(60.000, 25.000, Point.CARTESIAN)
|
new Point(7.800, 87.500, Point.CARTESIAN)
|
||||||
)
|
|
||||||
)
|
|
||||||
.setConstantHeadingInterpolation(Math.toRadians(90))
|
|
||||||
.addPath(
|
|
||||||
// Line 3
|
|
||||||
new BezierLine(
|
|
||||||
new Point(60.000, 25.000, Point.CARTESIAN),
|
|
||||||
new Point(10.000, 25.000, Point.CARTESIAN)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
/*
|
||||||
|
* End of only update this path
|
||||||
|
*/
|
||||||
|
|
||||||
follower.followPath(path);
|
follower.followPath(path);
|
||||||
|
|
@ -0,0 +1,135 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AsherPathBlueV1", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AsherPathBlueV1 extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(9.757, 84.983, 90);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.4);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
/*
|
||||||
|
* Only update this path
|
||||||
|
*/
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(7.800, 87.5, Point.CARTESIAN),
|
||||||
|
new Point(19.000, 116.000, Point.CARTESIAN),
|
||||||
|
new Point(93.000, 118.000, Point.CARTESIAN),
|
||||||
|
new Point(45.000, 115.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierLine(
|
||||||
|
new Point(45.000, 115.000, Point.CARTESIAN),
|
||||||
|
new Point(14.000, 126.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 3
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(14.000, 126.000, Point.CARTESIAN),
|
||||||
|
new Point(43.000, 112.500, Point.CARTESIAN),
|
||||||
|
new Point(64.000, 92.000, Point.CARTESIAN),
|
||||||
|
new Point(77.000, 117.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 4
|
||||||
|
new BezierLine(
|
||||||
|
new Point(77.000, 117.000, Point.CARTESIAN),
|
||||||
|
new Point(20.000, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 5
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(20.000, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(113.000, 95.000, Point.CARTESIAN),
|
||||||
|
new Point(69.000, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 6
|
||||||
|
new BezierLine(
|
||||||
|
new Point(69.000, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(20.500, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 7
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(20.500, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(101.500, 95.500, Point.CARTESIAN),
|
||||||
|
new Point(72.500, 95.500, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
/*
|
||||||
|
* End of only update this path
|
||||||
|
*/
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
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
|
||||||
|
* a circle, but some Bezier curves that have control points set essentially in a square. However,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AsherPathV1", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AsherPathV1 extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(10.0, 40, 90);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.4);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
/*
|
||||||
|
* Only update this path
|
||||||
|
*/
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(9.757, 84.983, Point.CARTESIAN),
|
||||||
|
new Point(33.000, 105.000, Point.CARTESIAN),
|
||||||
|
new Point(80.000, 118.000, Point.CARTESIAN),
|
||||||
|
new Point(55.000, 120.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(55.000, 120.000, Point.CARTESIAN),
|
||||||
|
new Point(22.000, 106.000, Point.CARTESIAN),
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 3
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN),
|
||||||
|
new Point(75.000, 95.000, Point.CARTESIAN),
|
||||||
|
new Point(112.000, 132.000, Point.CARTESIAN),
|
||||||
|
new Point(61.000, 131.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 4
|
||||||
|
new BezierLine(
|
||||||
|
new Point(61.000, 131.000, Point.CARTESIAN),
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 5
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN),
|
||||||
|
new Point(100.000, 118.000, Point.CARTESIAN),
|
||||||
|
new Point(103.000, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(61.000, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 6
|
||||||
|
new BezierLine(
|
||||||
|
new Point(61.000, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 7
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(11.000, 131.000, Point.CARTESIAN),
|
||||||
|
new Point(113.000, 95.000, Point.CARTESIAN),
|
||||||
|
new Point(67.000, 95.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
/*
|
||||||
|
* End of only update this path
|
||||||
|
*/
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AutoExample - Straight Path", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AutoExample extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(0.0, 20.0, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.6);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierLine(
|
||||||
|
new Point(0.000, 20.000, Point.CARTESIAN),
|
||||||
|
new Point(50.000, 20.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,11 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR;
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR;
|
|
||||||
|
|
||||||
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 com.qualcomm.robotcore.hardware.DcMotor;
|
|
||||||
import com.qualcomm.robotcore.hardware.DcMotorEx;
|
|
||||||
|
|
||||||
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;
|
||||||
@ -33,15 +27,16 @@ import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|||||||
* @version 1.0, 3/12/2024
|
* @version 1.0, 3/12/2024
|
||||||
*/
|
*/
|
||||||
@Config
|
@Config
|
||||||
@Autonomous(name = "AutoExample", group = "Autonomous Pathing Tuning")
|
@Disabled
|
||||||
public class AutoExample extends OpMode {
|
@Autonomous(name = "AutoExample - 2 Curves/2 Lines", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AutoExampleFour extends OpMode {
|
||||||
private Telemetry telemetryA;
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
private Follower follower;
|
private Follower follower;
|
||||||
|
|
||||||
private PathChain path;
|
private PathChain path;
|
||||||
|
|
||||||
private final Pose startPose = new Pose(12.0, 11, 90);
|
private final Pose startPose = new Pose(12,60, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
@ -51,54 +46,45 @@ public class AutoExample extends OpMode {
|
|||||||
public void init() {
|
public void init() {
|
||||||
follower = new Follower(hardwareMap);
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
follower.setMaxPower(.6);
|
follower.setMaxPower(.45);
|
||||||
|
|
||||||
follower.setStartingPose(startPose);
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
path = follower.pathBuilder()
|
path = follower.pathBuilder()
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 1
|
// Line 1
|
||||||
new BezierLine(
|
new BezierCurve(
|
||||||
new Point(12.804, 11.223, Point.CARTESIAN),
|
new Point(12.000, 60.000, Point.CARTESIAN),
|
||||||
new Point(12.804, 42.362, Point.CARTESIAN)
|
new Point(60.000, 60.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 12.000, Point.CARTESIAN)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setTangentHeadingInterpolation()
|
.setLinearHeadingInterpolation(Math.toRadians(0), Math.toRadians(-90))
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 2
|
// Line 2
|
||||||
new BezierCurve(
|
new BezierLine(
|
||||||
new Point(12.804, 42.362, Point.CARTESIAN),
|
new Point(60.000, 12.000, Point.CARTESIAN),
|
||||||
new Point(11.381, 57.379, Point.CARTESIAN),
|
new Point(40.000, 12.000, Point.CARTESIAN)
|
||||||
new Point(31.614, 56.588, Point.CARTESIAN)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setTangentHeadingInterpolation()
|
.setLinearHeadingInterpolation(Math.toRadians(-90), Math.toRadians(-90))
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 3
|
// Line 3
|
||||||
new BezierLine(
|
new BezierCurve(
|
||||||
new Point(31.614, 56.588, Point.CARTESIAN),
|
new Point(40.000, 12.000, Point.CARTESIAN),
|
||||||
new Point(51.214, 56.746, Point.CARTESIAN)
|
new Point(35.000, 35.000, Point.CARTESIAN),
|
||||||
|
new Point(12.000, 35.000, Point.CARTESIAN)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setTangentHeadingInterpolation()
|
.setLinearHeadingInterpolation(Math.toRadians(-90), Math.toRadians(-90))
|
||||||
.addPath(
|
.addPath(
|
||||||
// Line 4
|
// Line 4
|
||||||
new BezierCurve(
|
new BezierLine(
|
||||||
new Point(51.214, 56.746, Point.CARTESIAN),
|
new Point(12.000, 35.000, Point.CARTESIAN),
|
||||||
new Point(64.334, 58.643, Point.CARTESIAN),
|
new Point(12.000, 60.000, Point.CARTESIAN)
|
||||||
new Point(61.172, 45.524, Point.CARTESIAN)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setTangentHeadingInterpolation()
|
.setLinearHeadingInterpolation(Math.toRadians(-90), Math.toRadians(0))
|
||||||
.addPath(
|
|
||||||
// Line 5
|
|
||||||
new BezierCurve(
|
|
||||||
new Point(61.172, 45.524, Point.CARTESIAN),
|
|
||||||
new Point(36.198, 26.239, Point.CARTESIAN),
|
|
||||||
new Point(19.759, 11.065, Point.CARTESIAN)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.setTangentHeadingInterpolation()
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
follower.followPath(path);
|
follower.followPath(path);
|
@ -0,0 +1,144 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AutoExampleSeason2025V1", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AutoExampleSeason2025V1 extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(15.0, 35, 90);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.375);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierLine(
|
||||||
|
new Point(15.000, 35.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 35.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 35.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 25.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 3
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 25.000, Point.CARTESIAN),
|
||||||
|
new Point(15.000, 25.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 4
|
||||||
|
new BezierLine(
|
||||||
|
new Point(15.000, 25.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 25.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 5
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 25.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 15.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 6
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 15.000, Point.CARTESIAN),
|
||||||
|
new Point(15.000, 15.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 7
|
||||||
|
new BezierLine(
|
||||||
|
new Point(15.000, 15.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 15.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 8
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 15.000, Point.CARTESIAN),
|
||||||
|
new Point(60.000, 8.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 9
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.000, 8.000, Point.CARTESIAN),
|
||||||
|
new Point(15.000, 8.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AutoExample - Curve and Line", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AutoExampleThree extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(10,45, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.4);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(10.000, 45.000, Point.CARTESIAN),
|
||||||
|
new Point(45.000, 45.000, Point.CARTESIAN),
|
||||||
|
new Point(50.000, 20.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setLinearHeadingInterpolation(Math.toRadians(0), Math.toRadians(-90))
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierLine(
|
||||||
|
new Point(50.000, 20.000, Point.CARTESIAN),
|
||||||
|
new Point(10.000, 20.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setLinearHeadingInterpolation(Math.toRadians(-90), Math.toRadians(-90))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "AutoExample - Simple Curve", group = "Autonomous Pathing Tuning")
|
||||||
|
public class AutoExampleTwo extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(10.0, 45, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.4);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(10.000, 45.000, Point.CARTESIAN),
|
||||||
|
new Point(45.000, 45.000, Point.CARTESIAN),
|
||||||
|
new Point(50.000, 20.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setLinearHeadingInterpolation(Math.toRadians(0), Math.toRadians(-90))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(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;
|
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;
|
||||||
@ -82,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.
|
@ -0,0 +1,163 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "BlueBasketAuto", group = "Autonomous Pathing Tuning")
|
||||||
|
public class BlueBasketAuto extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(11.25, 95.75);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.45);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierLine(
|
||||||
|
new Point(11.250, 95.750, Point.CARTESIAN),
|
||||||
|
new Point(37.000, 108.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(37.000, 108.000, Point.CARTESIAN),
|
||||||
|
new Point(73.286, 111.536, Point.CARTESIAN),
|
||||||
|
new Point(67.821, 120.536, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 3
|
||||||
|
new BezierLine(
|
||||||
|
new Point(67.821, 120.536, Point.CARTESIAN),
|
||||||
|
new Point(28.000, 121.500, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 4
|
||||||
|
new BezierLine(
|
||||||
|
new Point(28.000, 121.500, Point.CARTESIAN),
|
||||||
|
new Point(18.000, 130.179, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 5
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(18.000, 130.179, Point.CARTESIAN),
|
||||||
|
new Point(59.000, 102.500, Point.CARTESIAN),
|
||||||
|
new Point(68.700, 130.500, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 6
|
||||||
|
new BezierLine(
|
||||||
|
new Point(68.700, 130.500, Point.CARTESIAN),
|
||||||
|
new Point(18.000, 130.339, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 7
|
||||||
|
new BezierCurve(
|
||||||
|
new Point(18.000, 130.339, Point.CARTESIAN),
|
||||||
|
new Point(49.018, 121.179, Point.CARTESIAN),
|
||||||
|
new Point(63.804, 135.321, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 8
|
||||||
|
new BezierLine(
|
||||||
|
new Point(63.804, 135.321, Point.CARTESIAN),
|
||||||
|
new Point(53.036, 135.161, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 9
|
||||||
|
new BezierLine(
|
||||||
|
new Point(53.036, 135.161, Point.CARTESIAN),
|
||||||
|
new Point(18.643, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(0))
|
||||||
|
.addPath(
|
||||||
|
// Line 10
|
||||||
|
new BezierLine(
|
||||||
|
new Point(18.643, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(72.300, 97.400, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addPath(
|
||||||
|
// Line 9
|
||||||
|
new BezierLine(
|
||||||
|
new Point(18.643, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(83.250, 95.464, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setLinearHeadingInterpolation(Math.toRadians(0), Math.toRadians(270)).build();
|
||||||
|
follower.followPath(path);
|
||||||
|
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,257 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.poc;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
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.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
* it turns enough to tune your centripetal force correction and some of your heading. Some lag in
|
||||||
|
* heading is to be expected.
|
||||||
|
*
|
||||||
|
* @author Anyi Lin - 10158 Scott's Bots
|
||||||
|
* @author Aaron Yang - 10158 Scott's Bots
|
||||||
|
* @author Harrison Womack - 10158 Scott's Bots
|
||||||
|
* @version 1.0, 3/12/2024
|
||||||
|
*/
|
||||||
|
@Config
|
||||||
|
@Disabled
|
||||||
|
@Autonomous(name = "BluebAutoV1", group = "Autonomous Pathing Tuning")
|
||||||
|
public class BluebAutoV1 extends OpMode {
|
||||||
|
private Telemetry telemetryA;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
|
||||||
|
private PathChain path;
|
||||||
|
|
||||||
|
private final Pose startPose = new Pose(7.5, 72, 90);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the Follower and creates the PathChain for the "circle". Additionally, this
|
||||||
|
* initializes the FTC Dashboard telemetry.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
|
||||||
|
follower.setMaxPower(.4);
|
||||||
|
|
||||||
|
follower.setStartingPose(startPose);
|
||||||
|
|
||||||
|
path = follower.pathBuilder()
|
||||||
|
.addPath(
|
||||||
|
// Line 1
|
||||||
|
new BezierLine(
|
||||||
|
new Point(7.5, 72, Point.CARTESIAN),
|
||||||
|
new Point(29.893, 38.250, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 2
|
||||||
|
new BezierLine(
|
||||||
|
new Point(29.893, 38.250, Point.CARTESIAN),
|
||||||
|
new Point(65.250, 32.143, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 3
|
||||||
|
new BezierLine(
|
||||||
|
new Point(65.250, 32.143, Point.CARTESIAN),
|
||||||
|
new Point(61.714, 24.429, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 4
|
||||||
|
new BezierLine(
|
||||||
|
new Point(61.714, 24.429, Point.CARTESIAN),
|
||||||
|
new Point(13.821, 22.821, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 5
|
||||||
|
new BezierLine(
|
||||||
|
new Point(13.821, 22.821, Point.CARTESIAN),
|
||||||
|
new Point(61.714, 24.429, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 6
|
||||||
|
new BezierLine(
|
||||||
|
new Point(61.714, 24.429, Point.CARTESIAN),
|
||||||
|
new Point(60.750, 12.696, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 7
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.750, 12.696, Point.CARTESIAN),
|
||||||
|
new Point(12.375, 13.179, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 8
|
||||||
|
new BezierLine(
|
||||||
|
new Point(12.375, 13.179, Point.CARTESIAN),
|
||||||
|
new Point(60.750, 12.536, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 9
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.750, 12.536, Point.CARTESIAN),
|
||||||
|
new Point(60.589, 9.321, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 10
|
||||||
|
new BezierLine(
|
||||||
|
new Point(60.589, 9.321, Point.CARTESIAN),
|
||||||
|
new Point(12.536, 8.357, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 11
|
||||||
|
new BezierLine(
|
||||||
|
new Point(12.536, 8.357, Point.CARTESIAN),
|
||||||
|
new Point(26.679, 8.679, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 12
|
||||||
|
new BezierLine(
|
||||||
|
new Point(26.679, 8.679, Point.CARTESIAN),
|
||||||
|
new Point(22.821, 109.446, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 13
|
||||||
|
new BezierLine(
|
||||||
|
new Point(22.821, 109.446, Point.CARTESIAN),
|
||||||
|
new Point(70.714, 109.446, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 14
|
||||||
|
new BezierLine(
|
||||||
|
new Point(70.714, 109.446, Point.CARTESIAN),
|
||||||
|
new Point(71.036, 120.214, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 15
|
||||||
|
new BezierLine(
|
||||||
|
new Point(71.036, 120.214, Point.CARTESIAN),
|
||||||
|
new Point(22.179, 120.214, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 16
|
||||||
|
new BezierLine(
|
||||||
|
new Point(22.179, 120.214, Point.CARTESIAN),
|
||||||
|
new Point(11.089, 130.821, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 17
|
||||||
|
new BezierLine(
|
||||||
|
new Point(11.089, 130.821, Point.CARTESIAN),
|
||||||
|
new Point(70.714, 112.018, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 18
|
||||||
|
new BezierLine(
|
||||||
|
new Point(70.714, 112.018, Point.CARTESIAN),
|
||||||
|
new Point(70.714, 128.250, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 19
|
||||||
|
new BezierLine(
|
||||||
|
new Point(70.714, 128.250, Point.CARTESIAN),
|
||||||
|
new Point(9.964, 130.018, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 20
|
||||||
|
new BezierLine(
|
||||||
|
new Point(9.964, 130.018, Point.CARTESIAN),
|
||||||
|
new Point(70.554, 130.500, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 21
|
||||||
|
new BezierLine(
|
||||||
|
new Point(70.554, 130.500, Point.CARTESIAN),
|
||||||
|
new Point(70.393, 135.000, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90))
|
||||||
|
.addPath(
|
||||||
|
// Line 22
|
||||||
|
new BezierLine(
|
||||||
|
new Point(70.393, 135.000, Point.CARTESIAN),
|
||||||
|
new Point(13.821, 134.839, Point.CARTESIAN)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setConstantHeadingInterpolation(Math.toRadians(90)).build();
|
||||||
|
|
||||||
|
|
||||||
|
follower.holdPoint(
|
||||||
|
new BezierPoint(
|
||||||
|
new Point(13.821, 134.839, Point.CARTESIAN)
|
||||||
|
),
|
||||||
|
90
|
||||||
|
);
|
||||||
|
|
||||||
|
follower.followPath(path);
|
||||||
|
telemetryA = new MultipleTelemetry(this.telemetry, FtcDashboard.getInstance().getTelemetry());
|
||||||
|
telemetryA.update();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This runs the OpMode, updating the Follower as well as printing out the debug statements to
|
||||||
|
* the Telemetry, as well as the FTC Dashboard.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
follower.update();
|
||||||
|
if (follower.atParametricEnd()) {
|
||||||
|
follower.followPath(path, true);
|
||||||
|
}
|
||||||
|
follower.telemetryDebug(telemetryA);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
/* Copyright (c) 2021 FIRST. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted (subject to the limitations in the disclaimer below) provided that
|
||||||
|
* the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
|
||||||
|
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
|
|
||||||
|
@TeleOp(name = "Arm Test", group = "Debug")
|
||||||
|
public class ArmTest extends LinearOpMode {
|
||||||
|
|
||||||
|
// Declare OpMode members for each of the 4 motors.
|
||||||
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runOpMode() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate Arm
|
||||||
|
*/
|
||||||
|
ArmSubsystem arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate gamepad state holders
|
||||||
|
*/
|
||||||
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
arm.init();
|
||||||
|
waitForStart();
|
||||||
|
runtime.reset();
|
||||||
|
|
||||||
|
// run until the end of the match (driver presses STOP)
|
||||||
|
while (opModeIsActive()) {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
|
arm.toParkPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
|
arm.toBucketPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
arm.switchState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
arm.setPosition(arm.getPosition() - .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
||||||
|
arm.setPosition(arm.getPosition() + .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
|
telemetry.addData("Arm State", arm.getState());
|
||||||
|
telemetry.addData("Arm Position", arm.getPosition());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/* Copyright (c) 2021 FIRST. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted (subject to the limitations in the disclaimer below) provided that
|
||||||
|
* the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
|
||||||
|
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
|
|
||||||
|
@TeleOp(name = "Claw Test", group = "Debug")
|
||||||
|
public class ClawTest extends LinearOpMode {
|
||||||
|
|
||||||
|
// Declare OpMode members for each of the 4 motors.
|
||||||
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runOpMode() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate Claw
|
||||||
|
*/
|
||||||
|
ClawSubsystem claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate gamepad state holders
|
||||||
|
*/
|
||||||
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
waitForStart();
|
||||||
|
runtime.reset();
|
||||||
|
|
||||||
|
// run until the end of the match (driver presses STOP)
|
||||||
|
while (opModeIsActive()) {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
claw.switchState();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the elapsed game time and wheel power.
|
||||||
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
|
telemetry.addData("Claw State", claw.getState());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
/* Copyright (c) 2021 FIRST. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted (subject to the limitations in the disclaimer below) provided that
|
||||||
|
* the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
|
||||||
|
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.LiftActionsSubsystem;
|
||||||
|
|
||||||
|
@TeleOp(name = "Lift Test", group = "Debug")
|
||||||
|
public class LiftTest extends LinearOpMode {
|
||||||
|
|
||||||
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runOpMode() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate Lift
|
||||||
|
*/
|
||||||
|
LiftActionsSubsystem lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate gamepad state holders
|
||||||
|
*/
|
||||||
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
lift.init();
|
||||||
|
waitForStart();
|
||||||
|
runtime.reset();
|
||||||
|
|
||||||
|
|
||||||
|
// run until the end of the match (driver presses STOP)
|
||||||
|
while (opModeIsActive()) {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
|
Actions.runBlocking(lift.toFloorPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
||||||
|
Actions.runBlocking(lift.toHighBucketPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
|
Actions.runBlocking(lift.toLowBucketPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
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.
|
||||||
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
|
telemetry.addData("Lift Drive Position", lift.getPosition());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
/* Copyright (c) 2021 FIRST. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted (subject to the limitations in the disclaimer below) provided that
|
||||||
|
* the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
|
||||||
|
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.firstinspires.ftc.teamcode.cometbots.tests;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ArmActionsSubsystem;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runOpMode() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate Lift
|
||||||
|
*/
|
||||||
|
LiftActionsSubsystem lift = new LiftActionsSubsystem(hardwareMap);
|
||||||
|
WristActionsSubsystem wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
|
ArmActionsSubsystem arm = new ArmActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate gamepad state holders
|
||||||
|
*/
|
||||||
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
lift.init();
|
||||||
|
wrist.init();
|
||||||
|
arm.init();
|
||||||
|
waitForStart();
|
||||||
|
runtime.reset();
|
||||||
|
|
||||||
|
|
||||||
|
// run until the end of the match (driver presses STOP)
|
||||||
|
while (opModeIsActive()) {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.dpad_up && !previousGamepad1.dpad_up) {
|
||||||
|
arm.setPosition(arm.getPosition() + .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.dpad_down && !previousGamepad1.dpad_down) {
|
||||||
|
arm.setPosition(arm.getPosition() - .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.triangle && !previousGamepad1.triangle) {
|
||||||
|
wrist.setPosition(wrist.getPosition() + .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
wrist.setPosition(wrist.getPosition() - .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
||||||
|
lift.setPosition(lift.getPosition() + 175);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
lift.setPosition(lift.getPosition() - 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the elapsed game time and wheel power.
|
||||||
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
|
telemetry.addData("Lift Drive Position", lift.getPosition());
|
||||||
|
telemetry.addData("Wrist Position", wrist.getPosition());
|
||||||
|
telemetry.addData("Arm Position", arm.getPosition());
|
||||||
|
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
/* Copyright (c) 2021 FIRST. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted (subject to the limitations in the disclaimer below) provided that
|
||||||
|
* the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
* other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
|
||||||
|
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.TeleOp;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristActionsSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
|
|
||||||
|
@TeleOp(name = "Wrist Test", group = "Debug")
|
||||||
|
public class WristTest extends LinearOpMode {
|
||||||
|
|
||||||
|
// Declare OpMode members for each of the 4 motors.
|
||||||
|
private final ElapsedTime runtime = new ElapsedTime();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runOpMode() {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate Wrist
|
||||||
|
*/
|
||||||
|
WristActionsSubsystem wrist = new WristActionsSubsystem(hardwareMap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Instantiate gamepad state holders
|
||||||
|
*/
|
||||||
|
Gamepad currentGamepad1 = new Gamepad();
|
||||||
|
Gamepad previousGamepad1 = new Gamepad();
|
||||||
|
|
||||||
|
wrist.init();
|
||||||
|
waitForStart();
|
||||||
|
runtime.reset();
|
||||||
|
|
||||||
|
// run until the end of the match (driver presses STOP)
|
||||||
|
while (opModeIsActive()) {
|
||||||
|
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.square && !previousGamepad1.square) {
|
||||||
|
Actions.runBlocking(wrist.toBucketPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.circle && !previousGamepad1.circle) {
|
||||||
|
Actions.runBlocking(wrist.toFloorPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.cross && !previousGamepad1.cross) {
|
||||||
|
wrist.switchState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
|
||||||
|
wrist.setPosition(wrist.getPosition() - .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
|
||||||
|
wrist.setPosition(wrist.getPosition() + .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the elapsed game time and wheel power.
|
||||||
|
telemetry.addData("Status", "Run Time: " + runtime.toString());
|
||||||
|
telemetry.addData("Wrist State", wrist.getState());
|
||||||
|
telemetry.addData("Wrist Position", wrist.getPosition());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.configs;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
|
||||||
|
@Config
|
||||||
|
public class RobotConstants {
|
||||||
|
public final static double clawClose = 1.00;
|
||||||
|
public final static double clawOpen = 0.05;
|
||||||
|
|
||||||
|
public final static double armFloor = 0.45;
|
||||||
|
public final static double armSubmarine = 0.375;
|
||||||
|
public final static double armPark = 0.0;
|
||||||
|
public final static double armBucket = 0.15;
|
||||||
|
|
||||||
|
public final static double wristFloor = 0.7;
|
||||||
|
public final static double wristBucket = 0.35;
|
||||||
|
|
||||||
|
public final static int liftToFloorPos = 0;
|
||||||
|
public final static int liftToSubmarinePos = 250;
|
||||||
|
public final static int liftToLowBucketPos = 2250;
|
||||||
|
public final static int liftToHighBucketPos = 3850;
|
||||||
|
public final static double liftPower = .625;
|
||||||
|
}
|
@ -71,8 +71,9 @@ measurements will be in centimeters.
|
|||||||
of how fast your robot will coast to a stop. Honestly, this is up to you. I personally used 4, but
|
of how fast your robot will coast to a stop. Honestly, this is up to you. I personally used 4, but
|
||||||
what works best for you is most important. Higher numbers will cause a faster brake, but increase
|
what works best for you is most important. Higher numbers will cause a faster brake, but increase
|
||||||
oscillations at the end. Lower numbers will do the opposite. This can be found on line `107` in
|
oscillations at the end. Lower numbers will do the opposite. This can be found on line `107` in
|
||||||
`FollowerConstants`, named `zeroPowerAccelerationMultiplier`. The drive PID is much, much more
|
`FollowerConstants`, named `zeroPowerAccelerationMultiplier`.
|
||||||
* sensitive than the others. For reference,
|
|
||||||
|
* The drive PID is much, much more sensitive than the others. For reference,
|
||||||
my P values were in the hundredths and thousandths place values, and my D values were in the hundred
|
my P values were in the hundredths and thousandths place values, and my D values were in the hundred
|
||||||
thousandths and millionths place values. To tune this, enable `useDrive`, `useHeading`, and
|
thousandths and millionths place values. To tune this, enable `useDrive`, `useHeading`, and
|
||||||
`useTranslational` in the `Follower` dropdown in FTC Dashboard. Next, run `StraightBackAndForth`
|
`useTranslational` in the `Follower` dropdown in FTC Dashboard. Next, run `StraightBackAndForth`
|
||||||
|
@ -60,8 +60,8 @@ public class FollowerConstants {
|
|||||||
public static CustomPIDFCoefficients headingPIDFCoefficients = new CustomPIDFCoefficients(
|
public static CustomPIDFCoefficients headingPIDFCoefficients = new CustomPIDFCoefficients(
|
||||||
2,
|
2,
|
||||||
0,
|
0,
|
||||||
.075,
|
.025,
|
||||||
-.03125);
|
0);
|
||||||
|
|
||||||
// Feed forward constant added on to the heading PIDF
|
// Feed forward constant added on to the heading PIDF
|
||||||
public static double headingPIDFFeedForward = 0.01;
|
public static double headingPIDFFeedForward = 0.01;
|
||||||
@ -81,7 +81,7 @@ public class FollowerConstants {
|
|||||||
// Kalman filter parameters for the drive error Kalman filter
|
// Kalman filter parameters for the drive error Kalman filter
|
||||||
public static KalmanFilterParameters driveKalmanFilterParameters = new KalmanFilterParameters(
|
public static KalmanFilterParameters driveKalmanFilterParameters = new KalmanFilterParameters(
|
||||||
6,
|
6,
|
||||||
1);
|
3);
|
||||||
|
|
||||||
|
|
||||||
// Mass of robot in kilograms
|
// Mass of robot in kilograms
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.runmodes;
|
||||||
|
|
||||||
|
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.pedroPathing.pathGeneration.BezierCurve;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Path;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.util.Timer;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ArmSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
|
import static org.firstinspires.ftc.teamcode.util.action.FieldConstants.*;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.WristSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.Action;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.SequentialAction;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.SleepAction;
|
||||||
|
|
||||||
|
public class Auto {
|
||||||
|
|
||||||
|
public ClawSubsystem claw;
|
||||||
|
public ArmSubsystem arm;
|
||||||
|
public WristSubsystem wrist;
|
||||||
|
|
||||||
|
public Timer clawTimer = new Timer();
|
||||||
|
public Timer armTimer = new Timer();
|
||||||
|
public Timer wristTimer = new Timer();
|
||||||
|
|
||||||
|
public Follower follower;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
|
public int caseState = 1;
|
||||||
|
|
||||||
|
public Auto(HardwareMap hardwareMap, Telemetry telemetry, Follower follower) {
|
||||||
|
claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
arm = new ArmSubsystem(hardwareMap, telemetry);
|
||||||
|
wrist = new WristSubsystem(hardwareMap, telemetry);
|
||||||
|
|
||||||
|
this.follower = follower;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
claw.init();
|
||||||
|
arm.init();
|
||||||
|
wrist.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
clawTimer.resetTimer();
|
||||||
|
armTimer.resetTimer();
|
||||||
|
wristTimer.resetTimer();
|
||||||
|
|
||||||
|
claw.start();
|
||||||
|
arm.start();
|
||||||
|
wrist.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
|
||||||
|
this.telemetry.addData("Current State", caseState);
|
||||||
|
this.telemetry.addData("Claw Timer", clawTimer.getElapsedTimeSeconds());
|
||||||
|
this.telemetry.addData("Arm Timer", armTimer.getElapsedTimeSeconds());
|
||||||
|
this.telemetry.addData("Wrist Timer", wristTimer.getElapsedTimeSeconds());
|
||||||
|
this.telemetry.update();
|
||||||
|
|
||||||
|
switch(caseState) {
|
||||||
|
case 1:
|
||||||
|
claw.openClaw();
|
||||||
|
caseState = 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (clawTimer.getElapsedTimeSeconds() > 2) {
|
||||||
|
arm.toFloorPosition();
|
||||||
|
caseState = 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (armTimer.getElapsedTimeSeconds() > 4) {
|
||||||
|
wrist.toFloorPosition();
|
||||||
|
caseState = 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (clawTimer.getElapsedTimeSeconds() > 6) {
|
||||||
|
claw.closeClaw();
|
||||||
|
caseState = 5;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (armTimer.getElapsedTimeSeconds() > 8) {
|
||||||
|
arm.toBucketPosition();
|
||||||
|
wrist.toBucketPosition();
|
||||||
|
caseState = 6;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (clawTimer.getElapsedTimeSeconds() > 10) {
|
||||||
|
claw.openClaw();
|
||||||
|
caseState = 7;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
this.init();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 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(.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()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
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_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 com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotorEx;
|
||||||
|
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.pedroPathing.localization.Pose;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.ClawSubsystem;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
|
public class Teleop {
|
||||||
|
|
||||||
|
private ClawSubsystem claw;
|
||||||
|
private Follower follower;
|
||||||
|
private DcMotorEx leftFront;
|
||||||
|
private DcMotorEx leftRear;
|
||||||
|
private DcMotorEx rightFront;
|
||||||
|
private DcMotorEx rightRear;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
|
||||||
|
private Gamepad gamepad1;
|
||||||
|
private Gamepad currentGamepad1;
|
||||||
|
private Gamepad previousGamepad1;
|
||||||
|
|
||||||
|
public Teleop(HardwareMap hardwareMap, Telemetry telemetry, Follower follower, Gamepad gamepad1) {
|
||||||
|
|
||||||
|
claw = new ClawSubsystem(hardwareMap, telemetry);
|
||||||
|
initMotors(hardwareMap);
|
||||||
|
|
||||||
|
this.follower = follower;
|
||||||
|
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.gamepad1 = gamepad1;
|
||||||
|
|
||||||
|
this.currentGamepad1 = new Gamepad();
|
||||||
|
this.previousGamepad1 = new Gamepad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
claw.start();
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
previousGamepad1.copy(currentGamepad1);
|
||||||
|
currentGamepad1.copy(gamepad1);
|
||||||
|
|
||||||
|
if (currentGamepad1.a && !previousGamepad1.a)
|
||||||
|
claw.switchState();
|
||||||
|
|
||||||
|
follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x);
|
||||||
|
follower.update();
|
||||||
|
|
||||||
|
telemetry.addData("X", follower.getPose().getX());
|
||||||
|
telemetry.addData("Y", follower.getPose().getY());
|
||||||
|
telemetry.addData("Heading", Math.toDegrees(follower.getPose().getHeading()));
|
||||||
|
telemetry.addData("Claw State", claw.getState());
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMotors(HardwareMap hardwareMap) {
|
||||||
|
rightFront = hardwareMap.get(DcMotorEx.class, FRONT_RIGHT_MOTOR);
|
||||||
|
rightRear = hardwareMap.get(DcMotorEx.class, BACK_RIGHT_MOTOR);
|
||||||
|
leftFront = hardwareMap.get(DcMotorEx.class, FRONT_LEFT_MOTOR);
|
||||||
|
leftRear = hardwareMap.get(DcMotorEx.class, BACK_LEFT_MOTOR);
|
||||||
|
|
||||||
|
rightFront.setDirection(FRONT_RIGHT_MOTOR_DIRECTION);
|
||||||
|
rightRear.setDirection(BACK_RIGHT_MOTOR_DIRECTION);
|
||||||
|
leftFront.setDirection(FRONT_LEFT_MOTOR_DIRECTION);
|
||||||
|
leftRear.setDirection(BACK_LEFT_MOTOR_DIRECTION);
|
||||||
|
|
||||||
|
leftFront.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
leftRear.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
rightRear.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,88 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
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-servo");
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
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.ServoImplEx;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
|
public class ArmSubsystem {
|
||||||
|
|
||||||
|
public enum ArmState {
|
||||||
|
PARK, FLOOR, BUCKET
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServoImplEx arm;
|
||||||
|
private ArmState state;
|
||||||
|
public RunAction toFloorPosition, toParkPosition, toBucketPosition;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
|
||||||
|
public ArmSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
this.arm = hardwareMap.get(ServoImplEx.class, "arm-servo");
|
||||||
|
this.toParkPosition = new RunAction(this::toParkPosition);
|
||||||
|
this.toFloorPosition = new RunAction(this::toFloorPosition);
|
||||||
|
this.toBucketPosition = new RunAction(this::toBucketPosition);
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ArmState armState) {
|
||||||
|
if (armState == ArmState.FLOOR) {
|
||||||
|
this.arm.setPosition(armFloor);
|
||||||
|
} else if (armState == ArmState.PARK) {
|
||||||
|
this.arm.setPosition(armPark);
|
||||||
|
} else if (armState == ArmState.BUCKET) {
|
||||||
|
this.arm.setPosition(armBucket);
|
||||||
|
}
|
||||||
|
this.state = armState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toFloorPosition() {
|
||||||
|
this.setState(ArmState.FLOOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toParkPosition() {
|
||||||
|
this.setState(ArmState.PARK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toBucketPosition() {
|
||||||
|
this.setState(ArmState.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (this.state == ArmState.FLOOR) {
|
||||||
|
this.setState(ArmState.PARK);
|
||||||
|
} else if (this.state == ArmState.PARK) {
|
||||||
|
this.setState(ArmState.BUCKET);
|
||||||
|
} else if (this.state == ArmState.BUCKET) {
|
||||||
|
this.setState(ArmState.FLOOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
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 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-servo");
|
||||||
|
}
|
||||||
|
|
||||||
|
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("Arm 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
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.Servo;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.Actions;
|
||||||
|
import org.firstinspires.ftc.teamcode.util.action.RunAction;
|
||||||
|
|
||||||
|
public class ClawSubsystem {
|
||||||
|
|
||||||
|
public enum ClawState {
|
||||||
|
CLOSED, OPEN
|
||||||
|
}
|
||||||
|
|
||||||
|
private Servo claw;
|
||||||
|
private ClawState state;
|
||||||
|
public RunAction openClaw, closeClaw;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
|
public ClawSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
this.claw = hardwareMap.get(Servo.class, "claw-servo");
|
||||||
|
this.openClaw = new RunAction(this::openClaw);
|
||||||
|
this.closeClaw = new RunAction(this::closeClaw);
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(ClawState clawState) {
|
||||||
|
if (clawState == ClawState.CLOSED) {
|
||||||
|
claw.setPosition(clawClose);
|
||||||
|
} else if (clawState == ClawState.OPEN) {
|
||||||
|
claw.setPosition(clawOpen);
|
||||||
|
}
|
||||||
|
this.state = clawState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClawState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (state == ClawState.CLOSED) {
|
||||||
|
setState(ClawState.OPEN);
|
||||||
|
} else if (state == ClawState.OPEN) {
|
||||||
|
setState(ClawState.CLOSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openClaw() {
|
||||||
|
setState(ClawState.OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeClaw() {
|
||||||
|
setState(ClawState.CLOSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
Actions.runBlocking(closeClaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(closeClaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return this.claw.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
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-motor");
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftPower;
|
||||||
|
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.liftToHighBucketPos;
|
||||||
|
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.liftToLowBucketPos;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class LiftSubsystem {
|
||||||
|
|
||||||
|
public DcMotor lift;
|
||||||
|
public RunAction toFloor, toLowBucket, toHighBucket, toFloat;
|
||||||
|
|
||||||
|
public enum LiftState {
|
||||||
|
FLOOR, LOW_BUCKET, HIGH_BUCKET, FLOAT
|
||||||
|
}
|
||||||
|
|
||||||
|
private LiftState liftState;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
|
||||||
|
public LiftSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
lift = hardwareMap.get(DcMotor.class, "lift-motor");
|
||||||
|
toFloor = new RunAction(this::toFloor);
|
||||||
|
toLowBucket = new RunAction(this::toLowBucket);
|
||||||
|
toHighBucket = new RunAction(this::toHighBucket);
|
||||||
|
toFloat = new RunAction(this::toFloat);
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(int b) {
|
||||||
|
lift.setTargetPosition(b);
|
||||||
|
lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (this.liftState == LiftState.FLOOR) {
|
||||||
|
this.toFloat();
|
||||||
|
} else if (this.liftState == LiftState.FLOAT) {
|
||||||
|
this.toLowBucket();
|
||||||
|
} else if (this.liftState == LiftState.LOW_BUCKET) {
|
||||||
|
this.toHighBucket();
|
||||||
|
} else if (this.liftState == LiftState.HIGH_BUCKET) {
|
||||||
|
this.toFloor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toFloor() {
|
||||||
|
this.setState(LiftState.FLOOR);
|
||||||
|
this.setTarget(liftToFloorPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toFloat() {
|
||||||
|
this.setState(LiftState.FLOAT);
|
||||||
|
this.setTarget(liftToSubmarinePos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toLowBucket() {
|
||||||
|
this.setState(LiftState.LOW_BUCKET);
|
||||||
|
this.setTarget(liftToLowBucketPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toHighBucket() {
|
||||||
|
this.setState(LiftState.HIGH_BUCKET);
|
||||||
|
this.setTarget(liftToHighBucketPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 start() {
|
||||||
|
Actions.runBlocking(toFloor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
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 com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
|
||||||
|
public class MotorsSubsystem {
|
||||||
|
|
||||||
|
public HardwareMap hardwareMap;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
|
public DcMotor frontLeftMotor;
|
||||||
|
public DcMotor backLeftMotor;
|
||||||
|
public DcMotor frontRightMotor;
|
||||||
|
public DcMotor backRightMotor;
|
||||||
|
|
||||||
|
public enum TravelState {
|
||||||
|
STOPPED, MOVING
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelState travelState;
|
||||||
|
|
||||||
|
public double power;
|
||||||
|
|
||||||
|
public MotorsSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
this.hardwareMap = hardwareMap;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.power = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorsSubsystem(HardwareMap hardwareMap, Telemetry telemetry, double power) {
|
||||||
|
this.hardwareMap = hardwareMap;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.power = power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 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);
|
||||||
|
|
||||||
|
frontLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
backLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
frontRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
backRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
|
||||||
|
this.setState(TravelState.STOPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrontLeftMotorPower(double power) {
|
||||||
|
frontLeftMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackLeftMotorPower(double power) {
|
||||||
|
backLeftMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrontRightMotorPower(double power) {
|
||||||
|
frontRightMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackRightMotorPower(double power) {
|
||||||
|
backRightMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calculateTrajectory(Gamepad gamepad1) {
|
||||||
|
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 leftBackPower = axial - lateral + yaw;
|
||||||
|
|
||||||
|
double rightFrontPower = 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
|
||||||
|
this.setFrontLeftMotorPower(leftFrontPower * this.power);
|
||||||
|
this.setFrontRightMotorPower(rightFrontPower * this.power);
|
||||||
|
this.setBackLeftMotorPower(leftBackPower * this.power);
|
||||||
|
this.setBackRightMotorPower(rightBackPower * this.power);
|
||||||
|
|
||||||
|
// Show the elapsed game time and wheel power.
|
||||||
|
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("Current State", this.getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(TravelState travelState) {
|
||||||
|
this.travelState = travelState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelState getState() {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
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 com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
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.RunAction;
|
||||||
|
|
||||||
|
public class WristSubsystem {
|
||||||
|
|
||||||
|
public enum WristState {
|
||||||
|
FLOOR, BUCKET
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServoImplEx wrist;
|
||||||
|
public WristState state;
|
||||||
|
public RunAction toFloorPosition, toBucketPosition;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
|
public WristSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
this.wrist = hardwareMap.get(ServoImplEx.class, "wrist-servo");
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
toBucketPosition = new RunAction(this::toBucketPosition);
|
||||||
|
toFloorPosition = new RunAction(this::toFloorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(WristState wristState) {
|
||||||
|
if (wristState == WristState.FLOOR) {
|
||||||
|
wrist.setPosition(wristFloor);
|
||||||
|
} else if (wristState == WristState.BUCKET) {
|
||||||
|
wrist.setPosition(wristBucket);
|
||||||
|
}
|
||||||
|
this.state = wristState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toFloorPosition() {
|
||||||
|
setState(WristState.FLOOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toBucketPosition() {
|
||||||
|
setState(WristState.BUCKET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchState() {
|
||||||
|
if (state == WristState.FLOOR) {
|
||||||
|
setState(WristState.BUCKET);
|
||||||
|
} else if (state == WristState.BUCKET) {
|
||||||
|
setState(WristState.FLOOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WristState getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
wrist.resetDeviceConfigurationForOpMode();
|
||||||
|
Actions.runBlocking(toFloorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
Actions.runBlocking(toFloorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPosition() {
|
||||||
|
return this.wrist.getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(double position) {
|
||||||
|
this.wrist.setPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.canvas.Canvas;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
|
public interface Action {
|
||||||
|
boolean run(TelemetryPacket p);
|
||||||
|
|
||||||
|
default void preview(Canvas fieldOverlay) {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
|
import com.acmerobotics.dashboard.canvas.Canvas;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
|
public class Actions {
|
||||||
|
|
||||||
|
public static void runBlocking(Action a) {
|
||||||
|
FtcDashboard dash = FtcDashboard.getInstance();
|
||||||
|
Canvas c = new Canvas();
|
||||||
|
a.preview(c);
|
||||||
|
|
||||||
|
boolean b = true;
|
||||||
|
while (b && !Thread.currentThread().isInterrupted()) {
|
||||||
|
TelemetryPacket p = new TelemetryPacket();
|
||||||
|
p.fieldOverlay().getOperations().addAll(c.getOperations());
|
||||||
|
b = a.run(p);
|
||||||
|
dash.sendTelemetryPacket(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.localization.Pose;
|
||||||
|
|
||||||
|
@Config
|
||||||
|
public class FieldConstants {
|
||||||
|
|
||||||
|
public enum RobotStart {
|
||||||
|
BLUE_BUCKET,
|
||||||
|
BLUE_OBSERVATION,
|
||||||
|
RED_BUCKET,
|
||||||
|
RED_OBSERVATION
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Pose blueBucketStartPose = new Pose(8, 79.5, Math.toRadians(180));
|
||||||
|
public static final Pose blueObservationStartPose = new Pose(8, 36, Math.toRadians(180));
|
||||||
|
public static final Pose redBucketStartPose = new Pose(144-8, 79.5, 0);
|
||||||
|
public static final Pose redObservationStartPose = new Pose(144-8, 36, 0);
|
||||||
|
|
||||||
|
// Blue Preload Poses
|
||||||
|
public static final Pose blueBucketPreloadPose = new Pose(34.5, 79.5, Math.toRadians(180));
|
||||||
|
|
||||||
|
// Blue Bucket Sample Poses
|
||||||
|
public static final Pose blueBucketLeftSamplePose = new Pose(34.75, 113.5, Math.toRadians(66));
|
||||||
|
public static final Pose blueBucketLeftSampleControlPose = new Pose(32, 108);
|
||||||
|
public static final Pose blueBucketMidSamplePose = new Pose(33, 125.5, Math.toRadians(73));
|
||||||
|
public static final Pose blueBucketMidSampleControlPose = new Pose(47.5, 110);
|
||||||
|
public static final Pose blueBucketRightSamplePose = new Pose(33, 133, Math.toRadians(74));
|
||||||
|
public static final Pose blueBucketRightSampleControlPose = new Pose(46, 101);
|
||||||
|
|
||||||
|
public static final Pose blueBucketScorePose = new Pose(16, 128, Math.toRadians(-45));
|
||||||
|
|
||||||
|
public static final Pose blueBucketParkPose = new Pose(65, 97.75, Math.toRadians(90));
|
||||||
|
public static final Pose blueBucketParkControlPose = new Pose(60.25, 123.5);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
|
public class RunAction implements Action {
|
||||||
|
|
||||||
|
private final Runnable runnable;
|
||||||
|
private Runnable callback;
|
||||||
|
|
||||||
|
public RunAction(Runnable runnable) {
|
||||||
|
this.runnable = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runAction() {
|
||||||
|
runnable.run();
|
||||||
|
if (callback != null) {
|
||||||
|
callback.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallback(Runnable callback) {
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adapter to make Action compatible with the Action interface
|
||||||
|
public boolean run(TelemetryPacket p) {
|
||||||
|
runAction();
|
||||||
|
return false; // Regular actions complete after one execution
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.canvas.Canvas;
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SequentialAction implements Action {
|
||||||
|
private List<Action> actions;
|
||||||
|
|
||||||
|
public SequentialAction(List<Action> actions) {
|
||||||
|
this.actions = new ArrayList<>(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SequentialAction(Action... actions) {
|
||||||
|
this(Arrays.asList(actions));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(TelemetryPacket p) {
|
||||||
|
if (actions.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actions.get(0).run(p)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
actions.remove(0);
|
||||||
|
return run(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preview(Canvas fieldOverlay) {
|
||||||
|
for (Action a : actions) {
|
||||||
|
a.preview(fieldOverlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.util.action;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
|
||||||
|
public class SleepAction implements Action {
|
||||||
|
private double dt;
|
||||||
|
private double beginTs = -1.0;
|
||||||
|
|
||||||
|
public SleepAction(double dt) {
|
||||||
|
this.dt = dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double now() {
|
||||||
|
return System.nanoTime() * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(TelemetryPacket p) {
|
||||||
|
double t;
|
||||||
|
if (beginTs < 0) {
|
||||||
|
beginTs = now();
|
||||||
|
t = 0.0;
|
||||||
|
} else {
|
||||||
|
t = now() - beginTs;
|
||||||
|
}
|
||||||
|
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