Skip to content

Commit 28b5981

Browse files
author
Strflightmight09
committed
Changed sim logic (still not working)
1 parent 38685d5 commit 28b5981

File tree

14 files changed

+41
-33
lines changed

14 files changed

+41
-33
lines changed

src/main/java/frc/trigon/robot/commands/AlignToNoteCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private double fieldRelativePowersToSelfRelativeXPower(double xPower, double yPo
7070
}
7171

7272
private MirrorableRotation2d getTargetAngle() {
73-
final Rotation2d currentRotation = RobotContainer.POSE_ESTIMATOR.getCurrentPose().getRotation();
73+
final Rotation2d currentRotation = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose().getRotation();
7474
return new MirrorableRotation2d(currentRotation.plus(CAMERA.getTrackedObjectYaw()), false);
7575
}
7676

src/main/java/frc/trigon/robot/commands/CommandConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class CommandConstants {
4545
() -> calculateDriveStickAxisValue(DRIVER_CONTROLLER.getLeftX()),
4646
() -> calculateRotationStickAxisValue(DRIVER_CONTROLLER.getRightX())
4747
),
48-
RESET_HEADING_COMMAND = new InstantCommand(() -> RobotContainer.POSE_ESTIMATOR.resetPose(changeRotation(new MirrorablePose2d(RobotContainer.POSE_ESTIMATOR.getCurrentPose(), false), new Rotation2d()).get())),
48+
RESET_HEADING_COMMAND = new InstantCommand(() -> RobotContainer.POSE_ESTIMATOR.resetPose(changeRotation(new MirrorablePose2d(RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose(), false), new Rotation2d()).get())),
4949
SET_GYRO_HEADING_TO_SOLVE_PNP_HEADING_COMMAND = new InstantCommand(RobotContainer.POSE_ESTIMATOR::setGyroHeadingToBestSolvePNPHeading).ignoringDisable(true),
5050
SELF_RELATIVE_DRIVE_FROM_DPAD_COMMAND = SwerveCommands.getClosedLoopSelfRelativeDriveCommand(
5151
() -> getXPowerFromPov(DRIVER_CONTROLLER.getPov()) / OperatorConstants.POV_DIVIDER / calculateShiftModeValue(MINIMUM_TRANSLATION_SHIFT_POWER),

src/main/java/frc/trigon/robot/commands/LEDAutoSetupCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ else if (difference > tolerance)
7575
}
7676

7777
private Pose2d getCurrentRobotPose() {
78-
return RobotContainer.POSE_ESTIMATOR.getCurrentPose();
78+
return RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose();
7979
}
8080
}

