mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Updates
This commit is contained in:
@@ -7,12 +7,12 @@ public final class BuildConstants {
|
|||||||
public static final String MAVEN_GROUP = "";
|
public static final String MAVEN_GROUP = "";
|
||||||
public static final String MAVEN_NAME = "2026KPopRobotHunters";
|
public static final String MAVEN_NAME = "2026KPopRobotHunters";
|
||||||
public static final String VERSION = "unspecified";
|
public static final String VERSION = "unspecified";
|
||||||
public static final int GIT_REVISION = 160;
|
public static final int GIT_REVISION = 161;
|
||||||
public static final String GIT_SHA = "8c8ac261397954f1b5a118cb96d4e5f60d70da81";
|
public static final String GIT_SHA = "f5ecfd0be19548215558eee7217cf6eb1b8c487b";
|
||||||
public static final String GIT_DATE = "2026-03-14 18:57:04 MDT";
|
public static final String GIT_DATE = "2026-03-14 20:00:21 MDT";
|
||||||
public static final String GIT_BRANCH = "MiraOrg";
|
public static final String GIT_BRANCH = "MiraOrg";
|
||||||
public static final String BUILD_DATE = "2026-03-14 19:59:14 MDT";
|
public static final String BUILD_DATE = "2026-03-14 20:18:36 MDT";
|
||||||
public static final long BUILD_UNIX_TIME = 1773539954157L;
|
public static final long BUILD_UNIX_TIME = 1773541116232L;
|
||||||
public static final int DIRTY = 1;
|
public static final int DIRTY = 1;
|
||||||
|
|
||||||
private BuildConstants(){}
|
private BuildConstants(){}
|
||||||
|
|||||||
@@ -27,25 +27,21 @@ public class SimpleSwerveSim implements SwerveIO {
|
|||||||
public synchronized void setControl(SwerveRequest ctrl) {
|
public synchronized void setControl(SwerveRequest ctrl) {
|
||||||
if (ctrl == null) return;
|
if (ctrl == null) return;
|
||||||
|
|
||||||
// Handle FieldCentricFacingAngle — compute omega from target direction
|
|
||||||
if (ctrl instanceof SwerveRequest.FieldCentricFacingAngle facingAngle) {
|
if (ctrl instanceof SwerveRequest.FieldCentricFacingAngle facingAngle) {
|
||||||
vx = facingAngle.VelocityX;
|
vx = facingAngle.VelocityX;
|
||||||
vy = facingAngle.VelocityY;
|
vy = facingAngle.VelocityY;
|
||||||
|
|
||||||
// Simple P controller to rotate toward target
|
|
||||||
double currentAngle = pose.getRotation().getRadians();
|
double currentAngle = pose.getRotation().getRadians();
|
||||||
double targetAngle = facingAngle.TargetDirection.getRadians();
|
double targetAngle = facingAngle.TargetDirection.getRadians();
|
||||||
double error = targetAngle - currentAngle;
|
double error = targetAngle - currentAngle;
|
||||||
|
|
||||||
// Wrap error to [-pi, pi]
|
|
||||||
error = Math.atan2(Math.sin(error), Math.cos(error));
|
error = Math.atan2(Math.sin(error), Math.cos(error));
|
||||||
|
|
||||||
double kP = 5.0; // tune this — matches PathPlanner's rotation PID
|
double kP = 5.0;
|
||||||
omega = error * kP;
|
omega = error * kP;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle FieldCentric (normal driving with explicit rotational rate)
|
|
||||||
if (ctrl instanceof SwerveRequest.FieldCentric fc) {
|
if (ctrl instanceof SwerveRequest.FieldCentric fc) {
|
||||||
vx = fc.VelocityX;
|
vx = fc.VelocityX;
|
||||||
vy = fc.VelocityY;
|
vy = fc.VelocityY;
|
||||||
@@ -54,7 +50,6 @@ public class SimpleSwerveSim implements SwerveIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl instanceof SwerveRequest.RobotCentric rc) {
|
if (ctrl instanceof SwerveRequest.RobotCentric rc) {
|
||||||
// rotate velocity into field frame
|
|
||||||
double cos = pose.getRotation().getCos();
|
double cos = pose.getRotation().getCos();
|
||||||
double sin = pose.getRotation().getSin();
|
double sin = pose.getRotation().getSin();
|
||||||
double vxRobot = rc.VelocityX;
|
double vxRobot = rc.VelocityX;
|
||||||
@@ -65,13 +60,11 @@ public class SimpleSwerveSim implements SwerveIO {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle brake
|
|
||||||
if (ctrl instanceof SwerveRequest.SwerveDriveBrake) {
|
if (ctrl instanceof SwerveRequest.SwerveDriveBrake) {
|
||||||
vx = 0; vy = 0; omega = 0;
|
vx = 0; vy = 0; omega = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: your original reflection approach
|
|
||||||
ChassisSpeeds cs = tryGetSpeedsField(ctrl);
|
ChassisSpeeds cs = tryGetSpeedsField(ctrl);
|
||||||
if (cs != null) {
|
if (cs != null) {
|
||||||
vx = cs.vxMetersPerSecond;
|
vx = cs.vxMetersPerSecond;
|
||||||
|
|||||||
Reference in New Issue
Block a user