Skip to content

Commit

Permalink
Merge pull request #17 from StuyPulse/se/7-19
Browse files Browse the repository at this point in the history
Se/7 19
  • Loading branch information
IanShiii authored Jul 20, 2024
2 parents b47f795 + 43ebeb4 commit 1e92b66
Show file tree
Hide file tree
Showing 26 changed files with 321 additions and 195 deletions.
31 changes: 20 additions & 11 deletions src/main/java/com/stuypulse/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import com.stuypulse.robot.commands.BuzzController;
import com.stuypulse.robot.commands.arm.ArmToAmp;
import com.stuypulse.robot.commands.arm.ArmToFeed;
import com.stuypulse.robot.commands.arm.ArmToFerry;
import com.stuypulse.robot.commands.arm.ArmToLobFerry;
import com.stuypulse.robot.commands.arm.ArmToLowFerry;
import com.stuypulse.robot.commands.arm.ArmToPreClimb;
import com.stuypulse.robot.commands.arm.ArmToSpeaker;
import com.stuypulse.robot.commands.arm.ArmToSpeakerHigh;
import com.stuypulse.robot.commands.arm.ArmToSpeakerLow;
import com.stuypulse.robot.commands.arm.ArmToStow;
import com.stuypulse.robot.commands.arm.ArmWaitUntilAtTarget;
import com.stuypulse.robot.commands.auton.DoNothingAuton;
Expand All @@ -15,12 +17,11 @@
import com.stuypulse.robot.commands.intake.IntakeStop;
import com.stuypulse.robot.commands.shooter.ShooterAcquireFromIntake;
import com.stuypulse.robot.commands.shooter.ShooterAutoShoot;
import com.stuypulse.robot.commands.swerve.SwerveDriveAlignedFerryAndShoot;
import com.stuypulse.robot.commands.swerve.SwerveDriveAlignedSpeakerAndShoot;
import com.stuypulse.robot.commands.swerve.SwerveDriveDrive;
import com.stuypulse.robot.commands.swerve.SwerveDriveDriveAlignedFerry;
import com.stuypulse.robot.commands.swerve.SwerveDriveDriveAlignedLowFerry;
import com.stuypulse.robot.commands.swerve.SwerveDriveDriveAlignedSpeakerHigh;
import com.stuypulse.robot.commands.swerve.SwerveDriveXMode;
import com.stuypulse.robot.commands.swerve.SwerveDriveDriveAlignedSpeaker;
import com.stuypulse.robot.commands.swerve.SwerveDriveDriveAlignedSpeakerLow;
import com.stuypulse.robot.commands.swerve.SwerveDriveSeedFieldRelative;
import com.stuypulse.robot.constants.Ports;
import com.stuypulse.robot.constants.Settings;
Expand All @@ -41,6 +42,7 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.ConditionalCommand;
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;

