-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e962a0
commit c9cfa9f
Showing
5 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.Feeder; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.Feeder; | ||
|
||
public class FeedAmmo extends CommandBase { | ||
Feeder m_feeder; | ||
/** Creates a new FeedAmmo. */ | ||
public FeedAmmo(Feeder feeder) { | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(feeder); | ||
m_feeder = feeder; | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
m_feeder.enableFeeder(); | ||
m_feeder.enableKicker(); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
m_feeder.disableFeeder(); | ||
m_feeder.disableKicker(); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/frc/robot/commands/Flywheel/FlywheelMaintainSpeed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.Flywheel; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.Flywheel; | ||
|
||
public class FlywheelMaintainSpeed extends CommandBase { | ||
Flywheel m_flywheel; | ||
double m_speed; | ||
/** Creates a new FlywheelMaintainSpeed. */ | ||
public FlywheelMaintainSpeed(Flywheel flywheel) { | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(flywheel); | ||
m_flywheel = flywheel; | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
m_speed = m_flywheel.getVelocity(); | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
m_flywheel.setVelocity(m_speed); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return Math.abs(m_flywheel.getVelocity() - m_speed) > 10; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.ParallelRaceGroup; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.commands.Feeder.FeedAmmo; | ||
import frc.robot.commands.Feeder.PrepareAmmo; | ||
import frc.robot.commands.Flywheel.FlywheelMaintainSpeed; | ||
import frc.robot.commands.Flywheel.FlywheelToSpeed; | ||
import frc.robot.subsystems.Feeder; | ||
import frc.robot.subsystems.Flywheel; | ||
|
||
// NOTE: Consider using this command inline, rather than writing a subclass. For more | ||
// information, see: | ||
// https://docs.wpilib.org/en/stable/docs/software/commandbased/convenience-features.html | ||
public class Shoot extends SequentialCommandGroup { | ||
/** Creates a new Shoot. */ | ||
public Shoot(Flywheel flywheel, Feeder feeder) { | ||
// Add your commands in the addCommands() call, e.g. | ||
// addCommands(new FooCommand(), new BarCommand()); | ||
addCommands( | ||
new ParallelRaceGroup(new FlywheelToSpeed(flywheel, 80), new PrepareAmmo(feeder)), | ||
new ParallelRaceGroup(new FlywheelMaintainSpeed(flywheel), new FeedAmmo(feeder)) | ||
); | ||
} | ||
} |