Skip to content

Commit

Permalink
Merge pull request #38 from Team6083/CoralShooter-PowerDistribution
Browse files Browse the repository at this point in the history
Coral shooter power distribution
  • Loading branch information
SallyLin0907 authored Feb 12, 2025
2 parents d251bfe + 55d7433 commit cae27f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import frc.robot.lib.PowerDistribution;
import frc.robot.subsystems.CoralShooterSubsystem;


public class RobotContainer {
private final CoralShooterSubsystem coralShooterSubsystem;
private final SendableChooser<Command> autChooser;
private final PowerDistribution powerDistribution;

public RobotContainer() {
coralShooterSubsystem = new CoralShooterSubsystem();
powerDistribution = new PowerDistribution();
coralShooterSubsystem = new CoralShooterSubsystem(powerDistribution);
autChooser = AutoBuilder.buildAutoChooser();
autChooser.setDefaultOption("DoNothing", Commands.none());
SmartDashboard.putData("CoralShooterSubsystem", coralShooterSubsystem);
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/frc/robot/subsystems/CoralShooterSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@
import frc.robot.Constants.CoralShooterConstant;
import frc.robot.lib.DistanceSensor;
import frc.robot.lib.DistanceSensorInterface;
import frc.robot.lib.PowerDistribution;

public class CoralShooterSubsystem extends SubsystemBase {
/** Creates a new CoralShooterSubsystem. */

private VictorSPX coralShooterLeftMotor;
private VictorSPX coralShooterRightMotor;
private DistanceSensorInterface distanceSensor;
private PowerDistribution powerDistribution;

public CoralShooterSubsystem() {

public CoralShooterSubsystem(PowerDistribution powerDistribution) {
this.powerDistribution = powerDistribution;
coralShooterLeftMotor = new VictorSPX(CoralShooterConstant.kShooterLeftMotorChannel);
coralShooterRightMotor = new VictorSPX(CoralShooterConstant.kShooterRightMotorChannel);

distanceSensor = new DistanceSensor(Port.kOnboard);
coralShooterRightMotor.setInverted(CoralShooterConstant.kCoralShooterMotorInverted);
coralShooterLeftMotor.setInverted(CoralShooterConstant.kCoralShooterMotorInverted);
Expand All @@ -33,7 +38,12 @@ private void setMotorSpeed(double speed) {
coralShooterRightMotor.set(VictorSPXControlMode.PercentOutput, -speed);
}


public void coralShooterFastOn() { // Motor on Fast
if (powerDistribution.isCoralShooterOverCurrent()) {
setMotorSpeed(0);
return;
}
setMotorSpeed(CoralShooterConstant.kShooterMotorFastSpeed);
}

Expand Down

0 comments on commit cae27f8

Please sign in to comment.