Skip to content

Commit 32221bc

Browse files
Nummun14Strflightmight09ShmayaR
authored
Algae Commands (#17)
* added temporary algae collection logic. Need to test and need targetScoring level logic * Added algae ejection * removed unnecacery things * no errors * Added algae collection states and unload coral command * oops * oops x2 * added reverse scoring * Update AlgaeManipulationCommands.java * Logic is logiccccccccccing * lol * W * temporary * some stuff Co-Authored-By: Nummun14 <[email protected]> * added algae to reef, and no loading when robot has algae * Flippable 2.0 * :) * Fix algae problem and more * Made work * fixed algae collection ending bug * It picks it up now * Just the dropping..... * is adding a boolean event rlly that hard @Strflightmight09 ? * lol * added proc and net locationsd * ugly solutions go brrrrrrr * Commit because I'm goateaddd * processor sim works! Updated SimulatedGamePieceConstants to define PROCESSOR_LOCATION and related fields as FlippablePose3d instead of Pose3d. Adjusted references in FieldConstants and SimulationScoringHandler to use the new FlippablePose3d API. Also fixed a minor variable naming issue in Elevator and added @AutoLogOutput to atTargetState. Updated SCORE_PROCESSOR target position in ElevatorConstants. * net works * added pid controller * ver yyes * code rabbit is actually op * s * Networks * Super cool stuff * dumb stuff * no need * The commit to fix all commits * lamb duh * Update ArmElevatorConstants.java * no erros, still need to test though * Some small things racked up * Fix * Cool stuff * Remove LEDs * updated coral placing commands to use flippable arm overide command * scores algae again Co-Authored-By: Nummun14 <[email protected]> * collection works Co-Authored-By: Nummun14 <[email protected]> * no more jerking Co-Authored-By: Nummun14 <[email protected]> * no jerk Co-Authored-By: Nummun14 <[email protected]> * no erros Co-Authored-By: Nummun14 <[email protected]> --------- Co-authored-by: Strflightmight09 <[email protected]> Co-authored-by: ShmayaR <[email protected]>
1 parent 65daf99 commit 32221bc

24 files changed

+501
-177
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
package frc.trigon.robot;
77

