Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Feb 8, 2024
1 parent 9cb2093 commit 11228f4
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 99 deletions.
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/arm/ArmConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public class ArmConstants {

/** Constants for the shoulder motor. */
public static class ShoulderMotorConstants {
/** Gearing between the soulder motor and the shoulder joint. */
public static final double GEARING = 51.2;

/** If true, invert the shoulder motor. */
public static final boolean IS_INVERTED = true;

/** Maximum voltage that can be applied to the shoulder motor. */
public static final double MAXIMUM_VOLTAGE = 2.0;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/frc/robot/arm/ArmFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public static ShoulderMotorIO createShoulderMotor() {
* @return an elbow motor.
*/
public static ElbowMotorIO createElbowMotor() {
if (Robot.isReal()) return new ElbowMotorIOSparkMax();

return new ElbowMotorIOSparkMax();
return new ElbowMotorIOSim();
}
}
23 changes: 23 additions & 0 deletions src/main/java/frc/robot/arm/ElbowMotorIOSim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.arm;

/** Simulated elbow motor. */
public class ElbowMotorIOSim implements ElbowMotorIO {

@Override
public void configure() {}

@Override
public void update(ElbowMotorIOValues values) {}

@Override
public void setPosition(double positionRotations) {}

@Override
public void runSetpoint(double positionRotations) {}

@Override
public void setVoltage(double volts) {}

@Override
public void stop() {}
}
84 changes: 0 additions & 84 deletions src/main/java/frc/robot/arm/ElbowMotorIOSparkMax.java

This file was deleted.

6 changes: 4 additions & 2 deletions src/main/java/frc/robot/arm/ShoulderMotorIOSparkMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public void configure() {
Configurator.configureREV(sparkMax::restoreFactoryDefaults);

Configurator.configureREV(() -> sparkMax.setIdleMode(IdleMode.kBrake));

sparkMax.setInverted(ShoulderMotorConstants.IS_INVERTED);
}

@Override
Expand All @@ -43,7 +45,7 @@ public void update(ShoulderMotorIOValues values) {

@Override
public void setPosition(double positionRotations) {
// TODO
sparkMax.getEncoder().setPosition(positionRotations * ShoulderMotorConstants.GEARING);
}

@Override
Expand Down Expand Up @@ -79,6 +81,6 @@ public void stop() {
* @return the absolute position of the shoulder in rotations.
*/
private double getPositionRotations() {
return sparkMax.getEncoder().getPosition();
return sparkMax.getEncoder().getPosition() / ShoulderMotorConstants.GEARING;
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/intake/IntakeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class IntakeFactory {
* @return a roller motor.
*/
public static RollerMotorIO createRollerMotor() {
if (Robot.isReal()) return new RollerMotorIOSparkMax();
//if (Robot.isReal()) return new RollerMotorIOSparkMax();

return new RollerMotorIOSim();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/lights/LightsFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LightsFactory {
* @return an LED controller.
*/
public static LEDControllerIO createLEDController() {
if (Robot.isReal()) return new LEDControllerIOCANdle();
//if (Robot.isReal()) return new LEDControllerIOCANdle();

return new LEDControllerIOSim();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/odometry/OdometryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OdometryFactory {
* @return a gyroscope.
*/
public static GyroscopeIO createGyroscope(CAN gyroscopeCAN, Odometry odometry) {
if (Robot.isReal()) return new GyroscopeIOPigeon2(gyroscopeCAN);
//if (Robot.isReal()) return new GyroscopeIOPigeon2(gyroscopeCAN);

return new GyroscopeIOSim(odometry);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/shooter/ShooterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static BeamBreakSensorIO createBeamBreakSensor() {
* @return a serializer motor.
*/
public static SerializerMotorIO createSerializerMotor() {
if (Robot.isReal()) return new SerializerMotorIOSparkMax();
//if (Robot.isReal()) return new SerializerMotorIOSparkMax();

return new SerializerMotorIOSim();
}
Expand All @@ -33,7 +33,7 @@ public static SerializerMotorIO createSerializerMotor() {
* @return a flywheel motor.
*/
public static FlywheelMotorIO createFlywheelMotor() {
if (Robot.isReal()) return new FlywheelMotorIOSparkMax(); // TODO
//if (Robot.isReal()) return new FlywheelMotorIOSparkMax(); // TODO

return new FlywheelMotorIOSim();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/frc/robot/swerve/SwerveFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static SwerveModuleIO createModule(SwerveModuleConfig config) {
* @return an azimuth encoder.
*/
public static AzimuthEncoderIO createAzimuthEncoder(SwerveModuleConfig config) {
if (Robot.isReal())
return new AzimuthEncoderIOCANcoder(config.moduleCAN().azimuth(), config.offset());
// if (Robot.isReal())
// return new AzimuthEncoderIOCANcoder(config.moduleCAN().azimuth(), config.offset());

return new AzimuthEncoderIOSim();
}
Expand All @@ -46,8 +46,8 @@ public static CANcoderConfiguration createAzimuthEncoderConfig() {
* @return a steer motor.
*/
public static SteerMotorIO createSteerMotor(SwerveModuleConfig config) {
if (Robot.isReal())
return new SteerMotorIOTalonFXPIDF(config.moduleCAN().steer(), config.moduleCAN().azimuth());
// if (Robot.isReal())
// return new SteerMotorIOTalonFXPIDF(config.moduleCAN().steer(), config.moduleCAN().azimuth());

return new SteerMotorIOSim();
}
Expand All @@ -58,7 +58,7 @@ public static SteerMotorIO createSteerMotor(SwerveModuleConfig config) {
* @return a drive motor.
*/
public static DriveMotorIO createDriveMotor(SwerveModuleConfig config) {
if (Robot.isReal()) return new DriveMotorIOTalonFXPID(config.moduleCAN().drive());
//if (Robot.isReal()) return new DriveMotorIOTalonFXPID(config.moduleCAN().drive());

return new DriveMotorIOSim();
}
Expand Down

0 comments on commit 11228f4

Please sign in to comment.