Skip to content
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

Robot config #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
id "edu.wpi.first.GradleRIO" version "2024.3.1"
}

java {
Expand Down Expand Up @@ -69,6 +69,8 @@ dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation 'com.google.code.gson:gson:2.8.6'
}

test {
Expand Down
66 changes: 66 additions & 0 deletions robot-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"parameters": {
"SuperStructure.AMP_GO.pivotEncoderVal": 1.0,
"Shooter.Pivot.PID.I": 0.0,
"SuperStructure.RECEIVE.elevatorEncoderVal": 0.0,
"Shooter.PID.P": 0.0,
"Shooter.Pivot.PID.P": 0.05,
"Intake.downPosition": -58.0,
"SuperStructure.SPOOLING.shooterSpeed": 0.8,
"Shooter.Pivot.PID.D": 0.0,
"SuperStructure.TRAP_GO.elevatorEncoderVal": 7.4,
"Shooter.PID.I": 0.0,
"Elevator.PID.OutputRange.Max": 1.0,
"SuperStructure.TRAP_READY.pivotEncoderVal": 0.0,
"SuperStructure.AMP_READY.indexerSpeed": 0.0,
"SuperStructure.AMP_GO.elevatorEncoderVal": 8.2,
"SuperStructure.SHOOTING.indexerSpeed": 0.2,
"SuperStructure.AMP_GO.indexerSpeed": -0.3,
"SuperStructure.tof_threshold_mm": 75.0,
"SuperStructure.AMP_READY.shooterSpeed": 0.0,
"SuperStructure.MANUAL_OVERRIDE.shooterSpeed": 0.0,
"SuperStructure.TRAP_GO.pivotEncoderVal": 0.0,
"SuperStructure.RECEIVE.pivotEncoderVal": -0.373,
"SuperStructure.AMP_READY.elevatorEncoderVal": 8.2,
"Shooter.maxVelocity": 35.0,
"SuperStructure.RECEIVE.indexerSpeed": -0.14,
"SuperStructure.MANUAL_OVERRIDE.pivotEncoderVal": 0.0,
"Elevator.PID.I": 0.0,
"DriveTrain.PID.I": 0.0,
"SuperStructure.IDLE.indexerSpeed": 0.0,
"Elevator.PID.FF": 0.0,
"DriveTrain.PID.D": 0.0,
"Elevator.PID.D": 0.0,
"DriveTrain.PID.P": 0.1,
"Elevator.PID.P": 0.3,
"SuperStructure.IDLE.shooterSpeed": 0.0,
"SuperStructure.SHOOTING.elevatorEncoderVal": 7.0,
"SuperStructure.SHOOTING.pivotEncoderVal": -11.0,
"Shooter.maxAcceleration": 15.0,
"Intake.maxVelocity": 60.0,
"SuperStructure.MANUAL_OVERRIDE.elevatorEncoderVal": 0.0,
"SuperStructure.SPOOLING.indexerSpeed": 0.0,
"SuperStructure.IDLE.elevatorEncoderVal": 0.0,
"Elevator.maxVelocity": 8.0,
"Intake.maxAcceleration": 25.0,
"SuperStructure.RECEIVE.shooterSpeed": 0.0,
"SuperStructure.AMP_GO.shooterSpeed": 0.0,
"SuperStructure.SHOOTING.shooterSpeed": 0.8,
"SuperStructure.MANUAL_OVERRIDE.indexerSpeed": 0.0,
"Elevator.maxAcceleration": 4.0,
"SuperStructure.TRAP_GO.indexerSpeed": 0.2,
"Intake.pivot.PID.I": 0.0,
"SuperStructure.IDLE.pivotEncoderVal": -0.373,
"Intake.pivot.PID.P": 0.02,
"Intake.pivot.PID.D": 0.005,
"SuperStructure.TRAP_GO.shooterSpeed": 0.0,
"Shooter.PID.D": 0.0,
"SuperStructure.SPOOLING.pivotEncoderVal": -11.0,
"SuperStructure.AMP_READY.pivotEncoderVal": 1.0,
"SuperStructure.TRAP_READY.elevatorEncoderVal": 7.4,
"SuperStructure.TRAP_READY.shooterSpeed": 0.0,
"SuperStructure.TRAP_READY.indexerSpeed": 0.0,
"Elevator.PID.OutputRange.Min": -0.2,
"SuperStructure.SPOOLING.elevatorEncoderVal": 7.0
}
}
9 changes: 4 additions & 5 deletions src/main/java/frc/robot/commands/SuperstructureDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ public void execute() {
// This does everything besides state transitions
// Superstructure.elevator.setGoal(superState.elevatorEncoderVal);
Superstructure.Elevator.leader.getPIDController()
.setReference(superState.elevatorEncoderVal, ControlType.kPosition, 0, 2.0);
Superstructure.shooter.setGoal(superState.pivotEncoderVal);
Superstructure.shooter.setIndexer(superState.indexerSpeed);

Superstructure.shooter.setShooter(superState.shooterSpeed);
.setReference(superState.elevatorEncoderVal.get(), ControlType.kPosition, 0, 2.0);
Superstructure.shooter.setGoal(superState.pivotEncoderVal.get());
Superstructure.shooter.setIndexer(superState.indexerSpeed.get());
Superstructure.shooter.setShooter(superState.shooterSpeed.get());
}

buttonBox.LED(ButtonBox.Button.RECEIVE_PRESET, false);
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/frc/robot/subsystems/Intake.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import edu.wpi.first.util.sendable.SendableBuilder;
import edu.wpi.first.wpilibj2.command.TrapezoidProfileSubsystem;
import frc.robot.subsystems.Superstructure.SuperstructureState;
import frc.robot.utilities.ConfigManager;
import frc.robot.utilities.Functions;

/** Represents the intake subsystem. */
Expand Down Expand Up @@ -34,6 +35,7 @@ private IntakeState(double pivot, double roller) {
}
}

private static final ConfigManager.PrefixedConfigAccessor config = ConfigManager.getInstance().getPrefixedAccessor("Intake.");
private static IntakeState state;
public static SuperstructureState pivotUpandDown;
public static CANSparkMax pivot;
Expand All @@ -42,14 +44,17 @@ private IntakeState(double pivot, double roller) {

/** Constructs a new Intake object. */
public Intake() {
super(new TrapezoidProfile.Constraints(60, 25));
super(new TrapezoidProfile.Constraints(
config.getDouble("maxVelocity", 60),
config.getDouble("maxAcceleration", 25)
));
pivot = new CANSparkMax(6, MotorType.kBrushless);
roller = new CANSparkMax(7, MotorType.kBrushless);
Functions.setStatusFrames(pivot);
Functions.setStatusFrames(roller);
pivot.getPIDController().setP(0.02);
pivot.getPIDController().setI(0);
pivot.getPIDController().setD(0.005);
config.doubleHandler("pivot.PID.P", val -> pivot.getPIDController().setP(val), 0.02);
config.doubleHandler("pivot.PID.I", val -> pivot.getPIDController().setI(val), 0);
config.doubleHandler("pivot.PID.D", val -> pivot.getPIDController().setD(val), 0.005);
state = IntakeState.UP;
}

Expand Down
Loading