File tree 3 files changed +20
-8
lines changed
src/main/java/org/team1540/robot2024
3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 11
11
* constants are needed, to reduce verbosity.
12
12
*/
13
13
public final class Constants {
14
- public static final Mode currentMode = Robot .isReal () ? Mode .REAL : Mode .SIM ;
14
+ public static final boolean IS_COMPETITION_ROBOT = true ;
15
+ private static final Mode simMode = Mode .SIM ; // Can also be Mode.REPLAY
16
+
17
+
18
+ public static final Mode currentMode = Robot .isReal () ? Mode .REAL : simMode ;
15
19
16
20
public enum Mode {
17
21
/**
@@ -32,8 +36,14 @@ public enum Mode {
32
36
33
37
public static final double LOOP_PERIOD_SECS = 0.02 ;
34
38
39
+ public static class SwerveConfig {
40
+ public static final String CAN_BUS = IS_COMPETITION_ROBOT ? "" : "" ;
41
+ public static final int FRONT_LEFT = IS_COMPETITION_ROBOT ? 3 : 0 ;
42
+ public static final int FRONT_RIGHT = IS_COMPETITION_ROBOT ? 4 : 0 ;
43
+ public static final int BACK_LEFT = IS_COMPETITION_ROBOT ? 7 : 0 ;
44
+ public static final int BACK_RIGHT = IS_COMPETITION_ROBOT ? 1 : 0 ;
45
+ }
35
46
public static class Drivetrain {
36
- public static final String CAN_BUS = "" ;
37
47
public static final double DRIVE_GEAR_RATIO = (50.0 / 14.0 ) * (17.0 / 27.0 ) * (45.0 / 15.0 );
38
48
public static final double TURN_GEAR_RATIO = 150.0 / 7.0 ;
39
49
public static final boolean IS_TURN_MOTOR_INVERTED = true ;
Original file line number Diff line number Diff line change 8
8
import edu .wpi .first .wpilibj2 .command .Command ;
9
9
import edu .wpi .first .wpilibj2 .command .Commands ;
10
10
import edu .wpi .first .wpilibj2 .command .button .CommandXboxController ;
11
+
12
+ import org .team1540 .robot2024 .Constants .SwerveConfig ;
11
13
import org .team1540 .robot2024 .commands .FeedForwardCharacterization ;
12
14
import org .team1540 .robot2024 .commands .SwerveDriveCommand ;
13
15
import org .team1540 .robot2024 .subsystems .drive .*;
@@ -42,10 +44,10 @@ public RobotContainer() {
42
44
drivetrain =
43
45
new Drivetrain (
44
46
new GyroIONavx (),
45
- new ModuleIOTalonFX (SwerveFactory .getModuleMotors (3 , SwerveFactory .SwerveCorner .FRONT_LEFT )),
46
- new ModuleIOTalonFX (SwerveFactory .getModuleMotors (4 , SwerveFactory .SwerveCorner .FRONT_RIGHT )),
47
- new ModuleIOTalonFX (SwerveFactory .getModuleMotors (7 , SwerveFactory .SwerveCorner .BACK_LEFT )),
48
- new ModuleIOTalonFX (SwerveFactory .getModuleMotors (1 , SwerveFactory .SwerveCorner .BACK_RIGHT )));
47
+ new ModuleIOTalonFX (SwerveFactory .getModuleMotors (SwerveConfig . FRONT_LEFT , SwerveFactory .SwerveCorner .FRONT_LEFT )),
48
+ new ModuleIOTalonFX (SwerveFactory .getModuleMotors (SwerveConfig . FRONT_RIGHT , SwerveFactory .SwerveCorner .FRONT_RIGHT )),
49
+ new ModuleIOTalonFX (SwerveFactory .getModuleMotors (SwerveConfig . BACK_LEFT , SwerveFactory .SwerveCorner .BACK_LEFT )),
50
+ new ModuleIOTalonFX (SwerveFactory .getModuleMotors (SwerveConfig . BACK_RIGHT , SwerveFactory .SwerveCorner .BACK_RIGHT )));
49
51
break ;
50
52
51
53
case SIM :
Original file line number Diff line number Diff line change 8
8
import com .ctre .phoenix6 .signals .InvertedValue ;
9
9
import com .ctre .phoenix6 .signals .SensorDirectionValue ;
10
10
import edu .wpi .first .math .geometry .Rotation2d ;
11
- import org .team1540 .robot2024 .Constants ;
11
+ import static org .team1540 .robot2024 .Constants . SwerveConfig . CAN_BUS ; ;
12
12
13
13
public class SwerveFactory {
14
14
private static final double [] moduleOffsetsRots = new double []{
@@ -23,7 +23,7 @@ public class SwerveFactory {
23
23
};
24
24
25
25
public static SwerveModuleHW getModuleMotors (int id , SwerveCorner corner ) {
26
- return new SwerveModuleHW (id , corner , Constants . Drivetrain . CAN_BUS );
26
+ return new SwerveModuleHW (id , corner , CAN_BUS );
27
27
}
28
28
29
29
public enum SwerveCorner {
You can’t perform that action at this time.
0 commit comments