Skip to content

Commit

Permalink
Run SpotlessApply
Browse files Browse the repository at this point in the history
  • Loading branch information
StewardHail3433 committed Jan 18, 2024
1 parent a66a8f0 commit 5ae8534
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 104 deletions.
1 change: 0 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package frc.robot;


import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
Expand Down
101 changes: 50 additions & 51 deletions src/main/java/frc/robot/commands/ShooterBaseCommand.java
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
package frc.robot.commands;



import java.util.Map;
import java.util.function.BooleanSupplier;

import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.shooter.ShooterBase;
import java.util.Map;
import java.util.function.BooleanSupplier;

public class ShooterBaseCommand extends Command {
ShooterBase shooter;
BooleanSupplier enable;
ShuffleboardTab tab;
GenericEntry voltsEntry;

public ShooterBaseCommand(ShooterBase shooter, BooleanSupplier enable) {
this.shooter = shooter;
this.enable = enable;

//create shooter tab on ShuffleBoard
tab = Shuffleboard.getTab("Shooter");
// Create volt entry under Shooter tab as a number sider with min = -1 and max = 1
voltsEntry = tab.add("Volts", 0).withWidget(BuiltInWidgets.kNumberSlider)
.withProperties(Map.of("min", -12, "max", 12)).getEntry();

// Sets default value to 0.0
voltsEntry.setValue(0.0);

addRequirements(shooter);
ShooterBase shooter;
BooleanSupplier enable;
ShuffleboardTab tab;
GenericEntry voltsEntry;

public ShooterBaseCommand(ShooterBase shooter, BooleanSupplier enable) {
this.shooter = shooter;
this.enable = enable;

// create shooter tab on ShuffleBoard
tab = Shuffleboard.getTab("Shooter");
// Create volt entry under Shooter tab as a number sider with min = -1 and max = 1
voltsEntry =
tab.add("Volts", 0)
.withWidget(BuiltInWidgets.kNumberSlider)
.withProperties(Map.of("min", -12, "max", 12))
.getEntry();

// Sets default value to 0.0
voltsEntry.setValue(0.0);

addRequirements(shooter);
}

@Override
public void initialize() {
// disable shooter when initialize
shooter.disable();
}

@Override
public void execute() {
// Turns on motors if right trigger is fully pressed. else the motors turn off.
if (enable.getAsBoolean() == true) {
// Checks the volt Entry for the volt and sets the voltage of motors
shooter.setVoltage(voltsEntry.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();
}
@Override
public void initialize() {
// disable shooter when initialize
shooter.disable();
}

}

@Override
public void execute() {
// Turns on motors if right trigger is fully pressed. else the motors turn off.
if (enable.getAsBoolean() == true) {
// Checks the volt Entry for the volt and sets the voltage of motors
shooter.setVoltage(voltsEntry.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();
}
}

@Override
//disable shooter when it ends.
public void end(boolean interrupted) {
shooter.disable();
}
@Override
// disable shooter when it ends.
public void end(boolean interrupted) {
shooter.disable();
}
}
8 changes: 2 additions & 6 deletions src/main/java/frc/robot/subsystems/shooter/Shooter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package frc.robot.subsystems.shooter;

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

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

/**
Expand Down
82 changes: 40 additions & 42 deletions src/main/java/frc/robot/subsystems/shooter/ShooterBase.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
package frc.robot.subsystems.shooter;


import org.littletonrobotics.junction.Logger;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import org.littletonrobotics.junction.Logger;

public class ShooterBase extends SubsystemBase implements Shooter {
ShooterIO io;
private final ShooterIOInputsAutoLogged inputs = new ShooterIOInputsAutoLogged();
private double voltage;

public ShooterBase(ShooterIO io) {
this.io = io;
voltage = 0;
}

@Override
//Disable the shooter
public void disable() {
voltage = 0;
io.setVoltage(voltage);
}

@Override
//Enable the shooter
public void enable() {
io.setVoltage(voltage);
}

@Override
//Sets the voltage to volts. the volts value is -12 to 12
public void setVoltage(double volts) {
voltage = volts;
}

@Override
public double getCurrentSpeed() {
return inputs.velocityRadPerSec;
}
@Override
public void periodic() {
//Updates the inputs
io.updateInputs(inputs);
Logger.processInputs("Shooter", inputs);
}
ShooterIO io;
private final ShooterIOInputsAutoLogged inputs = new ShooterIOInputsAutoLogged();
private double voltage;

public ShooterBase(ShooterIO io) {
this.io = io;
voltage = 0;
}

@Override
// Disable the shooter
public void disable() {
voltage = 0;
io.setVoltage(voltage);
}

@Override
// Enable the shooter
public void enable() {
io.setVoltage(voltage);
}

@Override
// Sets the voltage to volts. the volts value is -12 to 12
public void setVoltage(double volts) {
voltage = volts;
}

@Override
public double getCurrentSpeed() {
return inputs.velocityRadPerSec;
}

@Override
public void periodic() {
// Updates the inputs
io.updateInputs(inputs);
Logger.processInputs("Shooter", inputs);
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public default void updateInputs(ShooterIOInputs inputs) {}

/** Run open loop at the specified voltage. */
public default void setVoltage(double volts) {}
}
}
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class ShooterIOSim implements ShooterIO {
@Override
public void updateInputs(ShooterIOInputs inputs) {

//Update sim
// Update sim
sim.update(0.02);

//Update inputs
// Update inputs
inputs.velocityRadPerSec = sim.getAngularVelocityRadPerSec();
inputs.appliedVolts = appliedVolts;
}
Expand All @@ -24,5 +24,4 @@ public void setVoltage(double volts) {
appliedVolts = volts;
sim.setInputVoltage(volts);
}

}

0 comments on commit 5ae8534

Please sign in to comment.