generated from AZ-First/Az-RBSI
-
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.
coralScorer works with ls. ls added to coralscorerspark
- Loading branch information
Showing
7 changed files
with
110 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.CoralScorer.CoralScorer; | ||
|
||
public class CoralScorerCommand extends Command { | ||
|
||
private final CoralScorer haberdashery; | ||
|
||
private final double volts; | ||
|
||
public CoralScorerCommand(CoralScorer haberdashery, double volts) { | ||
this.haberdashery = haberdashery; | ||
this.volts = volts; | ||
addRequirements(haberdashery); | ||
} | ||
|
||
@Override | ||
public void initialize() {} | ||
|
||
@Override | ||
public void execute() { | ||
haberdashery.runVoltsWithLS(volts); | ||
} | ||
|
||
@Override | ||
public void end(boolean interupted) { | ||
haberdashery.stop(); | ||
} | ||
} |
28 changes: 26 additions & 2 deletions
28
src/main/java/frc/robot/subsystems/CoralScorer/CoralScorer.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 |
---|---|---|
@@ -1,5 +1,29 @@ | ||
package frc.robot.subsystems.CoralScorer; | ||
|
||
public class CoralScorer { | ||
|
||
import frc.robot.util.RBSISubsystem; | ||
|
||
public class CoralScorer extends RBSISubsystem { | ||
|
||
private final CoralScorerIO io; | ||
|
||
public CoralScorer(CoralScorerIO io) { | ||
this.io = io; | ||
} | ||
|
||
/** Stop in open loop. */ | ||
public void stop() { | ||
io.stop(); | ||
} | ||
|
||
public void runVolts(double volts) { | ||
io.setVolts(3 * volts); | ||
} | ||
|
||
public void runVoltsWithLS(double volts) { | ||
if (io.getLightStop() == false) { | ||
io.setVolts(3 * volts); | ||
} else { | ||
io.setVolts(-1.5 + (3 * volts)); | ||
} | ||
} | ||
} |
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
46 changes: 28 additions & 18 deletions
46
src/main/java/frc/robot/subsystems/CoralScorer/CoralScorerIOSpark.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 |
---|---|---|
@@ -1,25 +1,35 @@ | ||
package frc.robot.subsystems.CoralScorer; | ||
|
||
import com.revrobotics.spark.SparkMax; | ||
import com.revrobotics.spark.SparkBase; | ||
import com.revrobotics.spark.SparkClosedLoopController; | ||
import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
import com.revrobotics.spark.config.SparkMaxConfig; | ||
import com.revrobotics.spark.SparkMax; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import java.util.function.BooleanSupplier; | ||
|
||
public class CoralScorerIOSpark implements CoralScorerIO { | ||
private SparkMax motor = new SparkMax(0, MotorType.kBrushless); | ||
private SparkMaxConfig config = new SparkMaxConfig(); | ||
private SparkClosedLoopController m_pidController; | ||
|
||
public CoralScorerIOSpark() { | ||
config.encoder.positionConversionFactor(1000); | ||
config. | ||
} | ||
@Override | ||
public void moveXInches(double inches) { | ||
motor.configure(config, null, null); | ||
motor.getEncoder().getPosition(); | ||
m_pidController.setReference(inches, SparkBase.ControlType.kSmartMotion); | ||
} | ||
|
||
public CoralScorerIOSpark() {} | ||
|
||
private final SparkMax coralMotor = new SparkMax(16, MotorType.kBrushless); | ||
|
||
private final DigitalInput lightStop = new DigitalInput(1); | ||
|
||
@Override | ||
public void setVolts(double volts) { | ||
coralMotor.setVoltage(volts); | ||
} | ||
|
||
@Override | ||
public void lightStop(BooleanSupplier lightStop) { | ||
if (lightStop.getAsBoolean()) {} | ||
} | ||
|
||
@Override | ||
public boolean getLightStop() { | ||
return lightStop.get(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
coralMotor.stopMotor(); | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
src/main/java/frc/robot/subsystems/CoralScorer/CoralSocrerIOTalonFX.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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
package frc.robot.subsystems.CoralScorer; | ||
|
||
public class CoralSocrerIOTalonFX { | ||
|
||
} | ||
public class CoralSocrerIOTalonFX {} |
This file was deleted.
Oops, something went wrong.