-
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.
Merge branch 'main' of https://github.com/redshiftrobotics/crescendo-…
- Loading branch information
Showing
7 changed files
with
182 additions
and
5 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
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 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.hang.Hang; | ||
|
||
public class SetHangSpeed extends Command { | ||
|
||
private final Hang hang; | ||
private final double speed; | ||
|
||
public SetHangSpeed(Hang hang, double speed) { | ||
this.hang = hang; | ||
this.speed = speed; | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
hang.setSpeed(speed); | ||
} | ||
} |
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,35 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.intake.IntakeShooter; | ||
|
||
public class SpinIntakeFlywheels extends Command { | ||
private IntakeShooter intakeShooter; | ||
private int speed; | ||
|
||
private long startTime; | ||
|
||
public SpinIntakeFlywheels(IntakeShooter intake, int speed) { | ||
intakeShooter = intake; | ||
this.speed = speed; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
startTime = System.currentTimeMillis(); | ||
intakeShooter.setFlyWheelSpeed(speed); | ||
} | ||
|
||
// @Override | ||
// public void execute() { } | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return (System.currentTimeMillis() + 1000) >= startTime; | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
// end | ||
} | ||
} |
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,10 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
public class DummyHang extends Hang { | ||
public void setSpeed(double speed) { | ||
} | ||
|
||
public boolean isAtBottom() { | ||
return false; | ||
} | ||
} |
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,9 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public abstract class Hang extends SubsystemBase { | ||
public abstract void setSpeed(double speed); | ||
|
||
public abstract boolean isAtBottom(); | ||
} |
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 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
public class RealHang extends Hang { | ||
|
||
private final CANSparkMax leftMotor; | ||
private final CANSparkMax rightMotor; | ||
|
||
private final DigitalInput limitSwitch; | ||
|
||
private double speed; | ||
|
||
public RealHang(int leftMotorID, int rightMotorID, boolean leftMotorIsInverted, boolean rightMotorIsInverted, | ||
int limitSwitchId) { | ||
leftMotor = new CANSparkMax(leftMotorID, MotorType.kBrushless); | ||
rightMotor = new CANSparkMax(rightMotorID, MotorType.kBrushless); | ||
|
||
limitSwitch = new DigitalInput(limitSwitchId); | ||
|
||
leftMotor.setInverted(leftMotorIsInverted); | ||
rightMotor.setInverted(rightMotorIsInverted); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
leftMotor.set(speed); | ||
rightMotor.set(speed); | ||
SmartDashboard.putBoolean("Is Arm at Bottom?", isAtBottom()); | ||
} | ||
|
||
public void setSpeed(double speed) { | ||
this.speed = speed; | ||
} | ||
|
||
public boolean isAtBottom() { | ||
return limitSwitch.get(); | ||
} | ||
} |