Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
480eb86
i would try it if i had an xbox crontroller but for now it might work
themehdev Feb 17, 2026
efc7713
its being rlly wierd but ill fix it later
themehdev Feb 17, 2026
dd7cd94
kk I got it working just it needs some tuning on the hang time
themehdev Feb 18, 2026
4fa0eb4
updated max speed and fixed things from sim
themehdev Feb 18, 2026
cdc89d7
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 18, 2026
0cb7fed
commented tracking mode out
themehdev Feb 18, 2026
d002a06
added delay to shot so db can rotate correctly
themehdev Feb 18, 2026
2395d26
Commented stuff, got rid of base shoot command, updated hangtime cons…
themehdev Feb 19, 2026
8b00a78
saved some lines, added a bunch of comments (more things to think about)
themehdev Feb 19, 2026
4291534
fixed hood
themehdev Feb 19, 2026
e3468af
updated constants to be more correct
themehdev Feb 19, 2026
e6a4200
took out comments
themehdev Feb 21, 2026
8bc4fa7
moved things around, same functionality
themehdev Feb 23, 2026
ea6145b
moved more things around, pretty clean now :)
themehdev Feb 23, 2026
33f8f6b
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 24, 2026
d284e2e
fixed merge conflicts
themehdev Feb 24, 2026
8edc55b
removed unused imports
themehdev Feb 24, 2026
b17254b
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 26, 2026
d234bee
fixing bad merge
themehdev Feb 26, 2026
f44e3ec
made it so literally there is no added complexity when shooting not o…
themehdev Feb 26, 2026
07c6746
added ferrying (NEEDS TESTING)
themehdev Feb 26, 2026
4096400
removed unused imports
themehdev Feb 26, 2026
76d8d71
updated for more code reusability
themehdev Feb 27, 2026
956f4c2
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 27, 2026
8711ff8
kk it builds again
themehdev Feb 27, 2026
ad98cf7
remove unused imports
themehdev Feb 27, 2026
af0c70f
fixed things with merge
themehdev Feb 27, 2026
5e33948
GUYS IT TOTALLY WORKED
themehdev Feb 28, 2026
85089b6
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 28, 2026
ffd19fb
fixed merge crappiness
themehdev Feb 28, 2026
cb1ff39
Merge branch 'main' into michael-shooting-while-moving
themehdev Feb 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@

package frc.robot;

import static edu.wpi.first.units.Units.Inches;

import java.util.Set;

import edu.wpi.first.apriltag.AprilTagFieldLayout;
import edu.wpi.first.apriltag.AprilTagFields;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.units.measure.Distance;
import edu.wpi.first.wpilibj.Alert;
import edu.wpi.first.wpilibj.Alert.AlertType;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.RobotBase;
import frc.robot.subsystems.shooter.ShooterConstants;

