Named Commands and calculated feedforwards

This commit is contained in:
2024-02-27 10:47:44 -05:00
parent 3fec792691
commit cd28d8211f
15 changed files with 120 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ import frc.robot.subsystems.Shooter;
public class AmpHandoff extends ParallelCommandGroup{
AmpHandoff(Indexer indexer, Shooter shooter){
addCommands(indexer.shootNote(null), shooter.ampHandoff());
addCommands(indexer.shootNote(1), shooter.ampHandoff());
}
}

View File

@@ -8,6 +8,6 @@ import frc.robot.subsystems.Shooter;
public class SpeakerShot extends ParallelCommandGroup{
SpeakerShot(Indexer indexer, Shooter shooter){
addCommands(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 0, 0), indexer.shootNote(() -> 1.0));
addCommands(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 0, 0), indexer.shootNote( 1.0));
}
}

View File

@@ -21,6 +21,7 @@ import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
@@ -87,7 +88,8 @@ public class RobotContainer {
climber = new Climber(shooter.getShooterAngle());
NamedCommands.registerCommand("Charge Shooter", shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 1.0, 1.0));
NamedCommands.registerCommand("Speake Note Shot", Commands.parallel(shooter.angleSpeedsSetpoints(ShooterConstants.kShooterLoadAngle, 1.0, 1.0), indexer.shootNote(1.0)));
// An example Named Command, doesn't need to remain once we start actually adding real things
// ALL Named Commands need to be defined AFTER subsystem initialization and BEFORE auto/controller configuration
@@ -143,7 +145,7 @@ public class RobotContainer {
climber.setDefaultCommand(climber.stop());
indexer.setDefaultCommand(indexer.shootNote(operator::getRightTriggerAxis));
indexer.setDefaultCommand(indexer.shootNote(operator.getRightTriggerAxis()));
driver.povCenter().onFalse(
drivetrain.driveCardinal(
@@ -210,7 +212,7 @@ public class RobotContainer {
driver.leftBumper().toggleOnTrue(intake.intakeDownCommand());
operator.y().onTrue(climber.setSpeedWithSupplier(operator::getRightTriggerAxis));
operator.y().whileTrue(Commands.parallel(climber.setSpeedWithSupplier(operator::getRightTriggerAxis), shooter.climbState()));
}

View File

@@ -47,5 +47,5 @@ public final class DrivetrainConstants {
public static final boolean kGyroReversed = true;
public static final double kRobotStartOffset = 90;
public static final double kRobotStartOffset = 0;
}

View File

@@ -13,8 +13,8 @@ public class IntakeConstants {
public static final double kDIntake = 0;
public static final double kSFeedForward = 0;
public static final double kGFeedForward = 0;
public static final double kVFeedForward = 0;
public static final double kGFeedForward = 1.11;
public static final double kVFeedForward = 0.73;
public static final double kStartingAngle = Math.toRadians(105.0);
public static final double kUpAngle = Math.toRadians(90.0);

View File

@@ -22,8 +22,8 @@ public class ShooterConstants {
public static final double kPivotConversion = 1/(40.0*(28.0/15.0));
public static final double kSShooterPivotFF = 0.0;
public static final double kGShooterPivotFF = 0.0;
public static final double kVShooterPivotFF = 0.0;
public static final double kGShooterPivotFF = 0.33;
public static final double kVShooterPivotFF = 1.44;
public static final double kMaxPivotSpeed = 0.0;
public static final double kMaxPivotAcceleration = 0.0;

View File

@@ -49,9 +49,9 @@ public class Indexer extends SubsystemBase{
});
}
public Command shootNote(DoubleSupplier indexerSpeed){
public Command shootNote(double indexerSpeed){
return run(() -> {
indexerMotor.set(indexerSpeed.getAsDouble());
indexerMotor.set(indexerSpeed);
});
}