mirror of
https://github.com/Team4388/2025RidgeScape.git
synced 2026-06-09 00:38:02 -06:00
x /= i^2
This commit is contained in:
@@ -65,6 +65,7 @@ import frc4388.robot.subsystems.SwerveDrive;
|
||||
import frc4388.utility.DeferredBlock;
|
||||
import frc4388.utility.ReefPositionHelper;
|
||||
import frc4388.utility.Subsystem;
|
||||
import frc4388.utility.TimesNegativeOne;
|
||||
import frc4388.utility.ReefPositionHelper.Side;
|
||||
import frc4388.utility.configurable.ConfigurableString;
|
||||
|
||||
@@ -292,7 +293,10 @@ public class RobotContainer {
|
||||
|
||||
configureButtonBindings();
|
||||
configureVirtualButtonBindings();
|
||||
new DeferredBlock(() -> m_robotSwerveDrive.resetGyro());
|
||||
new DeferredBlock(() -> { // Called on robot enable
|
||||
TimesNegativeOne.update();
|
||||
m_robotSwerveDrive.resetGyro();
|
||||
});
|
||||
DriverStation.silenceJoystickConnectionWarning(true);
|
||||
// CameraServer.startAutomaticCapture();
|
||||
|
||||
@@ -462,7 +466,6 @@ public class RobotContainer {
|
||||
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 180)
|
||||
.onTrue(new InstantCommand(() -> AutoConstants.ELEVATOR_OFFSET_TRIM.stepDown()));
|
||||
|
||||
|
||||
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 90)
|
||||
.onTrue(new InstantCommand(() -> AutoConstants.ARM_OFFSET_TRIM.stepUp()));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import frc4388.robot.subsystems.SwerveDrive;
|
||||
import frc4388.robot.subsystems.Vision;
|
||||
import frc4388.utility.Gains;
|
||||
import frc4388.utility.ReefPositionHelper;
|
||||
import frc4388.utility.TimesNegativeOne;
|
||||
import frc4388.utility.ReefPositionHelper.Side;
|
||||
import frc4388.utility.UtilityStructs.AutoRecordingControllerFrame;
|
||||
import frc4388.utility.UtilityStructs.AutoRecordingFrame;
|
||||
@@ -75,18 +76,9 @@ public class GotoLastApril extends Command {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
if (alliance == Alliance.Red) {
|
||||
xerr = -(targetpos.getX() - vision.getPose2d().getX());
|
||||
yerr = (targetpos.getY() - vision.getPose2d().getY());
|
||||
}
|
||||
else{
|
||||
|
||||
xerr = targetpos.getX() - vision.getPose2d().getX();
|
||||
yerr = targetpos.getY() - vision.getPose2d().getY();
|
||||
}
|
||||
xerr = TimesNegativeOne.invert(targetpos.getX() - vision.getPose2d().getX(), TimesNegativeOne.XAxis);
|
||||
yerr = TimesNegativeOne.invert(targetpos.getX() - vision.getPose2d().getX(), TimesNegativeOne.YAxis);
|
||||
|
||||
|
||||
roterr = targetpos.getRotation().getDegrees() - vision.getPose2d().getRotation().getDegrees();
|
||||
|
||||
// SmartDashboard.putNumber("PID X Error", xerr);
|
||||
|
||||
@@ -35,9 +35,8 @@ import frc4388.robot.commands.GotoLastApril;
|
||||
import frc4388.robot.commands.LidarAlign;
|
||||
import frc4388.utility.Status;
|
||||
import frc4388.utility.Subsystem;
|
||||
import frc4388.utility.TimesNegativeOne;
|
||||
import frc4388.utility.Status.ReportLevel;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||
|
||||
import com.pathplanner.lib.controllers.PPHolonomicDriveController;
|
||||
import com.pathplanner.lib.config.PIDConstants;
|
||||
@@ -103,11 +102,11 @@ public class SwerveDrive extends Subsystem {
|
||||
// This will flip the path being followed to the red side of the field.
|
||||
// THE ORIGIN WILL REMAIN ON THE BLUE SIDE
|
||||
|
||||
var alliance = DriverStation.getAlliance();
|
||||
if (alliance.isPresent()) {
|
||||
return alliance.get() == DriverStation.Alliance.Red;
|
||||
}
|
||||
return false;
|
||||
// var alliance = DriverStation.getAlliance();
|
||||
// if (alliance.isPresent()) {
|
||||
// return alliance.get() == DriverStation.Alliance.Red;
|
||||
// }
|
||||
return TimesNegativeOne.isRed;
|
||||
},
|
||||
this // Reference to this subsystem to set requirements
|
||||
);
|
||||
@@ -141,18 +140,8 @@ public class SwerveDrive extends Subsystem {
|
||||
return; // don't bother doing swerve drive math and return early.
|
||||
|
||||
leftStick = leftStick.rotateBy(Rotation2d.fromDegrees(SwerveDriveConstants.FORWARD_OFFSET));
|
||||
|
||||
Optional<Alliance> alliance = DriverStation.getAlliance();
|
||||
|
||||
if(!alliance.isEmpty()){
|
||||
if (alliance.get() == Alliance.Red)
|
||||
leftStick = new Translation2d(-leftStick.getX(), leftStick.getY());
|
||||
else
|
||||
leftStick = new Translation2d(leftStick.getX(), -leftStick.getY());
|
||||
// if (alliance.get() != Alliance.Red) leftStick = new Translation2d(leftStick.getX(), -leftStick.getY());
|
||||
}
|
||||
if (SwerveDriveConstants.INVERT_ROTATION) rightStick.times(-1);
|
||||
|
||||
leftStick = TimesNegativeOne.invert(leftStick, TimesNegativeOne.XAxis, TimesNegativeOne.YAxis);
|
||||
leftStick = TimesNegativeOne.invert(rightStick, TimesNegativeOne.RotAxis);
|
||||
|
||||
|
||||
stopped = false;
|
||||
|
||||
Reference in New Issue
Block a user