Skip to content

Commit 7224e49

Browse files
committed
Made wheels reset to zero when enabled and tried subtracting offsets for PID
1 parent 840f506 commit 7224e49

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public void teleopInit() {
8282
if (m_autonomousCommand != null) {
8383
m_autonomousCommand.cancel();
8484
}
85-
m_robotContainer.stopAllMotors();
85+
m_robotContainer.resetToForwardPosition();
86+
//m_robotContainer.stopAllMotors();
8687
}
8788

8889
/** This function is called periodically during operator control. */

src/main/java/frc/robot/RobotContainer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,16 @@ private void configureBindings() {
7878
// // cancelling on release.
7979
// m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
8080
}
81-
8281
public void stopAllMotors() {
8382
m_driveSubsystem.stopAllMotors();
8483
}
8584

85+
public void resetToForwardPosition() {
86+
m_driveSubsystem.resetToForwardPosition();
87+
}
88+
89+
90+
8691
/**
8792
* Use this to pass the autonomous command to the main {@link Robot} class.
8893
*

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class DriveSubsystem extends SubsystemBase {
8080
private double[] CAN_CODER_ANGLE_OFFSETS = { // These values are all in degrees.
8181
21.53, // BACK_RIGHT
8282
74.62, // BACK_LEFT
83-
83.50, // FRONT_LEFT
83+
80.07, // FRONT_LEFT
8484
111.80, // FRONT_RIGHT
8585
};
8686

@@ -438,7 +438,6 @@ public void drive(double xAxis, double yAxis, double turn) {
438438
* or according to the current trajectory (during autonomous).
439439
*/
440440
public void periodic() {
441-
if (true) return;
442441
switch (driveType) {
443442
case DIFFERENTIAL_DRIVE:
444443
// If the joystick is being moved, then the shuffleboard will be
@@ -513,8 +512,9 @@ public void periodic() {
513512
// automatically.
514513
// rotations.refresh();
515514
CANCoderAnglesRadians[i] = rotations.getValueAsDouble() * 2 * Math.PI;
516-
517-
// TODO: We need to subtract the offset to the CANCoder angle.
515+
516+
//Uche suggested this but it did not work ):
517+
//CANCoderAnglesRadians[i] -= Math.toRadians(CAN_CODER_ANGLE_OFFSETS[i]);
518518
}
519519

520520
// TODO: Use the CANCoder's measurements for the PID
@@ -548,7 +548,13 @@ public void periodic() {
548548
swerveModuleState.angle.getRadians());
549549

550550
// Set the output to the pivot motor.
551+
//if(i == 0) {
551552
pivotMotor.set(power);
553+
if (DriverStation.isTeleopEnabled()) {
554+
System.out.println("i: " + i + " can: " + CANCoderAnglesRadians[i] + " angle: " + swerveModuleState.angle.getRadians());
555+
System.out.println("i: " + i + " power: " + power);
556+
}
557+
//}
552558
}
553559

554560
// We are powering the drive motor without PID because we do

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ private void controllerCheck() {
300300
try {
301301
if (xboxController == null) {
302302
xboxController = new XboxController(i);
303-
System.out.printf("controllerCheck: Found xbox controller on port %d.\n", i);
303+
//System.out.printf("controllerCheck: Found xbox controller on port %d.\n", i);
304304
continue;
305305
} else if (!xboxController.isConnected()) {
306306
xboxController = null;
307-
System.out.printf("controllerCheck: Xbox controller is disconnected.\n");
307+
//System.out.printf("controllerCheck: Xbox controller is disconnected.\n");
308308
continue;
309309
}
310310
} catch (Exception e) {
@@ -400,7 +400,7 @@ private boolean assignJoystick(Joystick j) {
400400
!secondaryJoystick.isConnected() ? "secondary joystick on port %d was disconnected".formatted(secondaryJoystick.getPort()) :
401401
"secondary joystick is connected on port %d".formatted(secondaryJoystick.getPort());
402402

403-
System.out.printf("%s: %s and %s; %s.\n", prefix, mainJoystickString, secondaryJoystickString, message);
403+
//System.out.printf("%s: %s and %s; %s.\n", prefix, mainJoystickString, secondaryJoystickString, message);
404404
}
405405
return success;
406406
}

0 commit comments

Comments
 (0)