-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Team841Aaron <[email protected]>
- Loading branch information
1 parent
13d2150
commit dd1c763
Showing
6 changed files
with
95 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.team841.Swerve23.Constants; | ||
|
||
public class SC { | ||
public static class Intake { | ||
public static final int currentLimit = 60; // in amps | ||
} | ||
|
||
public static class Arm { | ||
public static final int currentLimit = 60; // in amps | ||
|
||
public static class pidGains { | ||
public static final Double kP = 0.0; | ||
public static final Double kI = 0.0; | ||
public static final Double kD = 0.0; | ||
public static final Double tolerance = 0.0; | ||
public static final Double kIz = 0.0; | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/team841/Swerve23/Constants/SubsystemManifest.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,7 +1,11 @@ | ||
package com.team841.Swerve23.Constants; | ||
|
||
import com.team841.Swerve23.Drive.Drivetrain; | ||
import com.team841.Swerve23.Superstructure.Arm; | ||
import com.team841.Swerve23.Superstructure.Intake; | ||
|
||
public final class SubsystemManifest { | ||
public static final Drivetrain drivetrain = Swerve.drivetrain; | ||
public static final Intake intake = new Intake(); | ||
public static final Arm arm = new Arm(); | ||
} |
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
33 changes: 26 additions & 7 deletions
33
src/main/java/com/team841/Swerve23/Superstructure/Arm.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,22 +1,41 @@ | ||
package com.team841.Swerve23.Superstructure; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.SparkMaxPIDController; | ||
import com.revrobotics.CANSparkMax.ControlType; | ||
import com.revrobotics.CANSparkMaxLowLevel.MotorType; | ||
import com.revrobotics.SparkMaxPIDController; | ||
import com.team841.Swerve23.Constants.ConstantsIO; | ||
|
||
import com.team841.Swerve23.Constants.SC; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Arm extends SubsystemBase { | ||
|
||
private final CANSparkMax armMotor = new CANSparkMax(ConstantsIO.CANID.kArm, MotorType.kBrushless); | ||
private final CANSparkMax armMotor = | ||
new CANSparkMax(ConstantsIO.CANID.kArm, MotorType.kBrushless); | ||
|
||
public SparkMaxPIDController armPID = armMotor.getPIDController(); | ||
|
||
public Arm() {} | ||
public Arm() { | ||
armMotor.restoreFactoryDefaults(); | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
armMotor.setSmartCurrentLimit(SC.Arm.currentLimit); | ||
|
||
armPID.setP(SC.Arm.pidGains.kP); | ||
armPID.setI(SC.Arm.pidGains.kI); | ||
armPID.setD(SC.Arm.pidGains.kD); | ||
armPID.setIZone(SC.Arm.pidGains.kIz); | ||
|
||
armPID.setFeedbackDevice(armMotor.getEncoder()); | ||
} | ||
|
||
public Command armToPosition(double angle) { | ||
return Commands.run(() -> armPID.setReference(angle, ControlType.kPosition)) | ||
.withInterruptBehavior(Command.InterruptionBehavior.kCancelSelf) | ||
.handleInterrupt(() -> armMotor.set(0)); | ||
} | ||
|
||
@Override | ||
public void periodic() {} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/team841/Swerve23/Superstructure/ArmFactory.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,10 @@ | ||
package com.team841.Swerve23.Superstructure; | ||
|
||
import com.team841.Swerve23.Constants.SubsystemManifest; | ||
|
||
public class ArmFactory { | ||
|
||
private Arm s_arm = SubsystemManifest.arm; | ||
|
||
; | ||
} |
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