Skip to content

Commit 2262257

Browse files
committed
Merge branch 'main' into algae
2 parents de79737 + cfccccf commit 2262257

28 files changed

+1730
-54
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,35 @@
1717

1818
## CAN Bus
1919

20-
| Subsystem | Type | Talon | ID | CAN BUS | Comp PDP | Proto PDP | Motor | Breaker |
21-
| --------- | -------- | ------------------------- | --- | ------- | -------- | --------- | ----- | ------- |
22-
| Drive | FXS | azimuth | 0 | FD | | | Minion | |
23-
| Drive | FXS | azimuth | 1 | FD | | | Minion | |
24-
| Drive | FXS | azimuth | 2 | FD | | | Minion | |
25-
| Drive | FXS | azimuth | 3 | FD | | | Minion | |
26-
| Drive | FX | drive | 10 | FD | | | kraken | |
27-
| Drive | FX | drive | 11 | FD | | | kraken | |
28-
| Drive | FX | drive | 12 | FD | | | kraken | |
29-
| Drive | FX | drive | 13 | FD | | | kraken | |
20+
| Subsystem | Type | Talon | ID | CAN BUS | Comp PDP | Proto PDP | Motor | Breaker |
21+
| --------- | -------- | ------------------------- | --- | ------- | -------- | --------- | ------ | ------- |
22+
| Drive | FXS | azimuth | 0 | FD | | 16 | Minion | |
23+
| Drive | FXS | azimuth | 1 | FD | | 17 | Minion | |
24+
| Drive | FXS | azimuth | 2 | FD | | 6 | Minion | |
25+
| Drive | FXS | azimuth | 3 | FD | | 7 | Minion | |
26+
| Drive | FX | drive | 10 | FD | | 23 | kraken | |
27+
| Drive | FX | drive | 11 | FD | | 22 | kraken | |
28+
| Drive | FX | drive | 12 | FD | | 0 | kraken | |
29+
| Drive | FX | drive | 13 | FD | | 1 | kraken | |
3030
| Elevator | FX | elevatorMain | 20 | rio | | 21 | kraken | |
3131
| Elevator | FX | elevatorFollow | 21 | rio | | 20 | kraken | |
32-
| Biscuit | FXS | biscuit | 25 | rio | | | Minion | |
33-
| Algae | FXS | rollers | 30 | rio | | | Minion | |
34-
| Coral | FXS | wheels | 35 | rio | | | Minion | |
32+
| Biscuit | FXS | biscuit | 25 | rio | | 2 | Minion | |
33+
| Algae | FXS | algae | 30 | rio | | | Minion | |
34+
| Coral | FXS | coral | 35 | rio | | 3 | Minion | |
3535
| Funnel | FXS | rollers | 40 | rio | | | Minion | |
3636
| Climb | FX | rollers | 45 | rio | | | Minion | |
3737
| Climb | FX | pivot | 46 | rio | | | kraken | |
3838
| Climb | CANcoder | CANCoder | 47 | ri0 | | | n/a | |
3939
| - | - | rio | - | both | | 12 | | |
40-
| - | - | radio | - | - | | | | |
40+
| - | - | vrm (radio, pigeon) | - | - | | 13 | | |
4141
| - | - | custom circuit (pi power) | - | - | | | | |
4242

4343
## VRM
44-
| Device | Voltage | Current |
45-
| --------------- | ------- | ------- |
46-
| Pigeon 2 | 12 | 2 |
47-
| Ethernet Switch | 12 | 2 |
48-
| | | |
44+
| Device | Voltage | Current | ID |
45+
| --------------- | ------- | ------- | --- |
46+
| Pigeon 2 | 12 | 0.5 | 4 |
47+
| Ethernet Switch | 12 | 2 | |
48+
| | | | |
4949

5050
## Beam Breaks
5151
| Subsystem | Talon | ID | Fwd/Rev | Purpose |

src/main/java/frc/robot/Robot.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
import edu.wpi.first.wpilibj2.command.Command;
88
import edu.wpi.first.wpilibj2.command.CommandScheduler;
9+
import frc.robot.constants.BuildConstants;
910
import org.littletonrobotics.junction.LoggedRobot;
11+
import org.littletonrobotics.junction.Logger;
12+
import org.littletonrobotics.junction.networktables.NT4Publisher;
13+
import org.littletonrobotics.junction.wpilog.WPILOGWriter;
1014