88
import com.pathplanner.lib.auto.AutoBuilder;
9-
import edu.wpi.first.math.geometry.Pose3d;
109
import edu.wpi.first.wpilibj2.command.Command;
1110
import edu.wpi.first.wpilibj2.command.Commands;
1211
import edu.wpi.first.wpilibj2.command.InstantCommand;
1312
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
1413
import frc.trigon.robot.commands.CommandConstants;
1514
import frc.trigon.robot.commands.commandfactories.*;
15+
import frc.trigon.robot.constants.AutonomousConstants;
1616
import frc.trigon.robot.constants.CameraConstants;
1717
import frc.trigon.robot.constants.LEDConstants;
1818
import frc.trigon.robot.constants.OperatorConstants;
19-
import frc.trigon.robot.constants.PathPlannerConstants;
2019
import frc.trigon.robot.misc.objectdetectioncamera.ObjectPoseEstimator;
2120
import frc.trigon.robot.misc.simulatedfield.SimulatedGamePieceConstants;
2221
import frc.trigon.robot.misc.simulatedfield.SimulationFieldHandler;
@@ -92,21 +91,25 @@ private void bindDefaultCommands() {
9291
private void initializeGeneralSystems() {
9392
Flippable.init();
9493
LEDConstants.init();
95-
PathPlannerConstants.init();
94+
AutonomousConstants.init();
9695
}
9796

9897
private void bindControllerCommands() {
9998
OperatorConstants.RESET_HEADING_TRIGGER.onTrue(CommandConstants.RESET_HEADING_COMMAND);
100-
OperatorConstants.DRIVE_FROM_DPAD_TRIGGER.whileTrue(CommandConstants.SELF_RELATIVE_DRIVE_FROM_DPAD_COMMAND);
99+
// OperatorConstants.DRIVE_FROM_DPAD_TRIGGER.whileTrue(CommandConstants.SELF_RELATIVE_DRIVE_FROM_DPAD_COMMAND);
101100
OperatorConstants.TOGGLE_BRAKE_TRIGGER.onTrue(GeneralCommands.getToggleBrakeCommand());
102101

103-
OperatorConstants.SPAWN_CORAL_TRIGGER.onTrue(new InstantCommand(() -> SimulationFieldHandler.updateCoralSpawning(new Pose3d(ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose()))));
104-
OperatorConstants.CORAL_COLLECTION_TRIGGER.whileTrue(CoralCollectionCommands.getCoralCollectionCommand());
102+
OperatorConstants.FLOOR_ALGAE_COLLECTION_TRIGGER.toggleOnTrue(AlgaeManipulationCommands.getFloorAlgaeCollectionCommand());
103+
OperatorConstants.REEF_ALGAE_COLLECTION_TRIGGER.toggleOnTrue(AlgaeManipulationCommands.getReefAlgaeCollectionCommand());
105104

106-
OperatorConstants.EJECT_CORAL_TRIGGER.whileTrue(CoralEjectionCommands.getCoralEjectionCommand());
105+
OperatorConstants.CORAL_COLLECTION_TRIGGER.whileTrue(CoralCollectionCommands.getCoralCollectionCommand());
107106
OperatorConstants.SCORE_CORAL_LEFT_TRIGGER.whileTrue(CoralPlacingCommands.getScoreInReefCommand(false));
108107
OperatorConstants.SCORE_CORAL_RIGHT_TRIGGER.whileTrue(CoralPlacingCommands.getScoreInReefCommand(true));
108+
OperatorConstants.EJECT_CORAL_TRIGGER.whileTrue(CoralEjectionCommands.getCoralEjectionCommand());
109109

110+
OperatorConstants.SPAWN_CORAL_IN_SIMULATION_TRIGGER.onTrue(new InstantCommand(() -> SimulationFieldHandler.updateCoralSpawning(ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose())));
111+
OperatorConstants.FLIP_ARM_TRIGGER.onTrue(new InstantCommand(() -> OperatorConstants.SHOULD_FLIP_ARM_OVERRIDE = !OperatorConstants.SHOULD_FLIP_ARM_OVERRIDE));
112+
OperatorConstants.LOLLIPOP_ALGAE_TOGGLE_TRIGGER.onTrue(new InstantCommand(AlgaeManipulationCommands::toggleLollipopCollection));
110113
OperatorConstants.CLIMB_TRIGGER.toggleOnTrue(ClimbCommands.getClimbCommand());
111114
}
112115

src/main/java/frc/trigon/robot/commands/CommandConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import edu.wpi.first.wpilibj2.command.InstantCommand;
88
import frc.trigon.robot.RobotContainer;
99
import frc.trigon.robot.commands.commandfactories.GeneralCommands;
10+
import frc.trigon.robot.constants.AutonomousConstants;
1011
import frc.trigon.robot.constants.OperatorConstants;
11-
import frc.trigon.robot.constants.PathPlannerConstants;
1212
import frc.trigon.robot.subsystems.swerve.SwerveCommands;
1313
import lib.commands.CameraPositionCalculationCommand;
1414
import lib.commands.WheelRadiusCharacterizationCommand;
@@ -45,7 +45,7 @@ public class CommandConstants {
4545
() -> calculateRotationStickAxisValue(DRIVER_CONTROLLER.getRightX())
4646
),
4747
WHEEL_RADIUS_CHARACTERIZATION_COMMAND = new WheelRadiusCharacterizationCommand(
48-
PathPlannerConstants.ROBOT_CONFIG.moduleLocations,
48+
AutonomousConstants.ROBOT_CONFIG.moduleLocations,
4949
RobotContainer.SWERVE::getDriveWheelPositionsRadians,
5050
() -> RobotContainer.SWERVE.getHeading().getRadians(),
5151
(omegaRadiansPerSecond) -> RobotContainer.SWERVE.selfRelativeDriveWithoutSetpointGeneration(new ChassisSpeeds(0, 0, omegaRadiansPerSecond), null),

src/main/java/frc/trigon/robot/commands/commandclasses/CoralAutoDriveCommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import edu.wpi.first.wpilibj2.command.*;
77
import frc.trigon.robot.RobotContainer;
88
import frc.trigon.robot.commands.commandfactories.GeneralCommands;
9-
import frc.trigon.robot.constants.PathPlannerConstants;
9+
import frc.trigon.robot.constants.AutonomousConstants;
1010
import frc.trigon.robot.misc.objectdetectioncamera.ObjectPoseEstimator;
1111
import frc.trigon.robot.subsystems.swerve.SwerveCommands;
1212
import lib.utilities.flippable.FlippableRotation2d;
@@ -44,24 +44,24 @@ public static Translation2d calculateDistanceFromTrackedGamePiece() {
4444
final Translation2d robotToGamePiece = robotPose.getTranslation().minus(trackedObjectPositionOnField);
4545
var distanceFromTrackedGamePiece = robotToGamePiece.rotateBy(robotPose.getRotation().unaryMinus());
4646
Logger.recordOutput("GamePieceAutoDrive/DistanceFromTrackedGamePiece", distanceFromTrackedGamePiece);
47-
Logger.recordOutput("GamePieceAutoDrive/XDistanceFromTrackedGamePiece", PathPlannerConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.getSetpoint().position);
47+
Logger.recordOutput("GamePieceAutoDrive/XDistanceFromTrackedGamePiece", AutonomousConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.getSetpoint().position);
4848
return distanceFromTrackedGamePiece;
4949
}
5050

5151
public static Command getDriveToGamePieceCommand(Supplier<Translation2d> distanceFromTrackedGamePiece) {
5252
return new SequentialCommandGroup(
53-
new InstantCommand(() -> PathPlannerConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.reset(distanceFromTrackedGamePiece.get().getX(), RobotContainer.SWERVE.getSelfRelativeVelocity().vxMetersPerSecond)),
53+
new InstantCommand(() -> AutonomousConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.reset(distanceFromTrackedGamePiece.get().getX(), RobotContainer.SWERVE.getSelfRelativeVelocity().vxMetersPerSecond)),
5454
SwerveCommands.getClosedLoopSelfRelativeDriveCommand(
55-
() -> PathPlannerConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.calculate(distanceFromTrackedGamePiece.get().getX()),
56-
() -> PathPlannerConstants.GAME_PIECE_AUTO_DRIVE_Y_PID_CONTROLLER.calculate(distanceFromTrackedGamePiece.get().getY()),
55+
() -> AutonomousConstants.GAME_PIECE_AUTO_DRIVE_X_PID_CONTROLLER.calculate(distanceFromTrackedGamePiece.get().getX()),
56+
() -> AutonomousConstants.GAME_PIECE_AUTO_DRIVE_Y_PID_CONTROLLER.calculate(distanceFromTrackedGamePiece.get().getY()),
5757
CoralAutoDriveCommand::calculateTargetAngle
5858
)
5959
);
6060
}
6161

6262
public static boolean shouldMoveTowardsGamePiece(Translation2d distanceFromTrackedGamePiece) {
6363
return distanceFromTrackedGamePiece != null &&
64-
(distanceFromTrackedGamePiece.getNorm() > PathPlannerConstants.AUTO_COLLECTION_INTAKE_OPEN_CHECK_DISTANCE_METERS);//TODO: If intake is open
64+
(distanceFromTrackedGamePiece.getNorm() > AutonomousConstants.AUTO_COLLECTION_INTAKE_OPEN_CHECK_DISTANCE_METERS);//TODO: If intake is open
6565
}
6666

6767
public static FlippableRotation2d calculateTargetAngle() {

0 commit comments

Comments
 (0)