-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from CyberCoyotes/SZ-3-14-Schizo
Sz 3 14 schizo; fix to the auto-intake and auto-index
- Loading branch information
Showing
7 changed files
with
416 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package frc.robot; | ||
|
||
import com.ctre.phoenix6.mechanisms.swerve.SwerveRequest; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.generated.TunerConstants; | ||
import frc.robot.subsystems.IntakeSubsystem; | ||
|
||
public class ChargeIntakeCommand extends Command { | ||
|
||
CommandSwerveDrivetrain m_driveTrain; | ||
IntakeSubsystem intake; | ||
SwerveRequest newRequest; | ||
SwerveRequest oldRequest; | ||
|
||
@Override | ||
public void execute() { | ||
|
||
super.execute(); | ||
m_driveTrain.applyRequest(() -> newRequest); | ||
intake.Run(Constants.IntakeConstants.INTAKE_POWER); | ||
} | ||
|
||
public ChargeIntakeCommand(CommandSwerveDrivetrain dt, IntakeSubsystem intake, | ||
SwerveRequest.FieldCentric oldRequest) { | ||
this.oldRequest = oldRequest; | ||
this.m_driveTrain = dt; | ||
this.intake = intake; | ||
addRequirements(intake, m_driveTrain); | ||
|
||
} | ||
|
||
@Override | ||
public void initialize() { | ||
super.initialize(); | ||
|
||
double velo = TunerConstants.kSpeedAt12VoltsMps; | ||
newRequest = new SwerveRequest.RobotCentric().withVelocityY(-velo); | ||
} | ||
|
||
public ChargeIntakeCommand() { | ||
this.addRequirements(m_driveTrain); | ||
|
||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
m_driveTrain.applyRequest(() -> oldRequest); | ||
} | ||
} |
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
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,27 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexSubsystem; | ||
|
||
public class IncrementIndex extends Command { | ||
|
||
IndexSubsystem indexer; | ||
|
||
public IncrementIndex(IndexSubsystem indexer) { | ||
this.indexer = indexer; | ||
|
||
addRequirements(indexer); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
indexer.SetPower(-0.1); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
// Check if there is no note loaded. i.e. HasCargo() returns false | ||
return !indexer.HasCargo(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.