e.printStackTrace();
}
if(turret != null){
- turret.setDefaultCommand(new Superstructure(turret, drive, hood, shooter, spindexer));
+ //turret.setDefaultCommand(new Superstructure(turret, drive, hood, shooter, spindexer));
}
drive.setDefaultCommand(new DefaultDriveCommand(drive, driver));
break;
private final double phaseDelay = 0.03; // Extrapolation delay due to latency
- private Translation2d target = null;
+ private Translation2d target = FieldConstants.getHubTranslation().toTranslation2d();
private PhaseManager phaseManager = new PhaseManager();
+ private double hoodOffset = 0.0;
+
public Superstructure(Turret turret, Drivetrain drivetrain, Hood hood, Shooter shooter, Spindexer spindexer) {
this.turret = turret;
this.drivetrain = drivetrain;
lastTurretAngle = turretAngle;
+ Logger.recordOutput("Turret/Target Pose", target);
+
Logger.recordOutput("Lookahead Pose", lookaheadPose);
// Subtract the rotational angle of the robot from the setpoint
@Override
public void execute() {
+ hoodOffset = SmartDashboard.getNumber("Hood Offset", hoodOffset);
+ SmartDashboard.putNumber("Hood Offset", hoodOffset);
// Phase manager stuff
phaseManager.update(drivepose, shooter, turret);
- target = phaseManager.getTarget();
+ //target = phaseManager.getTarget();
updateDrivePose();
updateSetpoints(drivepose);
turret.setFieldRelativeTarget(Rotation2d.fromDegrees(turretSetpoint), turretVelocity - drivetrain.getAngularRate(2));
if(phaseManager.getCurrentState() == CurrentState.UNDER_TRENCH){
- hood.setFieldRelativeTarget(Rotation2d.fromDegrees(HoodConstants.MAX_ANGLE), 0.0);
+ hood.setFieldRelativeTarget(Rotation2d.fromDegrees(HoodConstants.MAX_ANGLE - hoodOffset), 0.0);
} else{
hood.setFieldRelativeTarget(Rotation2d.fromDegrees(hoodSetpoint), hoodVelocity);
}
- shooter.setShooter(ShotInterpolation.exitVelocityMap.get(goalState.exitVel()));
+ shooter.setShooter(-ShotInterpolation.exitVelocityMap.get(goalState.exitVel()));
// if (phaseManager.shouldFeed()) {
// spindexer.maxSpindexer();
import frc.robot.commands.gpm.ClimbDriveCommand;
import frc.robot.commands.gpm.IntakeMovementCommand;
import frc.robot.commands.gpm.ReverseMotors;
+import frc.robot.commands.gpm.Superstructure;
import frc.robot.constants.Constants;
import frc.robot.subsystems.Climb.LinearClimb;
import frc.robot.subsystems.drivetrain.Drivetrain;
// Auto shoot
if (turret != null && hood != null && shooter != null) {
- autoShoot = new AutoShootCommand(turret, getDrivetrain(), hood, shooter, spindexer);
+ autoShoot = new Superstructure(turret, getDrivetrain(), hood, shooter, spindexer);
controller.get(PS5Button.SQUARE).toggleOnTrue(autoShoot);
}
TalonFXConfiguration config = new TalonFXConfiguration();
config.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive;
- config.Slot0.kP = 12.0;
+ config.Slot0.kP = 10.0;
config.Slot0.kS = 0.1; // Static friction compensation
config.Slot0.kV = 0.12; // Adjusted kV for the gear ratio
- config.Slot0.kD = 0.15; // The "Braking" term to stop overshoot
+ config.Slot0.kD = 0.20; // The "Braking" term to stop overshoot
var mm = config.MotionMagic;
mm.MotionMagicCruiseVelocity = Units.radiansToRotations(TurretConstants.MAX_VELOCITY) * TurretConstants.GEAR_RATIO;
//Sets the initial motor position
motor.setPosition(motorRotations);
- motor.setPosition(0.0);
+ motor.setPosition(Units.degreesToRotations(238.86) * TurretConstants.GEAR_RATIO);
SmartDashboard.putData("Turn to 0", new InstantCommand(()->{setFieldRelativeTarget(Rotation2d.fromDegrees(0), 0.0);}));
SmartDashboard.putData("Turn to -90", new InstantCommand(()->{setFieldRelativeTarget(Rotation2d.fromDegrees(-90), 0.0);}));
@Override
public void updateInputs() {
- // inputs.positionDeg = Units.rotationsToDegrees(motor.getPosition().getValueAsDouble()) / TurretConstants.GEAR_RATIO;
+ inputs.positionDeg = Units.rotationsToDegrees(motor.getPosition().getValueAsDouble()) / TurretConstants.GEAR_RATIO;
inputs.velocityRadPerSec = Units.rotationsToRadians(motor.getVelocity().getValueAsDouble()) / TurretConstants.GEAR_RATIO;
inputs.motorCurrent = motor.getStatorCurrent().getValueAsDouble();
inputs.encoderLeftRot = wrapUnit(encoderLeft.getAbsolutePosition().getValueAsDouble());