-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/primo4586/RobotCode2024 int…
…o PreperForShooting # Conflicts: # src/main/java/frc/robot/Constants.java
- Loading branch information
Showing
11 changed files
with
259 additions
and
22 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
25 changes: 25 additions & 0 deletions
25
src/main/java/frc/robot/commands/IntakeCommands/CollectToFeeder.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,25 @@ | ||
// 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.IntakeCommands; | ||
|
||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import frc.robot.Constants.IntakeConstants; | ||
import frc.robot.commands.IntakeArmCommands.MoveIntakeArmToDegree; | ||
import frc.robot.commands.feederCommands.FeedUntilNote; | ||
|
||
// 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 CollectToFeeder extends ParallelCommandGroup { | ||
/** Creates a new MoveIntakeToCollectNote. */ | ||
public CollectToFeeder() { | ||
// Add your commands in the addCommands() call, e.g. | ||
// addCommands(new FooCommand(), new BarCommand()); | ||
addCommands( | ||
new IntakeSetSpeed(IntakeConstants.getNoteSpeed), | ||
new FeedUntilNote(), | ||
new MoveIntakeArmToDegree(IntakeConstants.GroundIntakePose)); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/frc/robot/commands/TrapArmCommands/goInSwitchCommand.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,37 @@ | ||
// 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.TrapArmCommands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.TrapArmSubsystem; | ||
|
||
public class goInSwitchCommand extends Command { | ||
private final TrapArmSubsystem trapArmSubsystem= TrapArmSubsystem.getInstance(); | ||
/** Creates a new goInSwitch. */ | ||
public goInSwitchCommand() { | ||
addRequirements(trapArmSubsystem); | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// 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() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
trapArmSubsystem.setSpeed(0); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return trapArmSubsystem.getInnerSwitch(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/frc/robot/commands/TrapArmCommands/goOutSwitchCommand.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,37 @@ | ||
// 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.TrapArmCommands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.TrapArmSubsystem; | ||
|
||
public class goOutSwitchCommand extends Command { | ||
private final TrapArmSubsystem trapArmSubsystem= TrapArmSubsystem.getInstance(); | ||
/** Creates a new goOutSwitch. */ | ||
public goOutSwitchCommand() { | ||
addRequirements(trapArmSubsystem); | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// 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() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
trapArmSubsystem.setSpeed(0); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return trapArmSubsystem.getOuterSwitch(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/frc/robot/commands/TrapArmCommands/setSpeedCommand.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,25 @@ | ||
// 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.TrapArmCommands; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import frc.robot.subsystems.TrapArmSubsystem; | ||
|
||
public class setSpeedCommand extends InstantCommand { | ||
private final TrapArmSubsystem trapArmSubsystem= TrapArmSubsystem.getInstance(); | ||
double speed; | ||
/** Creates a new setSpeedCommand. */ | ||
public setSpeedCommand(double speed) { | ||
addRequirements(trapArmSubsystem); | ||
this.speed = speed; | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
trapArmSubsystem.setSpeed(speed); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/frc/robot/commands/feederCommands/FeedUntilNote.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,39 @@ | ||
// 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.feederCommands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.Constants.FeederConstants; | ||
import frc.robot.subsystems.FeederSubsystem; | ||
|
||
public class FeedUntilNote extends Command { | ||
private final FeederSubsystem feederSubsystem = FeederSubsystem.getInstance(); | ||
/** Creates a new FeedUntilNote. */ | ||
public FeedUntilNote() { | ||
addRequirements(feederSubsystem); | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
feederSubsystem.setSpeed(FeederConstants.getNoteSpeed);} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
feederSubsystem.setSpeed(0); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return feederSubsystem.getSwitch(); | ||
} | ||
} |
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,56 @@ | ||
// 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.subsystems; | ||
|
||
import com.ctre.phoenix.motorcontrol.ControlMode; | ||
import com.ctre.phoenix.motorcontrol.can.TalonSRX; | ||
import static frc.robot.Constants.TrapArmConstants.*; | ||
|
||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class TrapArmSubsystem extends SubsystemBase { | ||
private TalonSRX m_TrapMotor; | ||
DigitalInput innerSwitch; | ||
DigitalInput outerSwitch; | ||
|
||
private static TrapArmSubsystem instance; | ||
|
||
public static TrapArmSubsystem getInstance() { | ||
if (instance == null) { | ||
instance = new TrapArmSubsystem(); | ||
} | ||
return instance; | ||
} | ||
|
||
/** Creates a new TrapArmSubsystem. */ | ||
private TrapArmSubsystem() { | ||
this.m_TrapMotor = new TalonSRX(ArmMotorID); | ||
this.innerSwitch = new DigitalInput(InnerSwitchID); | ||
this.outerSwitch = new DigitalInput(OuterSwitchID); | ||
} | ||
|
||
|
||
public void setSpeed(double speed){ | ||
m_TrapMotor.set(ControlMode.PercentOutput,speed); | ||
} | ||
|
||
|
||
public boolean getInnerSwitch(){ | ||
return innerSwitch.get(); | ||
} | ||
|
||
|
||
public boolean getOuterSwitch(){ | ||
return outerSwitch.get(); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |