updated dt constants, auto intaking, pathplanner
This commit is contained in:
31
src/main/java/frc/robot/Commands/autoIntaking.java
Normal file
31
src/main/java/frc/robot/Commands/autoIntaking.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package frc.robot.Commands;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.constants.IntakeConstants;
|
||||
import frc.robot.subsystems.Intake;
|
||||
|
||||
public class autoIntaking extends Command{
|
||||
private Intake m_intake;
|
||||
private BooleanSupplier m_beamBreak;
|
||||
|
||||
public autoIntaking(Intake intake, BooleanSupplier beamBreak){
|
||||
m_intake = intake;
|
||||
m_beamBreak = beamBreak;
|
||||
|
||||
addRequirements(intake);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
m_intake.intakeControl(() -> IntakeConstants.kDownAngle, () -> 1.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished(){
|
||||
if(!m_beamBreak.getAsBoolean()){
|
||||
return true;
|
||||
}else {return false;}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import edu.wpi.first.wpilibj2.command.button.Trigger;
|
||||
import frc.robot.Commands.autoIntaking;
|
||||
import frc.robot.constants.IntakeConstants;
|
||||
import frc.robot.constants.OIConstants;
|
||||
import frc.robot.constants.PhotonConstants;
|
||||
@@ -102,6 +103,7 @@ public class RobotContainer {
|
||||
|
||||
NamedCommands.registerCommand("Charge Shooter 2 Sec", shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0).withTimeout(2.0));
|
||||
NamedCommands.registerCommand("Speaker Note Shot", Commands.parallel(shooter.angleSpeedsSetpoints(() -> ShooterConstants.kShooterLoadAngle, 1.0, 1.0), indexer.shootNote(() -> 1.0)).withTimeout(2.0));
|
||||
NamedCommands.registerCommand("Auto Intake", new autoIntaking(intake, indexer::getBeamBreak).andThen(intake.intakeUpCommand()));
|
||||
|
||||
// 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
|
||||
@@ -168,17 +170,23 @@ public class RobotContainer {
|
||||
intake.setDefaultCommand(
|
||||
intake.intakeControl(
|
||||
() -> {
|
||||
if (intakeDown) {
|
||||
if (intakeDown && indexer.getBeamBreak()) {
|
||||
return IntakeConstants.kDownAngle;
|
||||
} else {
|
||||
return IntakeConstants.kUpAngle;
|
||||
}
|
||||
},
|
||||
operator::getRightY
|
||||
() -> {
|
||||
if(intakeDown && indexer.getBeamBreak()){
|
||||
return 1.0;
|
||||
}else{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
operator.povUp().onTrue(
|
||||
driver.leftTrigger().onFalse(
|
||||
new InstantCommand(
|
||||
() -> {
|
||||
intakeDown = false;
|
||||
@@ -186,7 +194,7 @@ public class RobotContainer {
|
||||
)
|
||||
);
|
||||
|
||||
operator.povDown().onTrue(
|
||||
driver.leftTrigger().onTrue(
|
||||
new InstantCommand(
|
||||
() -> {
|
||||
intakeDown = true;
|
||||
|
||||
@@ -7,7 +7,7 @@ import edu.wpi.first.math.util.Units;
|
||||
public final class DrivetrainConstants {
|
||||
// Driving Parameters - Note that these are not the maximum capable speeds of
|
||||
// the robot, rather the allowed maximum speeds
|
||||
public static final double kMaxSpeedMetersPerSecond = 4.1;
|
||||
public static final double kMaxSpeedMetersPerSecond = 5.2;
|
||||
public static final double kMaxAngularSpeed = 2 * Math.PI; // radians per second
|
||||
|
||||
public static final double kDirectionSlewRate = 4.8; // radians per second
|
||||
|
||||
@@ -49,6 +49,6 @@ public class SwerveModuleConstants {
|
||||
public static final IdleMode kDrivingMotorIdleMode = IdleMode.kBrake;
|
||||
public static final IdleMode kTurningMotorIdleMode = IdleMode.kBrake;
|
||||
|
||||
public static final int kDrivingMotorCurrentLimit = 65; // amps
|
||||
public static final int kDrivingMotorCurrentLimit = 70; // amps
|
||||
public static final int kTurningMotorCurrentLimit = 30; // amps
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package frc.robot.subsystems;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
import com.revrobotics.CANSparkMax;
|
||||
@@ -61,6 +60,29 @@ public class Intake extends SubsystemBase{
|
||||
armOffset = getIntakeAngle()-IntakeConstants.kStartingAngle;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public Command autoIntaking(BooleanSupplier beamBreak){
|
||||
return run(() -> {
|
||||
intakeRoller.set(1.0);
|
||||
|
||||
intakePivot.setVoltage(
|
||||
intakeAnglePID.calculate(
|
||||
getIntakeAngle(),
|
||||
IntakeConstants.kDownAngle
|
||||
) + intakeFeedForward.calculate(
|
||||
IntakeConstants.kDownAngle,
|
||||
0.0
|
||||
)
|
||||
);
|
||||
return isFinished(() -> {
|
||||
if(!beamBreak.getAsBoolean()){
|
||||
return true
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
public Command intakeControl(DoubleSupplier pivotAngle, DoubleSupplier intakeSpeed) {
|
||||
return run(() -> {
|
||||
intakeRoller.set(intakeSpeed.getAsDouble());
|
||||
@@ -93,35 +115,6 @@ public class Intake extends SubsystemBase{
|
||||
});
|
||||
}
|
||||
|
||||
public Command autoIntaking(BooleanSupplier beamBreak){
|
||||
return run(() -> {
|
||||
if(beamBreak.getAsBoolean()){
|
||||
intakeRoller.set(1.0);
|
||||
|
||||
intakePivot.setVoltage(
|
||||
intakeAnglePID.calculate(
|
||||
getIntakeAngle(),
|
||||
IntakeConstants.kUpAngle
|
||||
) + intakeFeedForward.calculate(
|
||||
IntakeConstants.kUpAngle,
|
||||
0.0
|
||||
)
|
||||
);
|
||||
}else{
|
||||
intakeRoller.set(0);
|
||||
intakePivot.setVoltage(
|
||||
intakeAnglePID.calculate(
|
||||
getIntakeAngle(),
|
||||
IntakeConstants.kDownAngle
|
||||
) + intakeFeedForward.calculate(
|
||||
IntakeConstants.kDownAngle,
|
||||
0.0
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Command manualPivot(DoubleSupplier pivotPower, DoubleSupplier rollerSpinny){
|
||||
return run(() ->{
|
||||
intakePivot.set(pivotPower.getAsDouble());
|
||||
|
||||
Reference in New Issue
Block a user