Skip to content

Commit 7353bc5

Browse files
committed
changes for dealing with orientation differences between the Field-Centric and Odometry-Centric systems.
1 parent 1ab4eac commit 7353bc5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class Robot extends TimedRobot {
4646
ControllerConstants.kDriverControllerPort);
4747
private final PowerDistribution m_pdh = new PowerDistribution();
4848
private final VisionSimulator m_visionSimulator = new VisionSimulator(m_driveSubsystem,
49-
pose(kFieldLayout.getFieldLength() / 2, 1.91, 0), 0.01);
49+
pose(kFieldLayout.getFieldLength() / 2, 1.91, 180), 0.01);
5050
private final PhotonCamera m_camera1 = RobotBase.isSimulation()
5151
? new PhotonCameraSimulator("Camera1", kRobotToCamera1, m_visionSimulator, 3, 0.1)
5252
: new PhotonCamera("Cool camera");
@@ -107,7 +107,7 @@ public void bindDriveControls() {
107107
() -> -m_driverController.getLeftY(),
108108
() -> -m_driverController.getLeftX(),
109109
() -> m_driverController.getL2Axis() - m_driverController.getR2Axis(),
110-
m_driverController.getHID()::getSquareButton));
110+
() -> !m_driverController.getHID().getSquareButton()));
111111

112112
m_driverController.button(Button.kSquare)
113113
.whileTrue(

src/main/java/frc/robot/subsystems/PoseEstimationSubsystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ public ChassisSpeeds chassisSpeedsTowardClosestTag(Transform2d robotToTag, doubl
203203
* @return the calculated {@code ChassisSpeeds} to move from the current
204204
* {@code Pose2d} toward the target {@code Pose2d}
205205
*/
206-
public static ChassisSpeeds chassisSpeeds(Pose2d currentPose, Pose2d targetPose, PIDController controllerXY,
206+
public ChassisSpeeds chassisSpeeds(Pose2d currentPose, Pose2d targetPose, PIDController controllerXY,
207207
PIDController controllerYaw) {
208-
Translation2d current2target = targetPose.getTranslation()
209-
.minus(currentPose.getTranslation());
208+
Translation2d current2target = targetPose.minus(currentPose).getTranslation()
209+
.rotateBy(m_driveSubsystem.getPose().getRotation());
210210
double velocityX = 0, velocityY = 0;
211211
double distance = current2target.getNorm();
212212
if (distance > 0) {

0 commit comments

Comments
 (0)