/**
* This class defines the runtime mode used by AdvantageKit. The mode is always "real" when running
Expand All @@ -39,9 +45,32 @@ public final class Constants {
private static final RobotType robotType = RobotType.SIMBOT;

public static final boolean spawnLessFuelInSim = true;
public static final boolean shootOnMove = true; // if true, we will allow the driver to shoot while moving, but with reduced max speed. if false, we will not allow the driver to shoot while moving.
//change to 0 if it really doesnt work, bc the db velocity will go to 0 and the target will just be the hub
//but I think it will work so yeah trust me butch <insert prayge hare>
public static final double shootOnMoveMaxSpeed = 2.0/5.0;
public static final double aimOnMoveMaxSpeed = 2.0/3.0; // obsolete rn, but change if we ever add a aim mode again

public static class DriveConstants {
public static final double slowModeJoystickMultiplier = 0.4;

public static final Distance fieldLength = Inches.of(651.22);
public static final Distance fieldWidth = Inches.of(317.69);

public static final Distance allianceZoneBlue = Inches.of(156.61);
public static final Distance allianceZoneRed = fieldLength.minus(allianceZoneBlue);

public static final Translation2d blueLeftFerryTarget = new Translation2d(allianceZoneBlue.div(2.0), fieldWidth.times(5.0/6.0));
public static final Translation2d blueRightFerryTarget = new Translation2d(allianceZoneBlue.div(2.0), fieldWidth.times(1.0/6.0));
public static final Translation2d redLeftFerryTarget = new Translation2d(fieldLength.minus(allianceZoneBlue.div(2.0)), fieldWidth.times(5.0/6.0));
public static final Translation2d redRightFerryTarget = new Translation2d(fieldLength.minus(allianceZoneBlue.div(2.0)), fieldWidth.times(1.0/6.0));
public static Translation2d getHubTranslation(Alliance alliance){
return (
alliance == Alliance.Blue
? ShooterConstants.Positions.blueHubPose
: ShooterConstants.Positions.redHubPose
);
}
}

public static class FieldConstants {
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import frc.robot.subsystems.shooter.HoodIOServo;
import frc.robot.subsystems.shooter.HoodIOSim;
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.shooter.RobotCommands;
import frc.robot.subsystems.shooter.ShooterIO;
import frc.robot.subsystems.shooter.ShooterIOSim;
import frc.robot.subsystems.shooter.ShooterIOTalonFX;
Expand Down Expand Up @@ -250,7 +249,6 @@ public RobotContainer() {
configureBindings();
configureDriveBindings();
}

// Bind robot actions to commands here.
private void configureBindings() {
// Manually deploying and undeploying the intake.
Expand All @@ -270,15 +268,22 @@ private void configureBindings() {
)
);

// While the right trigger is held, we will shoot into the hub or ferry.
gamepad_.rightTrigger().whileTrue(RobotCommands.shoot(shooter_, hopper_, drivebase_));


// When the hopper isnt shooting, set it to run its idle velocity.
// hopper_.setDefaultCommand(hopper_.idleScrambler());

// When the shooter isnt shooting, get it ready to shoot.
shooter_.setDefaultCommand(shooter_.awaitShooting(drivebase_::getPose));
shooter_.setDefaultCommand(shooter_.awaitShooting(drivebase_::getPose, drivebase_::getVirtualTarget));
// while in alliance zone, point drivebase at virtual target, but still allow translational driving
//lowkey we are not gonna need this but like maybe so idk imma just keep it

// While the right trigger is held, we will shoot into the hub.
// i wish i knew if this shoot command would interrrupt the other aim command, so this is kind of a "just in case", but if it is unnesecary it will be removed.
//CHANGE BACK TO RIGHT TRIGGER!
// we might want to limit the acceleration on this while shooting, but idk how to do that and hopefully it wont matter too much.
// just realized we could interrupt this with POV driving, but we would still be shooting, so we might want to create a block for that, but this too probably wont come up that much and i think i am not that numb-skulled to actually do this so idk
gamepad_.rightTrigger().whileTrue(
shooter_.shootCmd(drivebase_, hopper_, gamepad_, Constants.shootOnMove)
);

//While the A button is held, the intake will run the eject sequence. If it the intake is stowed, it will also deploy it.
gamepad_.a().whileTrue(intake_.ejectSequence());
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/frc/robot/commands/drive/DriveCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.Constants;
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.FieldConstants;
import frc.robot.Constants.Mode;
import frc.robot.subsystems.drive.Drive;
import frc.robot.subsystems.shooter.ShooterConstants;
import frc.robot.util.MapleSimUtil;
import frc.robot.util.VirtualTarget;

public class DriveCommands {
private static final double kStoppedVelocity = 0.15 ;
Expand Down Expand Up @@ -238,6 +242,45 @@ public static Command joystickDriveAtAngle(
// Reset PID controller when command starts
.beforeStarting(() -> angleController.reset(drive.getRotation().getRadians()));
}

public static Command pointAtTarget(Drive drive, CommandXboxController gamepad, Supplier<Translation2d> target, boolean shootOnMove){
return joystickDriveAtAngle(
drive,
() -> shootOnMove ? -gamepad.getLeftY() * Constants.shootOnMoveMaxSpeed : 0.0,
() -> shootOnMove ? -gamepad.getLeftX() * Constants.shootOnMoveMaxSpeed : 0.0,
() -> {
Logger.recordOutput("Drive/Target", target.get());
var translation = target.get().minus(drive.getPose().getTranslation());
var rotation = new Rotation2d(translation.getX(), translation.getY());

return rotation;
});
}

private static Translation2d getTarget(Drive drive) {
Translation2d target;

boolean blueDS = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Blue;

boolean robotInAllianceZone = blueDS ?
drive.getPose().getMeasureX().lt(DriveConstants.allianceZoneBlue):
drive.getPose().getMeasureX().gt(DriveConstants.allianceZoneRed);

if(robotInAllianceZone){
target = DriveConstants.getHubTranslation(DriverStation.getAlliance().orElse(Alliance.Blue));
}else if(drive.getPose().getMeasureY().gt(DriveConstants.fieldWidth.div(2.0))){
target = blueDS ? DriveConstants.blueLeftFerryTarget : DriveConstants.redLeftFerryTarget ;
}else{
target = blueDS ? DriveConstants.blueRightFerryTarget : DriveConstants.redRightFerryTarget ;
}

return target;
}

// make sure this isnt bad with intellisense later
public static Command pointAtShootingTarget(Drive drive, CommandXboxController gamepad, boolean shootOnMove){
return pointAtTarget(drive, gamepad, () -> (shootOnMove ? VirtualTarget.getVirtualTargetFromTarget(drive, getTarget(drive), ShooterConstants.hangTimeOnShot) : getTarget(drive)), shootOnMove);
}

/**
* Measures the velocity feedforward constants for the drive motors.
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/frc/robot/subsystems/drive/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// GNU General Public License for more details.

package frc.robot.subsystems.drive;

import static edu.wpi.first.units.Units.MetersPerSecond;
import static edu.wpi.first.units.Units.Volts;

Expand Down Expand Up @@ -61,9 +60,12 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.Constants;
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.Mode;
import frc.robot.subsystems.shooter.ShooterConstants;
import frc.robot.generated.CompTunerConstants;
import frc.robot.util.LocalADStarAK;
import frc.robot.util.VirtualTarget;

public class Drive extends SubsystemBase {
// These Constants should be the same for every drivebase, so just use the comp bot constants.
Expand Down Expand Up @@ -219,10 +221,8 @@ public void periodic() {
for (var module : modules) {
module.stop();
}
}

// Log empty setpoint states when disabled
if (DriverStation.isDisabled()) {
// Log empty setpoint states when disabled
Logger.recordOutput("SwerveStates/Setpoints", new SwerveModuleState[] {});
Logger.recordOutput("SwerveStates/SetpointsOptimized", new SwerveModuleState[] {});
}
Expand Down Expand Up @@ -466,6 +466,12 @@ public double getMaxAngularSpeedRadPerSec() {
public RobotConfig getPathplannerConfig() {
return PP_CONFIG;
}



public Translation2d getVirtualTarget() {
return VirtualTarget.getVirtualTargetFromTarget(this, DriveConstants.getHubTranslation(DriverStation.getAlliance().orElse(Alliance.Blue)), ShooterConstants.hangTimeOnShot);
}

/** Returns an array of module translations. */
public Translation2d[] getModuleTranslations() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/subsystems/hopper/Hopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public Command feed(AngularVelocity feeder, AngularVelocity scrambler) {
* Runs the scrambler at its active speed, and the feeder.
* @return
*/

// idk how to do this but like we should run the feeder motor backwards for about 0.5 secs to get arid of the balls stuck in there after we stop shooting
// theoretically this would improve consistency
public Command forwardFeed() {
return feed(HopperConstants.scramblerShootingVelocity, HopperConstants.feedingVelocity);
}
Expand Down
Loading
Loading