generated from Frc5572/Java-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algae #29
Closed
Algae #29
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
85ae7c0
Added an elevator coral and elevator algae subsystem
Merridew1 ee5f669
fixed ak
txrnqt 9ef2be1
fixed io issues
txrnqt 6888511
fixed some linting errors
Merridew1 a5d54f8
fixed more linting
Merridew1 5cc5d8f
more linting
Merridew1 41fc4b4
linting test
Merridew1 8306024
added asterisk
Merridew1 97f33f6
More linting-added tags
Merridew1 54afce1
got rid of coral, added neutral config
Merridew1 c80d775
added hasAlgae
Merridew1 3eecb7f
fixed method names to be consistent
Merridew1 4c32beb
fixed commands and removed non java file
Merridew1 577ee27
added stop when algae is present
Merridew1 c0a91e4
fixed hasAlgae
Merridew1 40fa314
trigger needed
Merridew1 1de24f8
added algae led trigger (unimplemented yet)
Merridew1 e07f912
Merge branch 'main' into Algae
Merridew1 098de47
Merge branch 'main' into Algae
Merridew1 cb22cc3
added import for instantcommand
Merridew1 b91170a
fixed linting again
Merridew1 7a88fb2
fixed linting
Merridew1 80e928d
Merge remote-tracking branch 'origin/main' into Algae
Merridew1 a48e957
binded has algae led to a trigger, added real runtime type
Merridew1 5d8af87
Merge branch 'main' into Algae
Merridew1 b6178c3
Merge branch 'main' into Algae
Merridew1 69c7508
fixed comments from github
Merridew1 6ebdb82
Merge branch 'main' into Algae, updated CAN IDs for coral and algae
Merridew1 c344076
linting
Merridew1 23e3f10
fixed leds command
Merridew1 06a996a
temporary test bindings
Merridew1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
40 changes: 40 additions & 0 deletions
40
src/main/java/frc/robot/subsystems/elevator_algae/ElevatorAlgae.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package frc.robot.subsystems.elevator_algae; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
/** | ||
* Elevator Algae class | ||
*/ | ||
public class ElevatorAlgae extends SubsystemBase { | ||
ElevatorAlgaeIO io; | ||
AlgaeIOInputsAutoLogged inputs = new AlgaeIOInputsAutoLogged(); | ||
|
||
/* | ||
* Constructor for Elevator Algae class | ||
*/ | ||
public ElevatorAlgae(ElevatorAlgaeIO io) { | ||
this.io = io; | ||
io.updateInputs(inputs); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
} | ||
|
||
|
||
public void setAlgaeMotorVoltage(double voltage) { // set motor speed function | ||
io.setAlgaeMotorVoltage(voltage); | ||
} | ||
|
||
public boolean hasAlgae() { | ||
legoguy1000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return inputs.algaeMotorCurrent > Constants.HAS_ALGAE_CURRENT_THRESHOLD; | ||
} | ||
|
||
public Command setMotorVoltageCommand(double speed) { // set motor speed Command | ||
return runEnd(() -> setAlgaeMotorVoltage(speed), () -> setAlgaeMotorVoltage(0)) | ||
.until(() -> hasAlgae()); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/frc/robot/subsystems/elevator_algae/ElevatorAlgaeIO.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package frc.robot.subsystems.elevator_algae; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
/** | ||
* elevator algae io class | ||
*/ | ||
public interface ElevatorAlgaeIO { | ||
/** | ||
* Elevator Algae inputs | ||
*/ | ||
@AutoLog | ||
public class AlgaeIOInputs { | ||
double algaeMotorCurrent; | ||
boolean beamBrakeStatus; | ||
} | ||
|
||
public default void setAlgaeMotorVoltage(double voltage) {} | ||
|
||
public default void updateInputs(AlgaeIOInputs inputs) {} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/frc/robot/subsystems/elevator_algae/ElevatorAlgaeReal.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package frc.robot.subsystems.elevator_algae; | ||
|
||
import com.revrobotics.spark.SparkBase.PersistMode; | ||
import com.revrobotics.spark.SparkBase.ResetMode; | ||
import com.revrobotics.spark.SparkFlex; | ||
import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode; | ||
import com.revrobotics.spark.config.SparkFlexConfig; | ||
import frc.robot.Constants; | ||
|
||
/** | ||
* Algae Real Class | ||
*/ | ||
public class ElevatorAlgaeReal implements ElevatorAlgaeIO { | ||
private final SparkFlex algaeMotor = // Algae motor | ||
new SparkFlex(Constants.Motors.AlgaeMotors.ALGAE_MOTOR_ID, MotorType.kBrushless); | ||
private final SparkFlexConfig algaeMotorConfig = new SparkFlexConfig(); | ||
|
||
/** | ||
* Algae Real constructor | ||
*/ | ||
public ElevatorAlgaeReal() { | ||
algaeMotorConfig.idleMode(IdleMode.kBrake); | ||
algaeMotor.configure(algaeMotorConfig, ResetMode.kResetSafeParameters, | ||
PersistMode.kPersistParameters); | ||
} | ||
|
||
@Override | ||
public void updateInputs(AlgaeIOInputs inputs) { // update inputs to IO layer | ||
inputs.algaeMotorCurrent = algaeMotor.getOutputCurrent(); | ||
} | ||
|
||
@Override | ||
public void setAlgaeMotorVoltage(double voltage) { // set hardware speed | ||
algaeMotor.setVoltage(voltage); | ||
} | ||
|
||
} |
Merridew1 marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the prototype and see if this logic works