Fix field relative rotation

This commit is contained in:
nathanrsxtn
2022-01-31 19:29:00 -07:00
parent c6975fa81e
commit 6cf8ca98c3
5 changed files with 16 additions and 14 deletions
+2 -1
View File
@@ -102,6 +102,7 @@ public final class Constants {
public static final class OIConstants {
public static final int XBOX_DRIVER_ID = 0;
public static final int XBOX_OPERATOR_ID = 1;
public static final double AXIS_DEADBAND = 0.1;
public static final double LEFT_AXIS_DEADBAND = 0.1;
public static final double RIGHT_AXIS_DEADBAND = 0.6;
}
}
+8 -7
View File
@@ -35,13 +35,14 @@ public class Robot extends TimedRobot {
@Override
public void robotInit() {
if (org.fusesource.jansi.Ansi.isEnabled()) {
LOGGER.log(Level.ALL, "Logging Test 1/7");
LOGGER.log(Level.WARNING, "Logging Test 2/7");
LOGGER.log(Level.INFO, "Logging Test 3/7");
LOGGER.log(Level.CONFIG, "Logging Test 4/7");
LOGGER.log(Level.FINE, "Logging Test 5/7");
LOGGER.log(Level.FINER, "Logging Test 6/7");
LOGGER.log(Level.FINEST, "Logging Test 7/7");
LOGGER.log(Level.ALL, "Logging Test 1/8");
LOGGER.log(Level.SEVERE, "Logging Test 2/8");
LOGGER.log(Level.WARNING, "Logging Test 3/8");
LOGGER.log(Level.INFO, "Logging Test 4/8");
LOGGER.log(Level.CONFIG, "Logging Test 5/8");
LOGGER.log(Level.FINE, "Logging Test 6/8");
LOGGER.log(Level.FINER, "Logging Test 7/8");
LOGGER.log(Level.FINEST, "Logging Test 8/8");
}
LOGGER.fine("robotInit()");
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
@@ -131,8 +131,8 @@ public class SwerveDrive extends SubsystemBase {
ignoreAngles = leftX == 0 && leftY == 0 && rightX == 0 && rightY == 0;
Translation2d speed = new Translation2d(leftX, leftY);
speed = speed.times(speed.getNorm() * speedAdjust);
if (rightX > OIConstants.AXIS_DEADBAND || rightY > OIConstants.AXIS_DEADBAND)
rotTarget = new Rotation2d(rightX, -rightY);
if (Math.abs(rightX) > OIConstants.RIGHT_AXIS_DEADBAND || Math.abs(rightY) > OIConstants.RIGHT_AXIS_DEADBAND)
rotTarget = new Rotation2d(rightX, -rightY).minus(new Rotation2d(0, 1));
double rot = rotTarget.minus(m_gyro.getRotation2d()).getRadians();
double xSpeedMetersPerSecond = -speed.getX();
double ySpeedMetersPerSecond = speed.getY();