Skip to content

Commit

Permalink
DCMP Final Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbit-Git committed Apr 17, 2023
1 parent 8a33c2d commit fe52fd0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static final class Drivetrain {
public static final int SHOULDER_MOTOR_SLAVE = 51;
public static final int SHOULDER_ENCODER = 0;
//public static final double SHOULDER_ENCODER_OFFSET = 0.542;
public static final double SHOULDER_ENCODER_OFFSET = 0.139;
public static final double SHOULDER_ENCODER_OFFSET = 0.095;
public static final double SHOULDER_GEAR_RATIO = (11.0 / 52.0) * (30.0 / 68.0) * (12.0 / 60.0);
public static final double SHOULDER_MANUAL_OVERRIDE_RANGE = 20.0;
public static final double MAX_SHOULDER_ANGLE = 90.0;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ private void configureButtonBindings() {
new Trigger(() -> operatorController.getRightTriggerAxis() > 0.05)
.whileTrue(new ManualPutdownCommand(intakeSubsystem, () -> operatorController.getRightTriggerAxis()));

left_controller.button(2).whileTrue(new StrafeAlign(m_drivetrainSubsystem, vision, left_controller::getX, left_controller::getY));
//left_controller.button(2).whileTrue(new StrafeAlign(m_drivetrainSubsystem, vision, left_controller::getX, left_controller::getY));
right_controller.button(1).whileTrue(new ManualPutdownCommand(intakeSubsystem, () -> 1.0));
left_controller.button(3).whileTrue(new InstantCommand( () -> m_drivetrainSubsystem.lockWheels = true)).whileFalse( new InstantCommand( () -> m_drivetrainSubsystem.lockWheels = false));
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/autos/ConeHighAndDriveAuto.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ConeHighAndDriveAuto(DrivetrainSubsystem dt, ShoulderSubsystem shoulder,
StateMachine sm) {

addCommands(new ConeScoreHighAuto(dt, shoulder, shoulderWristMessenger, wrist, arm, intake, armMessenger, ledSubsystem, sm),
new Drive(dt, 8.0, 0.0)
new Drive(dt, 8.2, 0.0)
.raceWith(new ShoulderHoldCommand(shoulder, armMessenger, () -> 0.0))
.raceWith(new WristHoldCommand(wrist, () -> 0.0))
.raceWith(new ArmHoldCommand(arm))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void end(boolean interruptible) {

@Override
public boolean isFinished() {
return this.timer.getTimeDeltaSec() > 1.0;
return this.timer.getTimeDeltaSec() > 0.3;
}


Expand Down
20 changes: 20 additions & 0 deletions src/main/java/frc/robot/subsystems/DrivetrainSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class DrivetrainSubsystem extends SubsystemBase {

private ChassisSpeeds m_chassisSpeeds = new ChassisSpeeds(0.0, 0.0, 0.0);

public boolean lockWheels;

//private SwerveDriveOdometry2022 odometry = new SwerveDriveOdometry2022(m_kinematics, getGyroscopeRotation(), new Pose2d(2.3, 4.5, Rotation2d.fromDegrees(0)));
private SwerveDriveOdometry2022 odometry = new SwerveDriveOdometry2022(m_kinematics, getGyroscopeRotation(), new Pose2d(2.3, 1.5, Rotation2d.fromDegrees(0)));

Expand All @@ -93,6 +95,8 @@ public class DrivetrainSubsystem extends SubsystemBase {
public OrbitPID driveRotPID;

public DrivetrainSubsystem() {
lockWheels = false;

ShuffleboardTab tab = Shuffleboard.getTab("Drivetrain");

m_frontLeftModule = Mk4iSwerveModuleHelper.createNeo(
Expand Down Expand Up @@ -203,6 +207,22 @@ public OrbitPID getDrivePID() {
@Override
public void periodic() {
SwerveModuleState[] states = m_kinematics.toSwerveModuleStates(m_chassisSpeeds);

//SwerveModuleState[] xstates = new SwerveModuleState[4];
//xstates[0] = new SwerveModuleState

if(lockWheels) {
for(int i = 0; i < 4; i++) {
states[i].speedMetersPerSecond = 0.0;
}

states[0].angle = Rotation2d.fromDegrees(45.0);
states[1].angle = Rotation2d.fromDegrees(-45.0);
states[2].angle = Rotation2d.fromDegrees(-45.0);
states[3].angle = Rotation2d.fromDegrees(45.0);
}


SwerveDriveKinematics.desaturateWheelSpeeds(states, MAX_VELOCITY_METERS_PER_SECOND); // this was normalizeWheelSpeeds but WPILib doesn't like that

m_frontLeftModule.set(states[0].speedMetersPerSecond / MAX_VELOCITY_METERS_PER_SECOND * MAX_VOLTAGE, states[0].angle.getRadians());
Expand Down

0 comments on commit fe52fd0

Please sign in to comment.