src/main/java/frc/trigon/robot/commands/VisualizeNoteShootingCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private double calculateNoteZDifference(double t) {
7171
private void configureStartingStats() {
7272
startingTimeSeconds = Timer.getFPGATimestamp();
7373

74-
final Pose2d currentRobotPose = RobotContainer.POSE_ESTIMATOR.getCurrentPose();
74+
final Pose2d currentRobotPose = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose();
7575
final Rotation2d currentRobotAngle = currentRobotPose.getRotation();
7676
final double startingTangentialVelocity = getStartingTangentialVelocity();
7777

src/main/java/frc/trigon/robot/commands/factories/AmpCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static Command getAutonomousPrepareForAmpCommand() {
4848
GeneralCommands.runWhen(
4949
AmpAlignerCommands.getSetTargetStateCommand(AmpAlignerConstants.AmpAlignerState.OPEN)
5050
.alongWith(PitcherCommands.getSetTargetPitchCommand(ShootingConstants.PREPARE_AMP_PITCH)),
51-
() -> RobotContainer.POSE_ESTIMATOR.getCurrentPose().getTranslation().getDistance(
51+
() -> RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose().getTranslation().getDistance(
5252
FieldConstants.IN_FRONT_OF_AMP_POSE.get().getTranslation()) < FieldConstants.MAXIMUM_DISTANCE_FROM_AMP_FOR_AUTONOMOUS_AMP_PREPARATION_METERS
5353
),
5454
ShooterCommands.getSetTargetVelocityCommand(ShootingConstants.AMP_SHOOTING_VELOCITY_ROTATIONS_PER_SECOND)

src/main/java/frc/trigon/robot/commands/factories/AutonomousCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static Optional<Rotation2d> calculateRotationOverride() {
104104
if (RobotContainer.INTAKE.hasNote() || !NOTE_DETECTION_CAMERA.hasTargets())
105105
return Optional.empty();
106106

107-
final Rotation2d currentRotation = RobotContainer.POSE_ESTIMATOR.getCurrentPose().getRotation();
107+
final Rotation2d currentRotation = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose().getRotation();
108108
final Rotation2d targetRotation = NOTE_DETECTION_CAMERA.getTrackedObjectYaw().minus(currentRotation);
109109
return Optional.of(targetRotation);
110110
}

src/main/java/frc/trigon/robot/misc/ShootingCalculations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Translation3d getRobotFieldRelativeVelocity() {
8686
*/
8787
private Translation2d predictFutureTranslation(double predictionTime) {
8888
final Translation2d fieldRelativeVelocity = getRobotFieldRelativeVelocity().toTranslation2d();
89-
final Translation2d currentPose = RobotContainer.POSE_ESTIMATOR.getCurrentPose().getTranslation();
89+
final Translation2d currentPose = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose().getTranslation();
9090
return currentPose.plus(fieldRelativeVelocity.times(predictionTime));
9191
}
9292

@@ -101,7 +101,7 @@ private Translation2d predictFutureTranslation(double predictionTime) {
101101
* @return the target state of the robot so the note will reach the shooting target, as a {@linkplain ShootingCalculations.TargetShootingState}
102102
*/
103103
private TargetShootingState calculateTargetShootingState(MirrorableTranslation3d shootingTarget, double standingShootingVelocityRotationsPerSecond, boolean reachFromAbove) {
104-
final Translation2d currentTranslation = RobotContainer.POSE_ESTIMATOR.getCurrentPose().getTranslation();
104+
final Translation2d currentTranslation = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose().getTranslation();
105105
final MirrorableRotation2d standingTargetRobotAngle = getAngleToTarget(currentTranslation, shootingTarget);
106106
final double standingTangentialVelocity = angularVelocityToTangentialVelocity(standingShootingVelocityRotationsPerSecond);
107107
final Rotation2d standingTargetPitch = calculateTargetPitch(standingTangentialVelocity, reachFromAbove, currentTranslation, standingTargetRobotAngle, shootingTarget);

src/main/java/frc/trigon/robot/misc/objectdetectioncamera/SimulationObjectDetectionCameraIO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected SimulationObjectDetectionCameraIO(String hostname) {
4343

4444
@Override
4545
protected void updateInputs(ObjectDetectionCameraInputsAutoLogged inputs) {
46-
final Rotation2d closestObjectYaw = getClosestVisibleObjectYaw(RobotContainer.POSE_ESTIMATOR.getCurrentPose());
46+
final Rotation2d closestObjectYaw = getClosestVisibleObjectYaw(RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose());
4747
if (closestObjectYaw == null) {
4848
inputs.hasTargets = false;
4949
} else {
@@ -63,7 +63,7 @@ protected void updateInputs(ObjectDetectionCameraInputsAutoLogged inputs) {
6363
private void updateHeldObjectPose() {
6464
if (heldObject.length == 0)
6565
return;
66-
heldObject[0] = getHeldObjectPose(RobotContainer.POSE_ESTIMATOR.getCurrentPose());
66+
heldObject[0] = getHeldObjectPose(RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose());
6767
}
6868

6969
private void updateObjectEjection() {
@@ -79,7 +79,7 @@ private void updateObjectEjection() {
7979
private void updateObjectCollection() {
8080
if (heldObject.length == 1 || !isCollecting())
8181
return;
82-
final Pose2d robotPose = RobotContainer.POSE_ESTIMATOR.getCurrentPose();
82+
final Pose2d robotPose = RobotContainer.POSE_ESTIMATOR.getCurrentEstimatedPose();
8383
final Translation2d robotTranslation = robotPose.getTranslation();
8484
for (Translation2d objectPlacement : objectsOnField) {
8585
if (objectPlacement.getDistance(robotTranslation) <= PICKING_UP_TOLERANCE_METERS) {

src/main/java/frc/trigon/robot/poseestimation/apriltagcamera/AprilTagCamera.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void update() {
6060

6161
logCameraInfo();
6262
if (RobotHardwareStats.isSimulation())
63-
AprilTagCameraConstants.VISION_SIMULATION.update(RobotContainer.POSE_ESTIMATOR.getCurrentPose());
63+
AprilTagCameraConstants.VISION_SIMULATION.update(RobotContainer.POSE_ESTIMATOR.getCurrentOdometryPose());
6464
}
6565

6666
public boolean hasNewResult() {
@@ -109,7 +109,7 @@ public double getDistanceToBestTagMeters() {
109109
* @return the robot's pose
110110
*/
111111
private Pose2d calculateBestRobotPose() {
112-
final Rotation2d gyroHeadingAtTimestamp = PoseEstimator6328.getInstance().samplePose(inputs.latestResultTimestampSeconds).getRotation();
112+
final Rotation2d gyroHeadingAtTimestamp = RobotHardwareStats.isSimulation() ? RobotContainer.SWERVE.getHeading() : PoseEstimator6328.getInstance().samplePose(inputs.latestResultTimestampSeconds).getRotation();
113113
return calculateAssumedRobotHeadingPose(gyroHeadingAtTimestamp);
114114
}
115115

src/main/java/frc/trigon/robot/poseestimation/apriltagcamera/AprilTagCameraConstants.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public class AprilTagCameraConstants {
2424
SIMULATION_CAMERA_RESOLUTION_WIDTH = 1600,
2525
SIMULATION_CAMERA_RESOLUTION_HEIGHT = 1200,
2626
SIMULATION_CAMERA_FPS = 60,
27-
SIMULATION_AVERAGE_CAMERA_LATENCY_MILLISECONDS = 35,
28-
SIMULATION_CAMERA_LATENCY_STANDARD_DEVIATIONS_MILLISECONDS = 5,
29-
SIMULATION_CAMERA_EXPOSURE_TIME_MILLISECONDS = 10;
27+
SIMULATION_AVERAGE_CAMERA_LATENCY_MILLISECONDS = 0,//35,
28+
SIMULATION_CAMERA_LATENCY_STANDARD_DEVIATIONS_MILLISECONDS = 0,//5,
29+
SIMULATION_CAMERA_EXPOSURE_TIME_MILLISECONDS = 0;//10;
3030
private static final Rotation2d SIMULATION_CAMERA_FOV = Rotation2d.fromDegrees(70);
3131
private static final double
32-
SIMULATION_CAMERA_AVERAGE_PIXEL_ERROR = 0.25,
33-
SIMULATION_CAMERA_PIXEL_STANDARD_DEVIATIONS = 0.08;
32+
SIMULATION_CAMERA_AVERAGE_PIXEL_ERROR = 0,//0.25,
33+
SIMULATION_CAMERA_PIXEL_STANDARD_DEVIATIONS = 0;//0.08;
3434
public static final SimCameraProperties SIMULATION_CAMERA_PROPERTIES = new SimCameraProperties();
3535

3636
static {

0 commit comments

Comments
 (0)