Skip to content

Commit 7f723ac

Browse files
committed
algae pivot chagnes
1 parent 217b10e commit 7f723ac

File tree

6 files changed

+39
-201
lines changed

6 files changed

+39
-201
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
66
import edu.wpi.first.wpilibj2.command.Command;
77
import edu.wpi.first.wpilibj2.command.InstantCommand;
8+
import frc.robot.algaepivot.AlgaeSubsystem;
9+
import frc.robot.algaepivot.AlgaeSubsystem.State;
10+
import frc.robot.algaepivot.commands.AlgaePivotCommands;
811
import frc.robot.driver.DriverXbox;
912
import frc.robot.drivetrain.CommandSwerveDrivetrain;
1013
import frc.robot.drivetrain.TunerConstants;
1114
import static edu.wpi.first.units.Units.*;
1215
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
13-
import frc.robot.subsystems.AlgaeSubsystem;
16+
import frc.robot.algaepivot.commands.*;
1417

1518
/**
1619
* This class is where the bulk of the robot should be declared. Since Command-based is a
@@ -30,8 +33,6 @@ public class RobotContainer {
3033

3134
public static SendableChooser<Command> mAutonChooser;
3235

33-
private final AlgaeSubsystem algaeSubsystem = AlgaeSubsystem.getInstance();
34-
3536
public RobotContainer() {
3637
setDefaultCommands();
3738
}
@@ -47,16 +48,16 @@ public Command getAutonomousCommand() {
4748

4849
public void setDefaultCommands() {
4950
final var driver = DriverXbox.getInstance();
50-
// CommandSwerveDrivetrain.getInstance().setDefaultCommand(
51-
// CommandSwerveDrivetrain.getInstance().applyRequest(() ->
52-
// drive.withVelocityX(driver.getDriveTranslation().getX() * kMaxVelocity) // Drive forward with negative Y (forward)
53-
// .withVelocityY(driver.getDriveTranslation().getY() * kMaxVelocity) // Drive left with negative X (left)
54-
// .withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity) // Drive counterclockwise with negative X (left)
55-
// )
56-
// );
57-
58-
//algaeSubsystem.setDefaultCommand(new AlgaeSubsystem.DefaultCommand(algaeSubsystem, () -> (driver.getRightX() + 1) / 2.0));
59-
algaeSubsystem.setDefaultCommand(new AlgaeSubsystem.DefaultCommand(algaeSubsystem, () -> 1.0));
51+
CommandSwerveDrivetrain.getInstance().setDefaultCommand(
52+
CommandSwerveDrivetrain.getInstance().applyRequest(() ->
53+
drive.withVelocityX(driver.getDriveTranslation().getX() * kMaxVelocity) // Drive forward with negative Y (forward)
54+
.withVelocityY(driver.getDriveTranslation().getY() * kMaxVelocity) // Drive left with negative X (left)
55+
.withRotationalRate(driver.getDriveRotation() * kMaxAngularVelocity) // Drive counterclockwise with negative X (left)
56+
)
57+
);
58+
AlgaeSubsystem.getInstance().setDefaultCommand(
59+
new AlgaeSubsystem.DefaultCommand()
60+
);
6061
}
6162
}
6263

src/main/java/frc/robot/algaepivot/AlgaeShooterPivot.java

Lines changed: 0 additions & 151 deletions
This file was deleted.

src/main/java/frc/robot/subsystems/AlgaeSubsystem.java renamed to src/main/java/frc/robot/algaepivot/AlgaeSubsystem.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package frc.robot.subsystems;
1+
package frc.robot.algaepivot;
22

33
import com.ctre.phoenix6.configs.CANcoderConfiguration;
44
import com.ctre.phoenix6.configs.MagnetSensorConfigs;
@@ -62,6 +62,8 @@ public enum State {
6262
private final ArmFeedforward mFFController;
6363
private final ProfiledPIDController mPPIDController;
6464

65+
public static State kLastState;
66+
6567
private AlgaeSubsystem() {
6668
mTalonPivot = new TalonFX(Settings.kTalonPivotID);
6769
mTalonPivot.getConfigurator().apply(new TalonFXConfiguration().withMotorOutput(new MotorOutputConfigs()
@@ -91,6 +93,7 @@ public static AlgaeSubsystem getInstance() {
9193
}
9294

9395
public void setTargetState(State targetState) {
96+
kLastState = targetState;
9497
setTargetPosition(targetState.pos);
9598
}
9699

@@ -124,24 +127,24 @@ public void periodic() {
124127
}
125128

126129
public static class DefaultCommand extends Command {
127-
private final Supplier<Double> percentSupplier;
128-
private final AlgaeSubsystem subsystem;
129130

130-
public DefaultCommand(AlgaeSubsystem subsystem, Supplier<Double> percentSupplier) {
131-
this.percentSupplier = percentSupplier;
132-
this.subsystem = subsystem;
133-
addRequirements(subsystem);
131+
public DefaultCommand() {
132+
134133
}
135134

136135
@Override
137-
public void execute() {
138-
var tp = getTargetPosition();
139-
subsystem.setTargetPosition(tp);
136+
public void initialize() {
137+
if (kLastState == State.kTuck) {
138+
AlgaeSubsystem.getInstance().setTargetState(State.kTuck);
139+
} else {
140+
AlgaeSubsystem.getInstance().setTargetState(State.kStow);
141+
}
140142
}
141143

142-
private Rotation2d getTargetPosition() {
143-
return Rotation2d.fromRotations((Settings.kMaxPos.getRotations() - Settings.kMinPos.getRotations()) * percentSupplier.get() + Settings.kMinPos.getRotations());
144+
@Override
145+
public void execute() {
144146
}
147+
145148
}
146149

147150
}

src/main/java/frc/robot/algaepivot/commands/AlgaePivotCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import edu.wpi.first.math.geometry.Rotation2d;
66
import edu.wpi.first.wpilibj2.command.Command;
7-
import frc.robot.subsystems.AlgaeSubsystem;
7+
import frc.robot.algaepivot.AlgaeSubsystem;
88

99
public class AlgaePivotCommands {
1010
public static Command setAlgaePivotAngle(AlgaeSubsystem.State state) {

src/main/java/frc/robot/algaepivot/commands/SetAngleAlgaePivot.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,25 @@
66

77
import edu.wpi.first.math.geometry.Rotation2d;
88
import edu.wpi.first.wpilibj2.command.Command;
9-
import frc.robot.algaepivot.AlgaeShooterPivot;
10-
import frc.robot.subsystems.AlgaeSubsystem;
9+
import frc.robot.algaepivot.AlgaeSubsystem;
1110

1211
public class SetAngleAlgaePivot extends Command {
1312
AlgaeSubsystem mAlgaeSubsystem;
1413
AlgaeSubsystem.State targetState;
15-
16-
// public enum State {
17-
// kFloorIntake(Rotation2d.fromRotations(-0.04)),
18-
// kReefIntake(Rotation2d.fromRotations(0)),
19-
// kScore(Rotation2d.fromRotations(0.15)),
20-
// kStow(Rotation2d.fromRotations(0.23));
21-
22-
// State(Rotation2d pos) {
23-
// this.pos = pos;
24-
// }
25-
// public final Rotation2d pos;
26-
27-
28-
// public double getDegrees() {
29-
// return pos.getDegrees();
30-
// }
31-
32-
// public Rotation2d getRotation2d() {
33-
// return pos;
34-
// }
35-
// }
14+
Rotation2d targetAngle;
3615

3716
public SetAngleAlgaePivot(AlgaeSubsystem.State targetState) {
3817
mAlgaeSubsystem = AlgaeSubsystem.getInstance();
3918
this.targetState = targetState;
4019
addRequirements(mAlgaeSubsystem);
4120
}
4221

22+
// public SetAngleAlgaePivot(Supplier<Rotation2d> angleSupplier) {
23+
// mAlgaeSubsystem = AlgaeSubsystem.getInstance();
24+
// targetAngle = angle;
25+
// addRequirements(mAlgaeSubsystem);
26+
// }
27+
4328
@Override
4429
public void initialize() {
4530
mAlgaeSubsystem.setTargetPosition(targetState.pos);

src/main/java/frc/robot/driver/DriverXbox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import frc.robot.algaeflywheel.AlgaeFlyWheel;
1919
import frc.robot.algaeflywheel.commands.AlgaeFlyWheelCommands;
2020
import frc.robot.algaeflywheel.commands.SetVelocityAlgaeFlyWheel;
21+
import frc.robot.algaepivot.AlgaeSubsystem;
2122
import frc.robot.algaepivot.commands.AlgaePivotCommands;
2223
import frc.robot.algaepivot.commands.SetAngleAlgaePivot;
2324
import frc.robot.drivetrain2.Drivetrain;
2425
import frc.robot.indexer.commands.IndexerCommands;
25-
import frc.robot.subsystems.AlgaeSubsystem;
2626

2727

2828
public class DriverXbox extends XboxGamepad {

0 commit comments

Comments
 (0)