-
Notifications
You must be signed in to change notification settings - Fork 0
Intake subsystem #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
3826e04
99d6da2
7f5902c
9caa3a4
dac998c
c7ee353
6d84acb
c907f86
6240789
1bcae63
4d16157
39870de
b4cdb8a
edbdb30
1a6f143
7f51f74
5a3340f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,39 +4,77 @@ | |
|
|
||
| package frc.robot.subsystems; | ||
|
|
||
|
|
||
| import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
| import com.revrobotics.spark.SparkMax; | ||
| import com.revrobotics.spark.config.SparkBaseConfig.IdleMode; | ||
| import com.revrobotics.spark.config.SparkMaxConfig; | ||
| import edu.wpi.first.wpilibj.DutyCycleEncoder; | ||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
|
||
|
|
||
| public class IntakeSubsystem extends SubsystemBase { | ||
| /** Creates a new IntakeSubsystem. */ | ||
| private final SparkMax intakeMotor = new SparkMax(10, MotorType.kBrushless); | ||
| private final SparkMax pivotLeft = new SparkMax(11, MotorType.kBrushless); | ||
| private final SparkMax pivotRight = new SparkMax(12, MotorType.kBrushless); | ||
| private final DutyCycleEncoder pivotEncoder = new DutyCycleEncoder(4); | ||
|
|
||
|
|
||
| public IntakeSubsystem() { | ||
| } | ||
| SparkMaxConfig config = new SparkMaxConfig(); | ||
| config.inverted(false) | ||
| .smartCurrentLimit(30) | ||
| .idleMode(IdleMode.kBrake); | ||
|
|
||
| private void intake() { | ||
|
|
||
| intakeMotor.configure(config, SparkMax.ResetMode.kResetSafeParameters, SparkMax.PersistMode.kPersistParameters); | ||
|
Check warning on line 31 in src/main/java/frc/robot/subsystems/IntakeSubsystem.java
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 這個縮排問題要記得修正喔 |
||
| pivotLeft.configure(config, SparkMax.ResetMode.kResetSafeParameters, SparkMax.PersistMode.kPersistParameters); | ||
| pivotRight.configure(config, SparkMax.ResetMode.kResetSafeParameters, SparkMax.PersistMode.kPersistParameters); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同 @BrianHu0925 說過的, |
||
| } | ||
|
|
||
| private void reverseIntake() { | ||
|
|
||
| public void intake() { | ||
| intakeMotor.set(0.5); | ||
| } | ||
|
|
||
| private void stopIntake() { | ||
| public void reverseIntake() { | ||
| intakeMotor.set(-0.5); | ||
| } | ||
|
|
||
| public void stopIntake() { | ||
| intakeMotor.set(0); | ||
| } | ||
|
|
||
| private void rotateUp() { | ||
| public void rotateUp() { | ||
| pivotLeft.set(0.2); | ||
| pivotRight.set(-0.2); | ||
| } | ||
|
|
||
| public void rotateDown() { | ||
| pivotLeft.set(-0.2); | ||
| pivotRight.set(0.2); | ||
| } | ||
|
|
||
| private void rotateDown() { | ||
| public void stopRotate() { | ||
| pivotLeft.set(0); | ||
| pivotRight.set(0); | ||
| } | ||
|
|
||
| public void deployIntake() { | ||
| rotateDown(); | ||
| } | ||
|
|
||
| private void stopRotate() { | ||
| public void retractIntake() { | ||
| rotateUp(); | ||
| } | ||
|
|
||
| public double getPivotAbsolutePosition() { | ||
| return pivotEncoder.get(); | ||
| } | ||
|
|
||
| @Override | ||
| public void periodic() { | ||
| // This method will be called once per scheduler run | ||
| SmartDashboard.putNumber("Pivot Absolute Pos", getPivotAbsolutePosition()); | ||
| SmartDashboard.putBoolean("Pivot Encoder Connected", pivotEncoder.isConnected()); | ||
|
Comment on lines
+77
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DashBoard 的命名方式確定了記得更改一下喔 |
||
| } | ||
| } | ||
| } | ||
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.
請修正這邊的縮排問題