From 77b21edd5dc263b20f6db4b01b2e599fa8068a91 Mon Sep 17 00:00:00 2001 From: Graisen Edwards Date: Sat, 5 Oct 2024 16:48:27 -0400 Subject: [PATCH] RoadRunner support for GoBilda Pinpoint is lacking (https://github.com/acmerobotics/road-runner-ftc/issues/8 is still open), thus no RoadRunner can be implemented at the moment :( --- .../ftc/teamcode/RoadRunnerTuning.java | 501 ------------------ .../ftc/teamcode/roadrunner/Drawing.java | 22 - .../ftc/teamcode/roadrunner/Localizer.java | 8 - .../ftc/teamcode/roadrunner/MecanumDrive.java | 489 ----------------- .../ftc/teamcode/roadrunner/TankDrive.java | 498 ----------------- .../roadrunner/ThreeDeadWheelLocalizer.java | 100 ---- .../roadrunner/TwoDeadWheelLocalizer.java | 121 ----- .../messages/DriveCommandMessage.java | 24 - .../messages/MecanumCommandMessage.java | 19 - .../MecanumLocalizerInputsMessage.java | 30 -- .../roadrunner/messages/PoseMessage.java | 18 - .../messages/TankCommandMessage.java | 15 - .../messages/TankLocalizerInputsMessage.java | 17 - .../messages/ThreeDeadWheelInputsMessage.java | 17 - .../messages/TwoDeadWheelInputsMessage.java | 35 -- .../roadrunner/tuning/LocalizationTest.java | 76 --- .../tuning/ManualFeedbackTuner.java | 63 --- .../roadrunner/tuning/SplineTest.java | 39 -- .../roadrunner/tuning/TuningOpModes.java | 180 ------- .../ftc/teamcode/subsystems/Sensors.java | 4 +- 20 files changed, 1 insertion(+), 2275 deletions(-) delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RoadRunnerTuning.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/Drawing.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/Localizer.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/MecanumDrive.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/TankDrive.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/ThreeDeadWheelLocalizer.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/TwoDeadWheelLocalizer.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/DriveCommandMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/MecanumCommandMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/MecanumLocalizerInputsMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/PoseMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/TankCommandMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/TankLocalizerInputsMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/ThreeDeadWheelInputsMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/messages/TwoDeadWheelInputsMessage.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/tuning/LocalizationTest.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/tuning/ManualFeedbackTuner.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/tuning/SplineTest.java delete mode 100644 TeamCode/src/main/java/org/firstinspires/ftc/teamcode/roadrunner/tuning/TuningOpModes.java diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RoadRunnerTuning.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RoadRunnerTuning.java deleted file mode 100644 index 47170e445ba5..000000000000 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RoadRunnerTuning.java +++ /dev/null @@ -1,501 +0,0 @@ -package org.firstinspires.ftc.teamcode; - -import androidx.annotation.NonNull; - -import com.acmerobotics.dashboard.canvas.Canvas; -import com.acmerobotics.dashboard.config.Config; -import com.acmerobotics.dashboard.telemetry.TelemetryPacket; -import com.acmerobotics.roadrunner.AccelConstraint; -import com.acmerobotics.roadrunner.Action; -import com.acmerobotics.roadrunner.Actions; -import com.acmerobotics.roadrunner.AngularVelConstraint; -import com.acmerobotics.roadrunner.DualNum; -import com.acmerobotics.roadrunner.HolonomicController; -import com.acmerobotics.roadrunner.MecanumKinematics; -import com.acmerobotics.roadrunner.MinVelConstraint; -import com.acmerobotics.roadrunner.MotorFeedforward; -import com.acmerobotics.roadrunner.Pose2d; -import com.acmerobotics.roadrunner.Pose2dDual; -import com.acmerobotics.roadrunner.PoseVelocity2d; -import com.acmerobotics.roadrunner.PoseVelocity2dDual; -import com.acmerobotics.roadrunner.ProfileAccelConstraint; -import com.acmerobotics.roadrunner.ProfileParams; -import com.acmerobotics.roadrunner.Rotation2d; -import com.acmerobotics.roadrunner.Time; -import com.acmerobotics.roadrunner.TimeTrajectory; -import com.acmerobotics.roadrunner.TimeTurn; -import com.acmerobotics.roadrunner.TrajectoryActionBuilder; -import com.acmerobotics.roadrunner.TrajectoryBuilderParams; -import com.acmerobotics.roadrunner.TurnConstraints; -import com.acmerobotics.roadrunner.Twist2dDual; -import com.acmerobotics.roadrunner.Vector2d; -import com.acmerobotics.roadrunner.Vector2dDual; -import com.acmerobotics.roadrunner.VelConstraint; -import com.acmerobotics.roadrunner.ftc.DownsampledWriter; -import com.acmerobotics.roadrunner.ftc.Encoder; -import com.acmerobotics.roadrunner.ftc.FlightRecorder; -import com.acmerobotics.roadrunner.ftc.LazyImu; -import com.acmerobotics.roadrunner.ftc.LynxFirmware; -import com.acmerobotics.roadrunner.ftc.OverflowEncoder; -import com.acmerobotics.roadrunner.ftc.PositionVelocityPair; -import com.acmerobotics.roadrunner.ftc.RawEncoder; -import com.qualcomm.hardware.lynx.LynxModule; -import com.qualcomm.hardware.rev.RevHubOrientationOnRobot; -import com.qualcomm.robotcore.hardware.DcMotor; -import com.qualcomm.robotcore.hardware.DcMotorEx; -import com.qualcomm.robotcore.hardware.HardwareMap; -import com.qualcomm.robotcore.hardware.IMU; -import com.qualcomm.robotcore.hardware.VoltageSensor; - -import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit; -import org.firstinspires.ftc.robotcore.external.navigation.YawPitchRollAngles; -import org.firstinspires.ftc.teamcode.roadrunner.Drawing; -import org.firstinspires.ftc.teamcode.roadrunner.Localizer; -import org.firstinspires.ftc.teamcode.roadrunner.messages.DriveCommandMessage; -import org.firstinspires.ftc.teamcode.roadrunner.messages.MecanumCommandMessage; -import org.firstinspires.ftc.teamcode.roadrunner.messages.MecanumLocalizerInputsMessage; -import org.firstinspires.ftc.teamcode.roadrunner.messages.PoseMessage; -import org.firstinspires.ftc.teamcode.subsystems.Sensors; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -@Config -public final class RoadRunnerTuning { - public static class Params { - // IMU orientation - // TODO: fill in these values based on - // see https://ftc-docs.firstinspires.org/en/latest/programming_resources/imu/imu.html?highlight=imu#physical-hub-mounting - public RevHubOrientationOnRobot.LogoFacingDirection logoFacingDirection = - RevHubOrientationOnRobot.LogoFacingDirection.UP; - public RevHubOrientationOnRobot.UsbFacingDirection usbFacingDirection = - RevHubOrientationOnRobot.UsbFacingDirection.FORWARD; - - // drive model parameters - public double inPerTick = 1; - public double lateralInPerTick = inPerTick; - public double trackWidthTicks = 0; - - // feedforward parameters (in tick units) - public double kS = 0; - public double kV = 0; - public double kA = 0; - - // path profile parameters (in inches) - public double maxWheelVel = 50; - public double minProfileAccel = -30; - public double maxProfileAccel = 50; - - // turn profile parameters (in radians) - public double maxAngVel = Math.PI; // shared with path - public double maxAngAccel = Math.PI; - - // path controller gains - public double axialGain = 0.0; - public double lateralGain = 0.0; - public double headingGain = 0.0; // shared with turn - - public double axialVelGain = 0.0; - public double lateralVelGain = 0.0; - public double headingVelGain = 0.0; // shared with turn - } - - public static Params PARAMS = new Params(); - - public final MecanumKinematics kinematics = new MecanumKinematics( - PARAMS.inPerTick * PARAMS.trackWidthTicks, PARAMS.inPerTick / PARAMS.lateralInPerTick); - - public final TurnConstraints defaultTurnConstraints = new TurnConstraints( - PARAMS.maxAngVel, -PARAMS.maxAngAccel, PARAMS.maxAngAccel); - public final VelConstraint defaultVelConstraint = - new MinVelConstraint(Arrays.asList( - kinematics.new WheelVelConstraint(PARAMS.maxWheelVel), - new AngularVelConstraint(PARAMS.maxAngVel) - )); - public final AccelConstraint defaultAccelConstraint = - new ProfileAccelConstraint(PARAMS.minProfileAccel, PARAMS.maxProfileAccel); - - public final DcMotorEx leftFront, leftBack, rightBack, rightFront; - - public final VoltageSensor voltageSensor; - - public final LazyImu lazyImu; - public final Sensors sensors = new Sensors(); - - public final Localizer localizer; - public Pose2d pose; - - private final LinkedList poseHistory = new LinkedList<>(); - - private final DownsampledWriter estimatedPoseWriter = new DownsampledWriter("ESTIMATED_POSE", 50_000_000); - private final DownsampledWriter targetPoseWriter = new DownsampledWriter("TARGET_POSE", 50_000_000); - private final DownsampledWriter driveCommandWriter = new DownsampledWriter("DRIVE_COMMAND", 50_000_000); - private final DownsampledWriter mecanumCommandWriter = new DownsampledWriter("MECANUM_COMMAND", 50_000_000); - - public class DriveLocalizer implements Localizer { - public final Encoder leftFront, leftBack, rightBack, rightFront; - public final IMU imu; - - private int lastLeftFrontPos, lastLeftBackPos, lastRightBackPos, lastRightFrontPos; - private Rotation2d lastHeading; - private boolean initialized; - - public DriveLocalizer() { - leftFront = new OverflowEncoder(new RawEncoder(RoadRunnerTuning.this.leftFront)); - leftBack = new OverflowEncoder(new RawEncoder(RoadRunnerTuning.this.leftBack)); - rightBack = new OverflowEncoder(new RawEncoder(RoadRunnerTuning.this.rightBack)); - rightFront = new OverflowEncoder(new RawEncoder(RoadRunnerTuning.this.rightFront)); - - imu = lazyImu.get(); - - // TODO: reverse encoders if needed - // leftFront.setDirection(DcMotorSimple.Direction.REVERSE); - } - - @Override - public Twist2dDual