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

Commit d465a5a

Browse files
committed
refactor: Refactor spree.
1 parent 022ebf3 commit d465a5a

21 files changed

+40
-193
lines changed

src/main/java/frc/lib/DoubleJointedArmFeedforward.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public DoubleJointedArmFeedforward(JointConstants shoulder, JointConstants elbow
3333
this.g1 = shoulder.gearing();
3434
this.g2 = elbow.gearing();
3535

36-
B_MATRIX.set(0, 0, shoulder.torque());
37-
B_MATRIX.set(1, 1, elbow.torque());
36+
B_MATRIX.set(0, 0, shoulder.torqueNm());
37+
B_MATRIX.set(1, 1, elbow.torqueNm());
3838
B_MATRIX.set(1, 0, 0);
3939
B_MATRIX.set(0, 1, 0);
4040

41-
Kb_MATRIX.set(0, 0, shoulder.torqueLoss());
42-
Kb_MATRIX.set(1, 1, elbow.torqueLoss());
41+
Kb_MATRIX.set(0, 0, shoulder.torqueLossNm());
42+
Kb_MATRIX.set(1, 1, elbow.torqueLossNm());
4343
Kb_MATRIX.set(1, 0, 0);
4444
Kb_MATRIX.set(0, 1, 0);
4545
}

