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