From 2aa527ce33c5858110c210a9633f515d11396506 Mon Sep 17 00:00:00 2001 From: maxwtan <100314265+MaxwellTTan20@users.noreply.github.com> Date: Thu, 5 Feb 2026 17:02:09 -0800 Subject: [PATCH] a --- .../frc/robot/subsystems/turret/Turret.java | 20 ++++++++++++++++++ vendordeps/yams.json | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 vendordeps/yams.json diff --git a/src/main/java/frc/robot/subsystems/turret/Turret.java b/src/main/java/frc/robot/subsystems/turret/Turret.java index 8a1630f..ad3e5a0 100644 --- a/src/main/java/frc/robot/subsystems/turret/Turret.java +++ b/src/main/java/frc/robot/subsystems/turret/Turret.java @@ -32,6 +32,8 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.constants.Constants; import frc.robot.constants.IdConstants; import frc.robot.constants.swerve.DriveConstants; +import yams.units.EasyCRT; +import yams.units.EasyCRTConfig; public class Turret extends SubsystemBase implements TurretIO{ @@ -56,6 +58,8 @@ public class Turret extends SubsystemBase implements TurretIO{ private double lastFrameVelocity = 0.0; + EasyCRT easyCRT; + /* ---------------- Hardware ---------------- */ private final TalonFX motor = new TalonFX(IdConstants.TURRET_MOTOR_ID, Constants.RIO_CAN); @@ -123,6 +127,22 @@ public class Turret extends SubsystemBase implements TurretIO{ setpoint = new State(getPositionRad(), 0.0); lastGoalRad = setpoint.position; + EasyCRTConfig crt_cfg = new EasyCRTConfig(null, null) + .withEncoderRatios(TurretConstants.LEFT_ENCODER_RATIO, TurretConstants.RIGHT_ENCODER_RATIO) + .withAbsoluteEncoderOffsets(Rotations.of(Units.degreesToRotations(TurretConstants.LEFT_ENCODER_OFFSET)), Rotations.of(Units.degreesToRotations(TurretConstants.RIGHT_ENCODER_OFFSET))) + .withMechanismRange(Degrees.of(TurretConstants.MIN_ANGLE), Degrees.of(TurretConstants.MAX_ANGLE)) + .withMatchTolerance(Degrees.of(2)) // Tune this + .withAbsoluteEncoderInversions(false, false) + // shared drive gear / pinion (the tan gear/tiny first gear on motor shaft) + // turret ring / shared drive pulley (big turret gear / first black belt gear weird thingy?) + .withCrtGearRecommendationInputs(10, 140.0/22.0); // prob need to fix + + this.easyCRT = new EasyCRT(crt_cfg); + + this.easyCRT.getAngleOptional().ifPresent(angle -> { + motor.setPosition(angle.in(Rotations) * gearRatio); + }); + if (RobotBase.isSimulation()) { simState = motor.getSimState(); turretSim = new SingleJointedArmSim( diff --git a/vendordeps/yams.json b/vendordeps/yams.json new file mode 100644 index 0000000..9557c14 --- /dev/null +++ b/vendordeps/yams.json @@ -0,0 +1,21 @@ +{ + "fileName": "yams.json", + "name": "Yet Another Mechanism System", + "version": "2026.2.3", + "frcYear": "2026", + "uuid": "a1051e86-a979-4880-a28b-a0d5362d1d96", + "mavenUrls": [ + "https://yet-another-software-suite.github.io/YAMS/releases/" + ], + "jsonUrl": "https://yet-another-software-suite.github.io/YAMS/yams.json", + "javaDependencies": [ + { + "groupId": "yams", + "artifactId": "YAMS-java", + "version": "2026.2.3" + } + ], + "cppDependencies": [], + "jniDependencies": [], + "requires": [] +} \ No newline at end of file -- 2.39.5