mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Fix offset model
This commit is contained in:
@@ -254,20 +254,21 @@ public class RobotContainer {
|
|||||||
|
|
||||||
// IF the driver is holding the aim button, aim the robot towards the hub and shooter ready
|
// IF the driver is holding the aim button, aim the robot towards the hub and shooter ready
|
||||||
new Trigger(() -> getDeadbandedDriverController().getRightTriggerAxis() >= 0.5)
|
new Trigger(() -> getDeadbandedDriverController().getRightTriggerAxis() >= 0.5)
|
||||||
.whileTrue(new RunCommand(() -> m_robotSwerveDrive.driveFacingPosition(
|
.whileTrue(new RunCommand(
|
||||||
getDeadbandedDriverController().getLeft(),
|
// () -> m_robotSwerveDrive.driveFacingPosition(
|
||||||
FieldPositions.HUB_POSITION,
|
// getDeadbandedDriverController().getLeft(),
|
||||||
ShooterConstants.AIM_LEAD_TIME.get()
|
|
||||||
), m_robotSwerveDrive)
|
|
||||||
// () -> {
|
|
||||||
// m_robotSwerveDrive.driveFacingVelocity(
|
|
||||||
// getDeadbandedDriverController().getLeft(),
|
|
||||||
// FieldPositions.HUB_POSITION,
|
// FieldPositions.HUB_POSITION,
|
||||||
// ShooterConstants.AIM_LEAD_TIME.get(),
|
// ShooterConstants.AIM_LEAD_TIME.get()
|
||||||
// m_robotShooter.getBallVelocity(),
|
// ), m_robotSwerveDrive)
|
||||||
// m_robotShooter.getDistanceToHub()
|
() -> {
|
||||||
// );
|
m_robotSwerveDrive.driveFacingVelocity(
|
||||||
// }, m_robotSwerveDrive)
|
getDeadbandedDriverController().getLeft(),
|
||||||
|
FieldPositions.HUB_POSITION,
|
||||||
|
ShooterConstants.AIM_LEAD_TIME.get(),
|
||||||
|
m_robotShooter.getBallVelocity(),
|
||||||
|
m_robotShooter.getDistanceToHub()
|
||||||
|
);
|
||||||
|
}, m_robotSwerveDrive)
|
||||||
);
|
);
|
||||||
|
|
||||||
// D-PAD fine alignment
|
// D-PAD fine alignment
|
||||||
|
|||||||
@@ -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 = 162;
|
public static final int GIT_REVISION = 164;
|
||||||
public static final String GIT_SHA = "aac68dad5eabfaa1e098ad8cf6e42cd3bddd1ef3";
|
public static final String GIT_SHA = "f4a42f02eed0fa3b0950a05da55174b9f4b89ce7";
|
||||||
public static final String GIT_DATE = "2026-03-14 20:20:55 MDT";
|
public static final String GIT_DATE = "2026-03-14 20:39:45 MDT";
|
||||||
public static final String GIT_BRANCH = "MiraOrg";
|
public static final String GIT_BRANCH = "MiraOrg";
|
||||||
public static final String BUILD_DATE = "2026-03-14 20:33:21 MDT";
|
public static final String BUILD_DATE = "2026-03-15 11:14:11 MDT";
|
||||||
public static final long BUILD_UNIX_TIME = 1773542001176L;
|
public static final long BUILD_UNIX_TIME = 1773594851399L;
|
||||||
public static final int DIRTY = 1;
|
public static final int DIRTY = 1;
|
||||||
|
|
||||||
private BuildConstants(){}
|
private BuildConstants(){}
|
||||||
|
|||||||
@@ -409,13 +409,13 @@ public class SwerveDrive extends SubsystemBase implements Queryable {
|
|||||||
chassisSpeeds.vyMetersPerSecond
|
chassisSpeeds.vyMetersPerSecond
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ballVelocity > 1E-3 && chassisSpeeds.vyMetersPerSecond > 1E-3){
|
if (ballVelocity > 1E-3 && Math.abs(chassisSpeeds.vyMetersPerSecond) > 1E-3){
|
||||||
double aimOffset = chassisSpeeds.vyMetersPerSecond*distanceToHub/(Math.abs(ballVelocity));
|
double aimOffset = chassisSpeeds.vyMetersPerSecond*distanceToHub/(Math.abs(ballVelocity));
|
||||||
fieldPos = new Translation2d(fieldPos.getX(), fieldPos.getY() - aimOffset);
|
|
||||||
Logger.recordOutput("Aim Offset", aimOffset);
|
|
||||||
|
|
||||||
// double aimOffset = (chassisSpeeds.vyMetersPerSecond * distanceToHub) / (Math.abs(ballVelocity) * Math.cos(Math.atan((-1.4478 - (2.8956 + 4 * (0.03724333 * distanceToHub + 0.64797583) - Math.sqrt(Math.pow(2.8956 + 4 * (0.03724333 * distanceToHub + 0.64797583), 2) - 8.3863)) / 2) / distanceToHub)));
|
// double aimOffset = (chassisSpeeds.vyMetersPerSecond * distanceToHub) / (Math.abs(ballVelocity) * Math.cos(Math.atan((-1.4478 - (2.8956 + 4 * (0.03724333 * distanceToHub + 0.64797583) - Math.sqrt(Math.pow(2.8956 + 4 * (0.03724333 * distanceToHub + 0.64797583), 2) - 8.3863)) / 2) / distanceToHub)));
|
||||||
// Logger.recordOutput("Aim Offset", aimOffset);
|
|
||||||
|
fieldPos = new Translation2d(fieldPos.getX(), fieldPos.getY() - aimOffset);
|
||||||
|
Logger.recordOutput("Offset", aimOffset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -424,6 +424,7 @@ public class SwerveDrive extends SubsystemBase implements Queryable {
|
|||||||
|
|
||||||
Rotation2d ang = getPose2d().getTranslation().minus(fieldPosLead).getAngle();
|
Rotation2d ang = getPose2d().getTranslation().minus(fieldPosLead).getAngle();
|
||||||
|
|
||||||
|
Logger.recordOutput("Aim at Offset", fieldPos);
|
||||||
|
|
||||||
driveFieldAngle(leftStick, ang);
|
driveFieldAngle(leftStick, ang);
|
||||||
}
|
}
|
||||||
@@ -531,6 +532,12 @@ public class SwerveDrive extends SubsystemBase implements Queryable {
|
|||||||
vision.setLastOdomPose(state.currentPose);
|
vision.setLastOdomPose(state.currentPose);
|
||||||
setLastOdomSpeed(state.currentPose, state.lastPose, state.odometryRate);
|
setLastOdomSpeed(state.currentPose, state.lastPose, state.odometryRate);
|
||||||
|
|
||||||
|
// if (state.speeds != null) {
|
||||||
|
// this.chassisSpeeds = state.speeds;
|
||||||
|
// } else {
|
||||||
|
// this.chassisSpeeds = new ChassisSpeeds();
|
||||||
|
// }
|
||||||
|
|
||||||
if (vision.isTag()) {
|
if (vision.isTag()) {
|
||||||
Pose2d pose = vision.getPose2d();
|
Pose2d pose = vision.getPose2d();
|
||||||
if (!robotKnowsWhereItIs) {
|
if (!robotKnowsWhereItIs) {
|
||||||
@@ -545,11 +552,6 @@ public class SwerveDrive extends SubsystemBase implements Queryable {
|
|||||||
|
|
||||||
vision.setLastOdomPose(state.currentPose);
|
vision.setLastOdomPose(state.currentPose);
|
||||||
setLastOdomSpeed(state.currentPose, state.lastPose, state.odometryRate);
|
setLastOdomSpeed(state.currentPose, state.lastPose, state.odometryRate);
|
||||||
if (state.speeds != null) {
|
|
||||||
this.chassisSpeeds = state.speeds;
|
|
||||||
} else {
|
|
||||||
this.chassisSpeeds = new ChassisSpeeds();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(e.isPresent())
|
// if(e.isPresent())
|
||||||
|
|||||||
Reference in New Issue
Block a user