Skip to content

Commit

Permalink
reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelLesirge committed Dec 15, 2024
1 parent dc860a6 commit eb0e1ef
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 67 deletions.
4 changes: 2 additions & 2 deletions shuffleboardLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"autoPopulate": true,
"autoPopulatePrefix": "SmartDashboard/",
"widgetPane": {
"gridSize": 128.0,
"gridSize": 109.0,
"showGrid": true,
"hgap": 8.0,
"vgap": 8.0,
"titleType": 0,
"titleType": 1,
"tiles": {
"1,0": {
"size": [
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private Constants() {}

public static final boolean SHOW_SYS_ID_AUTOS = false;

private static RobotType robotType = RobotType.TEST_BOT;
private static RobotType robotType = RobotType.SIM_BOT;

public static RobotType getRobot() {
if (RobotBase.isReal() && robotType == RobotType.SIM_BOT) {
Expand Down
68 changes: 27 additions & 41 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.Constants.Mode;
import frc.robot.Constants.RobotType;
import frc.robot.subsystems.cannon.CannonConstants;
import frc.robot.subsystems.cannon.CannonIO;
import frc.robot.subsystems.cannon.CannonIOHardware;
import frc.robot.subsystems.cannon.CannonIOSim;
import frc.robot.subsystems.cannon.FiringTube;
import frc.robot.subsystems.dashboard.DriverDashboard;
import frc.robot.subsystems.drive.Drive;
import frc.robot.subsystems.drive.DriveConstants;
Expand All @@ -36,14 +31,19 @@
import frc.robot.subsystems.drive.controllers.SpeedController;
import frc.robot.subsystems.drive.controllers.SpeedController.SpeedLevel;
import frc.robot.subsystems.drive.controllers.TeleopDriveController;
import frc.robot.subsystems.gateway.GatewayIO;
import frc.robot.subsystems.gateway.GatewayIOHardware;
import frc.robot.subsystems.gateway.GatewayIOSim;
import frc.robot.subsystems.gateway.GatewayTank;
import frc.robot.subsystems.reservoir.ReservoirIO;
import frc.robot.subsystems.reservoir.ReservoirIOHardware;
import frc.robot.subsystems.reservoir.ReservoirIOSim;
import frc.robot.subsystems.reservoir.ReservoirTank;
import frc.robot.subsystems.pneumatics.cannon.CannonConstants;
import frc.robot.subsystems.pneumatics.cannon.CannonIO;
import frc.robot.subsystems.pneumatics.cannon.CannonIOHardware;
import frc.robot.subsystems.pneumatics.cannon.CannonIOSim;
import frc.robot.subsystems.pneumatics.cannon.FiringTube;
import frc.robot.subsystems.pneumatics.gateway.GatewayIO;
import frc.robot.subsystems.pneumatics.gateway.GatewayIOHardware;
import frc.robot.subsystems.pneumatics.gateway.GatewayIOSim;
import frc.robot.subsystems.pneumatics.gateway.GatewayTank;
import frc.robot.subsystems.pneumatics.reservoir.ReservoirIO;
import frc.robot.subsystems.pneumatics.reservoir.ReservoirIOHardware;
import frc.robot.subsystems.pneumatics.reservoir.ReservoirIOSim;
import frc.robot.subsystems.pneumatics.reservoir.ReservoirTank;
import frc.robot.subsystems.vision.AprilTagVision;
import frc.robot.utility.NormUtil;
import frc.robot.utility.OverrideSwitch;
Expand Down Expand Up @@ -324,13 +324,12 @@ private void configureDriverControllerBindings() {
boolean includeDiagonalPOV = true;
for (int pov = 0; pov < 360; pov += includeDiagonalPOV ? 45 : 90) {

// POV angles are in Clock Wise degrees, needs to be flipped to get correct
// rotation2d
// POV angles are in Clock Wise degrees, needs to be flipped to get correct rotation2d
final Rotation2d angle = Rotation2d.fromDegrees(-pov);
final String name = String.format("%d\u00B0", pov);

// While the POV is being pressed and we are not in angle control mode, set the
// chassis speeds to the Cos and Sin of the angle
// While the POV is being pressed and we are not in angle control mode, set the chassis
// speeds to the Cos and Sin of the angle
driverXbox
.pov(pov)
.and(useAngleControlMode)
Expand All @@ -344,8 +343,8 @@ private void configureDriverControllerBindings() {
drive::stop)
.withName(String.format("DriveRobotRelative %s", name)));

// While the POV is being pressed and we are angle control mode
// Start by resetting the controller and setting the goal angle to the pov angle
// While the POV is being pressed and we are angle control mode. Start by resetting the
// controller and setting the goal angle to the pov angle
driverXbox
.pov(pov)
.and(useAngleControlMode.negate())
Expand All @@ -358,8 +357,8 @@ private void configureDriverControllerBindings() {
})
.withName(String.format("PrepareLockedHeading %s", name)));

// Then if the button is held for more than 0.2 seconds, drive forward at the
// angle once the chassis reaches it
// Then if the button is held for more than 0.2 seconds, drive forward at the angle once the
// chassis reaches it
driverXbox
.pov(pov)
.debounce(0.2)
Expand All @@ -378,8 +377,8 @@ private void configureDriverControllerBindings() {
})
.withName(String.format("ForwardLockedHeading %s", name)));

// Then once the pov is let go, if we are not at the angle continue turn to it,
// while also accepting x and y input to drive. Cancel once we get turn request
// Then once the pov is let go, if we are not at the angle continue turn to it, while also
// accepting x and y input to drive. Cancel once we get turn request
driverXbox
.pov(pov)
.and(useAngleControlMode.negate())
Expand All @@ -401,8 +400,7 @@ private void configureDriverControllerBindings() {
.withName(String.format("DriveLockedHeading %s", name)));
}

// While X is held down go into stop and go into the cross position to resistent
// movement,
// While X is held down go into stop and go into the cross position to resistent movement,
// then once X button is let go put modules forward
driverXbox
.x()
Expand All @@ -411,9 +409,8 @@ private void configureDriverControllerBindings() {
.startEnd(drive::stopUsingBrakeArrangement, drive::stopUsingForwardArrangement)
.withName("StopWithX"));

// When be is pressed stop the drivetrain then idle it, cancelling all incoming
// commands.
// Also do this when robot is disabled
// When be is pressed stop the drivetrain then idle it, cancelling all incoming commands. Also
// do this when robot is disabled
driverXbox
.b()
.or(RobotModeTriggers.disabled())
Expand All @@ -424,23 +421,17 @@ private void configureDriverControllerBindings() {
.withInterruptBehavior(InterruptionBehavior.kCancelIncoming)
.withName("StopCancel"));

// When right (Gas) trigger is held down or left stick (sprint) is pressed, put
// in boost
// (fast) mode
// When right (Gas) trigger is held down put in boost (fast) mode
driverXbox
.rightTrigger(0.5)
// .or(driverXbox.leftStick())
.whileTrue(
Commands.startEnd(
() -> speedController.pushSpeedLevel(SpeedLevel.BOOST),
() -> speedController.removeSpeedLevel(SpeedLevel.BOOST)));

// When left (Brake) trigger is held down or right stick (crouch) is pressed put
// in precise
// (slow) mode
// When left (Brake) trigger is held down put in precise (slow) mode
driverXbox
.leftTrigger(0.5)
// .or(driverXbox.rightStick())
.whileTrue(
Commands.startEnd(
() -> speedController.pushSpeedLevel(SpeedLevel.PRECISE),
Expand Down Expand Up @@ -473,11 +464,6 @@ private void configureOperatorControllerBindings() {
if (operatorController instanceof CommandXboxController) {
final CommandXboxController operatorXbox = (CommandXboxController) operatorController;

// TODO, this should be the other way around, pressing buttons should put
// command that pause
// the filling and in general more commands should be used to greatly simplify
// code.

operatorXbox
.y()
.whileTrue(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.utility;
package frc.robot.subsystems.pneumatics;

import java.util.function.BooleanSupplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

public class CannonConstants {
public static final double FIRE_TUBE_OPEN_TIME_SECONDS = 0.2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

import org.littletonrobotics.junction.AutoLog;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

public class CannonIOSim implements CannonIO {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.cannon;
package frc.robot.subsystems.pneumatics.cannon;

import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.wpilibj.Timer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

public class GatewayConstants {
private GatewayConstants() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

import java.util.function.BooleanSupplier;
import org.littletonrobotics.junction.AutoLog;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

import edu.wpi.first.wpilibj.PneumaticsModuleType;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.hardwareWrappers.Transducer;
import frc.robot.subsystems.pneumatics.hardwareWrappers.Transducer;

public class GatewayIOHardware implements GatewayIO {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

import frc.robot.Constants;
import java.util.function.BooleanSupplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.DriverStation;
Expand Down Expand Up @@ -159,6 +159,9 @@ public void unpause() {
// --- Status String ---

public String getStatusString() {
if (DriverStation.isDisabled()) {
return "Pause: Disabled";
}
if (isFilling()) {
return String.format("Filling to %.2f PSI (End threshold)", controller.getUpperThreshold());
} else if (!controller.isOn() && getPressure() > controller.getLowerThreshold()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.gateway;
package frc.robot.subsystems.pneumatics.gateway;

import edu.wpi.first.math.interpolation.InterpolatingDoubleTreeMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.hardwareWrappers;
package frc.robot.subsystems.pneumatics.hardwareWrappers;

import edu.wpi.first.wpilibj.DigitalGlitchFilter;
import edu.wpi.first.wpilibj.DigitalInput;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.hardwareWrappers;
package frc.robot.subsystems.pneumatics.hardwareWrappers;

import edu.wpi.first.wpilibj.Relay;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.hardwareWrappers;
package frc.robot.subsystems.pneumatics.hardwareWrappers;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.wpilibj.AnalogInput;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.reservoir;
package frc.robot.subsystems.pneumatics.reservoir;

public class ReservoirConstants {
private ReservoirConstants() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.reservoir;
package frc.robot.subsystems.pneumatics.reservoir;

import java.util.function.BooleanSupplier;
import org.littletonrobotics.junction.AutoLog;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package frc.robot.subsystems.reservoir;
package frc.robot.subsystems.pneumatics.reservoir;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Relay.Direction;
import edu.wpi.first.wpilibj.Relay.Value;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.hardwareWrappers.Transducer;
import frc.robot.subsystems.pneumatics.hardwareWrappers.Transducer;

public class ReservoirIOHardware implements ReservoirIO {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.reservoir;
package frc.robot.subsystems.pneumatics.reservoir;

import frc.robot.Constants;
import java.util.function.BooleanSupplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.reservoir;
package frc.robot.subsystems.pneumatics.reservoir;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand Down Expand Up @@ -129,6 +129,9 @@ public void unpause() {
// --- Status String ---

public String getStatusString() {
if (DriverStation.isDisabled()) {
return "Pause: Disabled";
}
if (isFilling()) {
return String.format("Filling to %.2f PSI (End threshold)", controller.getUpperThreshold());
} else if (!controller.isOn() && getPressure() > controller.getLowerThreshold()) {
Expand Down

0 comments on commit eb0e1ef

Please sign in to comment.