mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 00:38:00 -06:00
Integrate Storage Code with Firing Code
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
package frc4388.robot.commands.shooter;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
|
||||
import edu.wpi.first.wpilibj2.command.ParallelRaceGroup;
|
||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||
import frc4388.robot.commands.storage.StorageFire;
|
||||
@@ -18,7 +19,7 @@ import frc4388.robot.subsystems.Storage;
|
||||
// NOTE: Consider using this command inline, rather than writing a subclass. For more
|
||||
// information, see:
|
||||
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
|
||||
public class ShootFireGroup extends ParallelRaceGroup {
|
||||
public class ShootFireGroup extends ParallelDeadlineGroup {
|
||||
/**
|
||||
* Fires the shooter
|
||||
* @param m_shooter The Shooter subsytem
|
||||
@@ -26,11 +27,11 @@ public class ShootFireGroup extends ParallelRaceGroup {
|
||||
* @param m_storage The Storage subsytem
|
||||
*/
|
||||
public ShootFireGroup(Shooter m_shooter, ShooterAim m_shooterAim, ShooterHood m_shooterHood, Storage m_storage) {
|
||||
addCommands(
|
||||
new RunCommand(() -> m_shooter.runDrumShooterVelocityPID(m_shooter.addFireVel()), m_shooter),
|
||||
new RunCommand(() -> m_shooterHood.runAngleAdjustPID(m_shooterHood.addFireAngle()), m_shooterHood),
|
||||
super(
|
||||
new StorageFire(m_storage),
|
||||
new TrackTarget(m_shooterAim),
|
||||
new StorageFire(m_storage)
|
||||
new ShooterVelocityControlPID(m_shooter),
|
||||
new HoodPositionPID(m_shooterHood)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,10 @@ public class ShootPrepGroup extends ParallelDeadlineGroup {
|
||||
public ShootPrepGroup(Shooter m_shooter, ShooterAim m_shooterAim, ShooterHood m_shooterHood, Storage m_storage) {
|
||||
super(
|
||||
new PrepChecker(m_shooter, m_storage),
|
||||
new StoragePrep(m_storage),
|
||||
new TrackTarget(m_shooterAim),
|
||||
new ShooterVelocityControlPID(m_shooter),
|
||||
new HoodPositionPID(m_shooterHood),
|
||||
new StoragePrep(m_storage)
|
||||
new HoodPositionPID(m_shooterHood)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ManageStorage extends CommandBase {
|
||||
/* Used for intaking a ball. Keeps track off when the 2nd ball in storage has moved */
|
||||
boolean m_isStorageEmpty = true;
|
||||
|
||||
enum StorageMode{IDLE, INTAKE, RESET};
|
||||
public enum StorageMode{IDLE, INTAKE, RESET};
|
||||
StorageMode m_storageMode = StorageMode.IDLE;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ import frc4388.robot.subsystems.Storage;
|
||||
public class StorageFire extends CommandBase {
|
||||
Storage m_storage;
|
||||
/**
|
||||
* Runs the Storage at a speed
|
||||
* Runs the Storage until shoot beam is empty, then ends
|
||||
* @param storageSub The Storage subsytem
|
||||
*/
|
||||
public StorageFire(Storage storageSub) {
|
||||
@@ -40,6 +40,9 @@ public class StorageFire extends CommandBase {
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
if (m_storage.getBeamShooter()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ public class StoragePrep extends CommandBase {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
m_storage.runStorage(StorageConstants.STORAGE_SPEED);
|
||||
if (!m_storage.m_isStorageReadyToFire) {
|
||||
m_storage.runStorage(StorageConstants.STORAGE_SPEED);
|
||||
} else {
|
||||
m_storage.runStorage(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@@ -45,10 +49,10 @@ public class StoragePrep extends CommandBase {
|
||||
public boolean isFinished() {
|
||||
if (!m_storage.getBeamShooter() || (startTime + StorageConstants.STORAGE_TIMEOUT) < System.currentTimeMillis()) {
|
||||
m_storage.m_isStorageReadyToFire = true;
|
||||
return true;
|
||||
} else {
|
||||
m_storage.m_isStorageReadyToFire = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user