Skip to content

Commit

Permalink
Added Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StewardHail3433 committed Jan 14, 2024
1 parent a24bea6 commit d184efb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
10 changes: 7 additions & 3 deletions src/main/java/frc/robot/commands/ShooterBaseCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,26 @@ public ShooterBaseCommand(ShooterBase shooter, DoubleSupplier rightTriggerAxis)
}
@Override
public void initialize() {
// create speed entry under Shooter tab as a number sider with min = -1 and max = 1
// Create speed entry under Shooter tab as a number sider with min = -1 and max = 1
speedEntry = tab.add("speed", 0).withWidget(BuiltInWidgets.kNumberSlider)
.withProperties(Map.of("min", -1, "max", 1)).getEntry();

//sets default value to 0.0
// Sets default value to 0.0
speedEntry.setValue(0.0);
}


@Override
public void execute() {
//turns on motors if right trigger is fully pressed. else the motors turn off.
// Turns on motors if right trigger is fully pressed. else the motors turn off.
if (rightTriggerAxis.getAsDouble() == 1.0) {
// Checks the speed Entry for the speed and sets the speed of motors
shooter.setSpeed(speedEntry.getDouble(0.0));

// Enable motors, It has to be called regularly for voltage compensation to work properly
shooter.enable();
} else {
// Disable the shooters
shooter.disable();
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/frc/robot/subsystems/shooter/Shooter.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package frc.robot.subsystems.shooter;

public interface Shooter {
// Disable the shooter
/**
* Disable the speed of a motors for the shooter.
*/
public default void disable() {}

// Enable the shooter with the .
/**
* Enable the speed of a motors for the shooter.
*/
public default void enable() {}

// Set the speed of the motors.
/**
* Set the speed of motors for the shooter.
*
* @param speed The speed to set. Value should be between -1.0 and 1.0.
*/
public default void setSpeed(double speed) {}
}
16 changes: 8 additions & 8 deletions src/main/java/frc/robot/subsystems/shooter/ShooterBase.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package frc.robot.subsystems.shooter;

import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.motorcontrol.Spark;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class ShooterBase extends SubsystemBase implements Shooter {
private final Spark ShooterMotorLeft;
private final Spark ShooterMotorRight;
private final MotorController ShooterMotorLeft;
private final MotorController ShooterMotorRight;
private double voltage;

public ShooterBase() {
Expand All @@ -17,20 +18,19 @@ public ShooterBase() {
@Override
public void disable() {
voltage = 0;
ShooterMotorLeft.stopMotor();
ShooterMotorRight.stopMotor();
//System.out.println(voltage);
ShooterMotorLeft.disable();
ShooterMotorRight.disable();
}

@Override
public void enable() {
ShooterMotorLeft.setVoltage(voltage);
System.out.println(voltage);
ShooterMotorRight.setVoltage(voltage);
}

@Override
//Sets the voltage to 5.0 times speed. the speed value is -1 1
public void setSpeed(double speed) {
//Sets the voltage to 5.0 times speed. the speed value is -1 1
this.voltage = 5.0 * speed;
voltage = 5.0 * speed;
}
}

0 comments on commit d184efb

Please sign in to comment.