1115
public class Robot extends LoggedRobot {
1216
private Command m_autonomousCommand;
@@ -17,6 +21,31 @@ public Robot() {
1721
m_robotContainer = new RobotContainer();
1822
}
1923

24+
@Override
25+
public void robotInit() {
26+
if (isReal()) {
27+
Logger.recordMetadata("ProjectName", BuildConstants.MAVEN_NAME);
28+
Logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE);
29+
Logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);
30+
Logger.recordMetadata("GitDate", BuildConstants.GIT_DATE);
31+
Logger.recordMetadata("GitBranch", BuildConstants.GIT_BRANCH);
32+
switch (BuildConstants.DIRTY) {
33+
case 0:
34+
Logger.recordMetadata("GitDirty", "All Changes Committed");
35+
break;
36+
case 1:
37+
Logger.recordMetadata("GitDirty", "Uncommitted changes");
38+
break;
39+
default:
40+
Logger.recordMetadata("GitDirty", "Unknown");
41+
break;
42+
}
43+
Logger.addDataReceiver(new WPILOGWriter("/home/lvuser/logs"));
44+
Logger.addDataReceiver(new NT4Publisher());
45+
}
46+
Logger.start();
47+
}
48+
2049
@Override
2150
public void robotPeriodic() {
2251
CommandScheduler.getInstance().run();

src/main/java/frc/robot/RobotContainer.java

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,82 @@
44

55
package frc.robot;
66

7+
import static edu.wpi.first.units.Units.Rotations;
8+
9+
import edu.wpi.first.units.measure.Angle;
710
import edu.wpi.first.wpilibj.Joystick;
811
import edu.wpi.first.wpilibj.XboxController;
912
import edu.wpi.first.wpilibj2.command.Command;
1013
import edu.wpi.first.wpilibj2.command.Commands;
1114
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
15+
import edu.wpi.first.wpilibj2.command.button.Trigger;
1216
import frc.robot.commands.algae.OpenLoopAlgaeCommand;
17+
import frc.robot.commands.coral.EnableEjectBeamCommand;
18+
import frc.robot.commands.coral.OpenLoopCoralCommand;
1319
import frc.robot.commands.drive.DriveTeleopCommand;
20+
import frc.robot.commands.elevator.JogElevatorCommand;
21+
import frc.robot.commands.elevator.ZeroElevatorCommand;
22+
import frc.robot.constants.ElevatorConstants;
23+
import frc.robot.constants.RobotConstants;
1424
import frc.robot.controllers.FlyskyJoystick;
1525
import frc.robot.subsystems.algae.AlgaeIOFX;
1626
import frc.robot.subsystems.algae.AlgaeSubsystem;
27+
import frc.robot.subsystems.coral.CoralIO;
28+
import frc.robot.subsystems.coral.CoralIOFX;
29+
import frc.robot.subsystems.coral.CoralSubsystem;
1730
import frc.robot.subsystems.drive.DriveSubsystem;
1831
import frc.robot.subsystems.drive.Swerve;
32+
import frc.robot.subsystems.elevator.ElevatorIO;
33+
import frc.robot.subsystems.elevator.ElevatorIOFX;
34+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
1935
import org.strykeforce.telemetry.TelemetryController;
2036
import org.strykeforce.telemetry.TelemetryService;
2137

2238
public class RobotContainer {
23-
private DriveSubsystem driveSubsystem;
39+
40+
private ElevatorIO elevatorIO;
41+
private ElevatorSubsystem elevatorSubsystem;
42+
43+
private final CoralIO coralIO;
44+
private final CoralSubsystem coralSubsystem;
45+
46+
private AlgaeIOFX algaeIO;
2447
private AlgaeSubsystem algaeSubsystem;
2548

2649
private Swerve swerve;
27-
private AlgaeIOFX algaeIO;
50+
private DriveSubsystem driveSubsystem;
2851

2952
private final XboxController xboxController = new XboxController(1);
3053
private final Joystick driveJoystick = new Joystick(0);
54+
3155
private final FlyskyJoystick flysky = new FlyskyJoystick(driveJoystick);
3256
private final TelemetryService telemetryService = new TelemetryService(TelemetryController::new);
3357

3458
public RobotContainer() {
35-
swerve = new Swerve();
3659
algaeIO = new AlgaeIOFX();
37-
3860
algaeSubsystem = new AlgaeSubsystem(algaeIO);
61+
62+
swerve = new Swerve();
3963
driveSubsystem = new DriveSubsystem(swerve);
4064

41-
configureBindings();
65+
coralIO = new CoralIOFX();
66+
coralSubsystem = new CoralSubsystem(coralIO);
67+
68+
elevatorIO = new ElevatorIOFX();
69+
elevatorSubsystem = new ElevatorSubsystem(elevatorIO);
70+
71+
configureTelemetry();
4272
configureDriverBindings();
73+
configureOperatorBindings();
4374
}
4475

45-
private void configureBindings() {}
76+
private void configureTelemetry() {
77+
telemetryService.register(driveSubsystem);
78+
telemetryService.register(coralSubsystem);
79+
telemetryService.register(algaeSubsystem);
80+
telemetryService.register(elevatorSubsystem);
81+
telemetryService.start();
82+
}
4683

4784
private void configureDriverBindings() {
4885
driveSubsystem.setDefaultCommand(
@@ -51,6 +88,35 @@ private void configureDriverBindings() {
5188
}
5289

5390
private void configureOperatorBindings() {
91+
// Stop Coral
92+
new JoystickButton(xboxController, XboxController.Button.kB.value)
93+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, 0));
94+
95+
// Intake Coral
96+
new JoystickButton(xboxController, XboxController.Button.kY.value)
97+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
98+
.onTrue(new EnableEjectBeamCommand(false, coralSubsystem));
99+
100+
// Eject Coral
101+
new JoystickButton(xboxController, XboxController.Button.kA.value)
102+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
103+
.onTrue(new EnableEjectBeamCommand(true, coralSubsystem));
104+
105+
// Move Elevator
106+
new Trigger((() -> xboxController.getRightY() > RobotConstants.kJoystickDeadband))
107+
.onTrue(
108+
new JogElevatorCommand(
109+
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmount, Rotations)));
110+
new Trigger((() -> xboxController.getRightY() < -RobotConstants.kJoystickDeadband))
111+
.onTrue(
112+
new JogElevatorCommand(
113+
elevatorSubsystem, Angle.ofBaseUnits(-ElevatorConstants.kJogAmount, Rotations)));
114+
115+
// Zero Elevator
116+
new JoystickButton(xboxController, XboxController.Button.kX.value)
117+
.onTrue(new ZeroElevatorCommand(elevatorSubsystem));
118+
119+
// Algae Buttons
54120
new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value)
55121
.onTrue(new OpenLoopAlgaeCommand(algaeSubsystem, 0.5));
56122
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package frc.robot.commands.coral;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.coral.CoralSubsystem;
5+
6+
public class EnableEjectBeamCommand extends InstantCommand {
7+
private CoralSubsystem coralSubsystem;
8+
private Boolean enable;
9+
10+
public EnableEjectBeamCommand(Boolean enable, CoralSubsystem coralSubsystem) {
11+
this.coralSubsystem = coralSubsystem;
12+
this.enable = enable;
13+
}
14+
15+
@Override
16+
public void initialize() {
17+
coralSubsystem.enableEjectBeam(enable);
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package frc.robot.commands.coral;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.coral.CoralSubsystem;
5+
6+
public class OpenLoopCoralCommand extends InstantCommand {
7+
private CoralSubsystem coralSubsystem;
8+
private double pct;
9+
10+
public OpenLoopCoralCommand(CoralSubsystem coralSubsystem, double pct) {
11+
this.coralSubsystem = coralSubsystem;
12+
this.pct = pct;
13+
}
14+
15+
@Override
16+
public void initialize() {
17+
coralSubsystem.setPct(pct);
18+
}
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package frc.robot.commands.elevator;
2+
3+
import edu.wpi.first.units.measure.Angle;
4+
import edu.wpi.first.wpilibj2.command.Command;
5+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
6+
7+
public class JogElevatorCommand extends Command {
8+
9+
private ElevatorSubsystem elevatorSubsystem;
10+
private Angle positionChange;
11+
12+
public JogElevatorCommand(ElevatorSubsystem elevatorSubsystem, Angle positionChange) {
13+
this.elevatorSubsystem = elevatorSubsystem;
14+
this.positionChange = positionChange;
15+
}
16+
17+
@Override
18+
public void initialize() {
19+
elevatorSubsystem.setPosition(elevatorSubsystem.getPosition().plus(positionChange));
20+
}
21+
22+
@Override
23+
public boolean isFinished() {
24+
return elevatorSubsystem.isFinished();
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package frc.robot.commands.elevator;
2+
3+
import edu.wpi.first.units.measure.Angle;
4+
import edu.wpi.first.wpilibj2.command.Command;
5+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
6+
7+
public class SetElevatorPositionCommand extends Command {
8+
9+
private ElevatorSubsystem elevatorSubsystem;
10+
private Angle position;
11+
12+
public SetElevatorPositionCommand(ElevatorSubsystem elevatorSubsystem, Angle position) {
13+
this.elevatorSubsystem = elevatorSubsystem;
14+
this.position = position;
15+
}
16+
17+
@Override
18+
public void initialize() {
19+
elevatorSubsystem.setPosition(position);
20+
}
21+
22+
@Override
23+
public boolean isFinished() {
24+
return elevatorSubsystem.isFinished();
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package frc.robot.commands.elevator;
2+
3+
import edu.wpi.first.wpilibj2.command.Command;
4+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
5+
6+
public class ZeroElevatorCommand extends Command {
7+
8+
private ElevatorSubsystem elevatorSubsystem;
9+
10+
public ZeroElevatorCommand(ElevatorSubsystem elevatorSubsystem) {
11+
this.elevatorSubsystem = elevatorSubsystem;
12+
}
13+
14+
@Override
15+
public void initialize() {
16+
elevatorSubsystem.zero();
17+
}
18+
}

src/main/java/frc/robot/constants/BiscuitConstants.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,44 @@
1919
import edu.wpi.first.units.measure.Angle;
2020

2121
public class BiscuitConstants {
22-
// FIXME These are all wrong right now because we don't have any actual info
22+
// These are all wrong right now because we don't have any actual info
2323

2424
public static Angle kZero = Rotations.of(42); // Will need to be experimentally determined
2525
public static int talonID = 3;
2626
public static double kCloseEnough = 2137473647; // This is a little out of wack.
2727
public static final Angle kMaxFwd = Rotations.of(100);
2828
public static final Angle kMaxRev = Rotations.of(-100);
29-
// public static Angle Level1 = ;
29+
30+
// Setpoints
31+
// Idle
32+
public static final Angle kStowSetpoint = Rotations.of(0.0);
33+
public static final Angle kFunnelSetpoint = Rotations.of(0.0);
34+
public static final Angle kPrestageSetpoint = Rotations.of(0.0);
35+
36+
// Algae removal
37+
public static final Angle kL2AlgaeSetpoint = Rotations.of(0.0);
38+
public static final Angle kL3AlgaeSetpoint = Rotations.of(0.0);
39+
40+
public static final Angle kL2AlgaeRemovalSetpoint = Rotations.of(0.0);
41+
public static final Angle kL3AlgaeRemovalSetpoint = Rotations.of(0.0);
42+
43+
public static final Angle kSafeAlgaeRemovalSetpoint = Rotations.of(0.0);
44+
public static final Angle kSafeAlgaeRemovalRotateSetpoint = Rotations.of(0.0);
45+
46+
// Coral score
47+
public static final Angle kL1CoralSetpoint = Rotations.of(0.0);
48+
public static final Angle kL2CoralSetpoint = Rotations.of(0.0);
49+
public static final Angle kL3CoralSetpoint = Rotations.of(0.0);
50+
public static final Angle kL4CoralSetpoint = Rotations.of(0.0);
51+
52+
// Algae obtaining
53+
public static final Angle kFloorAlgaeSetpoint = Rotations.of(0.0);
54+
public static final Angle kMicAlgaeSetpoint = Rotations.of(0.0);
55+
public static final Angle kHpAlgaeSetpoint = Rotations.of(0.0);
56+
57+
// Algae scoring
58+
public static final Angle kProcessorSetpoint = Rotations.of(0.0);
59+
public static final Angle kBargeSetpoint = Rotations.of(0.0);
3060

3161
// Disables the TalonFXS by setting it's voltage to zero. Not very shocking.
3262
public static VoltageConfigs disableTalon() {

0 commit comments

Comments
 (0)