src/main/java/frc/lib/JointConstants.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public JointConstants(
5353
*
5454
* @return the torque generated by the joint's gearbox element for the feedforward matrix.
5555
*/
56-
// TODO Determine units
57-
public double torque() {
56+
public double torqueNm() {
5857
return gearing * motorCount * motor.KtNMPerAmp / motor.rOhms;
5958
}
6059

@@ -63,8 +62,7 @@ public double torque() {
6362
*
6463
* @return the torque loss due to back-emf for the feedforward matrix.
6564
*/
66-
// TODO Determine units
67-
public double torqueLoss() {
65+
public double torqueLossNm() {
6866
return gearing
6967
* gearing
7068
* motorCount

src/main/java/frc/lib/Telemetry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public static ShuffleboardLayout addColumn(ShuffleboardTab tab, String columnTit
8383
* @param component the component to make fullscreen.
8484
* @return the fullscreen component.
8585
*/
86-
// TODO
8786
public static ShuffleboardComponent makeFullscreen(ShuffleboardComponent component) {
8887
return component.withPosition(0, 0).withSize(10, 4);
8988
}

src/main/java/frc/robot/arm/ShoulderMotorIOSim.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void setSetpoint(double positionRotations, double velocityRotationsPerSec
4545

4646
@Override
4747
public void setVoltage(double volts) {
48-
// TODO
4948
this.inputVoltage = volts;
5049
}
5150
}

src/main/java/frc/robot/climber/Climber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public class Climber extends Subsystem {
2929

3030
/** Creates a new instance of the climber subsystem. */
3131
private Climber() {
32-
westElevator = new ElevatorIOSim(); // TODO
33-
eastElevator = new ElevatorIOSim(); // TODO
32+
westElevator = new ElevatorIOSim();
33+
eastElevator = new ElevatorIOSim();
3434

3535
westElevator.configure();
3636
eastElevator.configure();

src/main/java/frc/robot/climber/ClimberConstants.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@ public class ClimberConstants {
77

88
/** Constants for the elevator. */
99
public static class ElevatorConstants {
10-
/** Gearing between the elevator motor and drum. */
11-
public static final double GEARING = 25.0;
12-
13-
/** Mass of the elevator carriage in kilograms. */
14-
// TODO Does not include the mass of two WCP-0418 parts
15-
public static final double MASS = Units.lbsToKilograms(0.678);
16-
17-
/** Diameter of the drum in meters. */
18-
public static final double DRUM_DIAMETER = Units.inchesToMeters(0.908);
19-
2010
/** Minimum height of the elevator in meters. */
21-
// TODO Determine if the minimum height is above this
2211
public static final double MIN_HEIGHT = 0.0;
2312

2413
/** Maximum height of the elevator in meters. */
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package frc.robot.climber;
22

33
import frc.lib.CAN;
4-
import frc.robot.Robot;
5-
import frc.robot.RobotConstants;
6-
import frc.robot.RobotConstants.Subsystem;
74

85
/** Helper class for creating hardware for the climber subsystem. */
96
public class ClimberFactory {
@@ -14,10 +11,6 @@ public class ClimberFactory {
1411
* @return an elevator.
1512
*/
1613
public static ElevatorIO createElevator(CAN can, boolean inverted) {
17-
if (Robot.isReal() && RobotConstants.REAL_SUBSYSTEMS.contains(Subsystem.CLIMBER)) {
18-
return new ElevatorIOSparkMax(can, inverted);
19-
}
20-
2114
return new ElevatorIOSim();
2215
}
2316
}
Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
11
package frc.robot.climber;
22

3-
import edu.wpi.first.math.system.plant.DCMotor;
4-
import edu.wpi.first.wpilibj.simulation.ElevatorSim;
5-
import frc.robot.RobotConstants;
6-
import frc.robot.climber.ClimberConstants.ElevatorConstants;
7-
83
/** Simulated elevator. */
94
public class ElevatorIOSim implements ElevatorIO {
105

11-
private final DCMotor motor;
12-
13-
private final ElevatorSim elevatorSim;
14-
15-
public ElevatorIOSim() {
16-
motor = DCMotor.getNEO(1);
17-
18-
elevatorSim =
19-
new ElevatorSim(
20-
motor,
21-
ElevatorConstants.GEARING,
22-
ElevatorConstants.MASS,
23-
ElevatorConstants.DRUM_DIAMETER,
24-
ElevatorConstants.MIN_HEIGHT,
25-
ElevatorConstants.MAX_HEIGHT,
26-
false,
27-
ElevatorConstants.MIN_HEIGHT);
28-
}
6+
private double positionMeters;
297

308
@Override
319
public void configure() {}
3210

3311
@Override
3412
public void update(ElevatorIOValues values) {
35-
elevatorSim.update(RobotConstants.PERIODIC_DURATION);
36-
37-
values.positionMeters = elevatorSim.getPositionMeters();
13+
values.positionMeters = positionMeters;
3814
}
3915

4016
@Override
4117
public void setPosition(double positionMeters) {
42-
elevatorSim.setState(positionMeters, 0);
18+
this.positionMeters = positionMeters;
4319
}
4420

4521
@Override
46-
public void setVoltage(double volts) {
47-
elevatorSim.setInputVoltage(volts);
48-
}
22+
public void setVoltage(double volts) {}
4923
}

src/main/java/frc/robot/climber/ElevatorIOSparkMax.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/main/java/frc/robot/intake/IntakeConstants.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ public class IntakeConstants {
1010

1111
/** Constants for the pivot motor. */
1212
public static class PivotMotorConstants {
13-
/** Gearing between the pivot sensor and the pivot. */
14-
public static final double SENSOR_GEARING = 2.3;
15-
16-
/** Gearing between the motor and the pivot. */
17-
public static final double MOTOR_GEARING = 49 * SENSOR_GEARING;
18-
1913
/** Distance between the pivot and the far edge of the intake. */
2014
public static final double DISTANCE = Units.inchesToMeters(10.275);
2115

@@ -51,9 +45,6 @@ public static class PivotMotorConstants {
5145

5246
/** Constants for the roller motor. */
5347
public static class RollerMotorConstants {
54-
/** Gearing between the roller motor and the rollers. */
55-
public static final double GEARING = 4.5;
56-
5748
/** Velocity to apply when intaking in rotations per second. */
5849
public static final double INTAKE_VELOCITY = 1.0;
5950

0 commit comments

Comments
 (0)