diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index ee88284..0c85eb6 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -66,16 +66,11 @@ public final class Constants { } public static final class DriveConstants { - public static final int DRIVE_LEFT_FRONT_CAN_ID = 2; - public static final int DRIVE_RIGHT_FRONT_CAN_ID = 4; - public static final int DRIVE_LEFT_BACK_CAN_ID = 3; - public static final int DRIVE_RIGHT_BACK_CAN_ID = 5; - public static final int DRIVE_PIGEON_ID = 6; public static final int SMARTDASHBOARD_UPDATE_FRAME = 2; } - + public static final class LEDConstants { public static final int LED_SPARK_ID = 0; diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index b7542bc..99f5cb1 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -13,7 +13,6 @@ import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.button.JoystickButton; import frc4388.robot.Constants.*; -import frc4388.robot.subsystems.Drive; import frc4388.robot.subsystems.LED; import frc4388.utility.LEDPatterns; import frc4388.utility.controller.IHandController; @@ -31,9 +30,6 @@ public class RobotContainer { private final RobotMap m_robotMap = new RobotMap(); /* Subsystems */ - private final Drive m_robotDrive = new Drive(m_robotMap.leftFrontMotor, m_robotMap.rightFrontMotor, - m_robotMap.leftBackMotor, m_robotMap.rightBackMotor, m_robotMap.driveTrain, m_robotMap.gyroDrive); - private final LED m_robotLED = new LED(m_robotMap.LEDController); /* Controllers */ @@ -48,9 +44,6 @@ public class RobotContainer { /* Default Commands */ // drives the robot with a two-axis input from the driver controller - m_robotDrive.setDefaultCommand( - new RunCommand(() -> m_robotDrive.driveWithInput(getDriverController().getLeftYAxis(), - getDriverController().getRightXAxis()), m_robotDrive)); // continually sends updates to the Blinkin LED controller to keep the lights on m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED(), m_robotLED)); } @@ -64,8 +57,6 @@ public class RobotContainer { private void configureButtonBindings() { /* Driver Buttons */ // test command to spin the robot while pressing A on the driver controller - new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON) - .whileHeld(() -> m_robotDrive.driveWithInput(0, 1)); /* Operator Buttons */ // activates "Lit Mode" diff --git a/src/main/java/frc4388/robot/RobotMap.java b/src/main/java/frc4388/robot/RobotMap.java index 3456b71..4bec615 100644 --- a/src/main/java/frc4388/robot/RobotMap.java +++ b/src/main/java/frc4388/robot/RobotMap.java @@ -14,7 +14,6 @@ import com.ctre.phoenix.sensors.PigeonIMU; import edu.wpi.first.wpilibj.Spark; import edu.wpi.first.wpilibj.drive.DifferentialDrive; -import frc4388.robot.Constants.DriveConstants; import frc4388.robot.Constants.LEDConstants; import frc4388.utility.RobotGyro; @@ -36,36 +35,6 @@ public class RobotMap { } - /* Drive Subsystem */ - public final WPI_TalonFX leftFrontMotor = new WPI_TalonFX(DriveConstants.DRIVE_LEFT_FRONT_CAN_ID); - public final WPI_TalonFX rightFrontMotor = new WPI_TalonFX(DriveConstants.DRIVE_RIGHT_FRONT_CAN_ID); - public final WPI_TalonFX leftBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_LEFT_BACK_CAN_ID); - public final WPI_TalonFX rightBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_RIGHT_BACK_CAN_ID); - public final DifferentialDrive driveTrain = new DifferentialDrive(leftFrontMotor, rightFrontMotor); - public final RobotGyro gyroDrive = new RobotGyro(new PigeonIMU(DriveConstants.DRIVE_PIGEON_ID)); - void configureDriveMotorControllers() { - - /* factory default values */ - leftFrontMotor.configFactoryDefault(); - rightFrontMotor.configFactoryDefault(); - leftBackMotor.configFactoryDefault(); - rightBackMotor.configFactoryDefault(); - - /* set back motors as followers */ - leftBackMotor.follow(leftFrontMotor); - rightBackMotor.follow(rightFrontMotor); - - /* set neutral mode */ - leftFrontMotor.setNeutralMode(NeutralMode.Brake); - rightFrontMotor.setNeutralMode(NeutralMode.Brake); - leftFrontMotor.setNeutralMode(NeutralMode.Brake); - rightFrontMotor.setNeutralMode(NeutralMode.Brake); - - /* flip input so forward becomes back, etc */ - leftFrontMotor.setInverted(false); - rightFrontMotor.setInverted(false); - leftBackMotor.setInverted(InvertType.FollowMaster); - rightBackMotor.setInverted(InvertType.FollowMaster); } } diff --git a/src/main/java/frc4388/robot/subsystems/Drive.java b/src/main/java/frc4388/robot/subsystems/DiffDrive.java similarity index 94% rename from src/main/java/frc4388/robot/subsystems/Drive.java rename to src/main/java/frc4388/robot/subsystems/DiffDrive.java index 9bbdee7..a791913 100644 --- a/src/main/java/frc4388/robot/subsystems/Drive.java +++ b/src/main/java/frc4388/robot/subsystems/DiffDrive.java @@ -20,7 +20,7 @@ import frc4388.utility.RobotTime; /** * Add your docs here. */ -public class Drive extends SubsystemBase { +public class DiffDrive extends SubsystemBase { // Put methods for controlling this subsystem // here. Call these from Commands. @@ -36,7 +36,7 @@ public class Drive extends SubsystemBase { /** * Add your docs here. */ - public Drive(WPI_TalonFX leftFrontMotor, WPI_TalonFX rightFrontMotor, WPI_TalonFX leftBackMotor, + public DiffDrive(WPI_TalonFX leftFrontMotor, WPI_TalonFX rightFrontMotor, WPI_TalonFX leftBackMotor, WPI_TalonFX rightBackMotor, DifferentialDrive driveTrain, RobotGyro gyro) { m_leftFrontMotor = leftFrontMotor; diff --git a/src/main/java/frc4388/utility/RobotUnits.java b/src/main/java/frc4388/utility/RobotUnits.java new file mode 100644 index 0000000..9e07312 --- /dev/null +++ b/src/main/java/frc4388/utility/RobotUnits.java @@ -0,0 +1,27 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc4388.utility; + +/** Aarav's good units class (better than WPILib) + * @author Aarav Shah */ + +public class RobotUnits { + // constants + + // angle conversions + public static double degreesToRadians(final double degrees) {return degrees * Math.PI / 180;} + + public static double radiansToDegrees(final double radians) {return radians / Math.PI * 180;} + + // falcon conversions + public static double falconTicksToRotations(final double ticks) {return ticks / 2048;} + + public static double falconRotationsToTicks(final double rotations) {return rotations * 2048;} + + // distance conversions + public static double metersToFeet(final double meters) {return meters * 3.28084;} + + public static double feetToMeters(final double feet) {return feet / 3.28084;} +} \ No newline at end of file