public class RobotContainer {
Expand Down Expand Up @@ -126,15 +128,22 @@ private void configureButtonBindings() {
);

driver.getRightBumper()
.onTrue(new SwerveDriveDriveAlignedSpeaker(driver));
.onTrue(new SwerveDriveDriveAlignedSpeakerLow(driver));

driver.getTopButton()
.onTrue(new ArmToSpeaker());
// .onTrue(new SwerveDriveDriveAlignedSpeaker(driver));
.onTrue(new ConditionalCommand(
new ArmToSpeakerHigh(),
new ArmToSpeakerLow(),
() -> Arm.getInstance().getState() == Arm.State.SPEAKER_LOW));

driver.getLeftButton().onTrue(new ArmToAmp());

driver.getRightButton()
.onTrue(new ArmToFerry());
// .onTrue(new SwerveDriveAlignedFerry(driver));
.onTrue(new ConditionalCommand(
new ArmToLobFerry(),
new ArmToLowFerry(),
() -> Arm.getInstance().getState() == Arm.State.LOW_FERRY));

driver.getBottomButton().onTrue(new ArmToFeed());

driver.getDPadUp().onTrue(new ArmToPreClimb());
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/stuypulse/robot/commands/arm/ArmToFerry.java

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/com/stuypulse/robot/commands/arm/ArmToLobFerry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stuypulse.robot.commands.arm;

import com.stuypulse.robot.subsystems.arm.Arm;

public class ArmToLobFerry extends ArmSetState{

public ArmToLobFerry(){
super(Arm.State.LOB_FERRY);
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/stuypulse/robot/commands/arm/ArmToLowFerry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stuypulse.robot.commands.arm;

import com.stuypulse.robot.subsystems.arm.Arm;

public class ArmToLowFerry extends ArmSetState{

public ArmToLowFerry(){
super(Arm.State.LOW_FERRY);
}
}
10 changes: 0 additions & 10 deletions src/main/java/com/stuypulse/robot/commands/arm/ArmToSpeaker.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stuypulse.robot.commands.arm;

import com.stuypulse.robot.subsystems.arm.Arm;

public class ArmToSpeakerHigh extends ArmSetState{

public ArmToSpeakerHigh(){
super(Arm.State.SPEAKER_HIGH);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.stuypulse.robot.commands.arm;

import com.stuypulse.robot.subsystems.arm.Arm;

public class ArmToSpeakerLow extends ArmSetState{

public ArmToSpeakerLow(){
super(Arm.State.SPEAKER_LOW);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ public void initialize() {
case AMP:
CommandScheduler.getInstance().schedule(new ShooterScoreAmp());
break;
case SPEAKER:
case SPEAKER_HIGH:
CommandScheduler.getInstance().schedule(new ShooterScoreSpeaker());
break;
case FERRY:
case SPEAKER_LOW:
CommandScheduler.getInstance().schedule(new ShooterScoreSpeaker());
break;
case LOW_FERRY:
CommandScheduler.getInstance().schedule(new ShooterFerry());
break;
case LOB_FERRY:
CommandScheduler.getInstance().schedule(new ShooterFerry());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public class ShooterFerry extends SequentialCommandGroup {

public ShooterFerry() {
addCommands(
new ShooterSetRPM(Settings.Shooter.FERRY),
new ShooterWaitForTarget().withTimeout((Settings.Shooter.MAX_WAIT_TO_REACH_TARGET))
.andThen(new ShooterFeederShoot())
new ShooterWaitForTarget().withTimeout((Settings.Shooter.MAX_WAIT_TO_REACH_TARGET)),
new ShooterFeederShoot()
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stuypulse.robot.commands.shooter;

import com.stuypulse.robot.constants.Settings;
import com.stuypulse.robot.subsystems.shooter.Shooter;

import edu.wpi.first.wpilibj2.command.InstantCommand;
Expand All @@ -12,7 +13,7 @@ public ShooterScoreAmp() {
addCommands(
new ShooterFeederDeacquire(),
new WaitUntilCommand(() -> !Shooter.getInstance().hasNote()),
new WaitUntilCommand(1),
new WaitUntilCommand(Settings.Arm.SHOULD_RETURN_TO_FEED_TIME.get()),
new InstantCommand(() -> Shooter.getInstance().feederStop())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public class ShooterScoreSpeaker extends SequentialCommandGroup {

public ShooterScoreSpeaker() {
addCommands(
new ShooterSetRPM(Settings.Shooter.SPEAKER),
new ShooterWaitForTarget().withTimeout(Settings.Shooter.MAX_WAIT_TO_REACH_TARGET)
.andThen(new ShooterFeederShoot())
new ShooterWaitForTarget().withTimeout(Settings.Shooter.MAX_WAIT_TO_REACH_TARGET),
new ShooterFeederShoot()
);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public SwerveDriveDrive(Gamepad driver) {
@Override
public void execute() {
swerve.setControl(drive.withVelocityX(speed.get().y)
.withVelocityY(speed.get().x)
.withVelocityY(-speed.get().x)
.withRotationalRate(turn.get())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ protected double getAngleError() {
@Override
public void execute() {
swerve.setControl(
drive.withVelocityX(velocity.get().x)
.withVelocityY(velocity.get().y)
drive.withVelocityX(velocity.get().y)
.withVelocityY(-velocity.get().x)
.withRotationalRate(
angleVelocity.get()
+ controller.update(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.stuypulse.robot.commands.swerve;

import com.stuypulse.robot.Robot;
import com.stuypulse.robot.constants.Field;
import com.stuypulse.robot.subsystems.swerve.SwerveDrive;
import com.stuypulse.stuylib.input.Gamepad;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;


public class SwerveDriveDriveAlignedLobFerry extends SwerveDriveDriveAligned {

public SwerveDriveDriveAlignedLobFerry(Gamepad driver) {
super(driver);
}

// returns pose of close amp corner
private Translation2d getAmpCornerPose() {
Translation2d targetPose = Robot.isBlue()
? new Translation2d(0.0, Field.WIDTH - 1.5)
: new Translation2d(0.0, 1.5);

return targetPose;
}

@Override
protected Rotation2d getTargetAngle() {
return SwerveDrive.getInstance().getPose().getTranslation().minus(getAmpCornerPose()).getAngle().plus(Rotation2d.fromDegrees(180));
}

@Override
protected double getDistanceToTarget() {
return SwerveDrive.getInstance().getPose().getTranslation().getDistance(getAmpCornerPose());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import edu.wpi.first.math.geometry.Translation2d;


public class SwerveDriveDriveAlignedFerry extends SwerveDriveDriveAligned {
public class SwerveDriveDriveAlignedLowFerry extends SwerveDriveDriveAligned {

public SwerveDriveDriveAlignedFerry(Gamepad driver) {
public SwerveDriveDriveAlignedLowFerry(Gamepad driver) {
super(driver);
}

Expand Down
Loading

0 comments on commit 1e92b66

Please sign in to comment.