-
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: PeskyBuzz <[email protected]>
- Loading branch information
1 parent
d451103
commit 83956e4
Showing
9 changed files
with
268 additions
and
22 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
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,53 @@ | ||
// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs | ||
// https://www.team2106.org | ||
|
||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.intake; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
import org.littletonrobotics.junction.LogTable; | ||
import org.littletonrobotics.junction.inputs.LoggableInputs; | ||
|
||
public interface IO_IntakeBase { | ||
|
||
@AutoLog | ||
public static class IntakeInputs implements LoggableInputs { | ||
|
||
public double armAngleDegrees = 0.0; | ||
public double armMotorCurrent = 0.0; | ||
public double wheelMotorCurrent = 0.0; | ||
public double wheelRPM = 0.0; | ||
public boolean toggleSensor = false; | ||
public double distanceSensorCM = 0.0; | ||
|
||
@Override | ||
public void toLog(LogTable table) { | ||
table.put("ArmAngleDegrees", armAngleDegrees); | ||
table.put("ArmMotorCurrent", armMotorCurrent); | ||
table.put("wheelMotorCurrent", wheelMotorCurrent); | ||
table.put("wheelRPM", wheelRPM); | ||
table.put("toggleSensor", toggleSensor); | ||
table.put("distanceSensorCM", distanceSensorCM); | ||
} | ||
|
||
@Override | ||
public void fromLog(LogTable table) { | ||
armAngleDegrees = table.get("ArmAngleDegrees", armAngleDegrees); | ||
armMotorCurrent = table.get("ArmMotorCurrent", armMotorCurrent); | ||
wheelMotorCurrent = table.get("wheelMotorCurrent", wheelMotorCurrent); | ||
wheelRPM = table.get("wheelRPM", wheelRPM); | ||
toggleSensor = table.get("toggleSensor", toggleSensor); | ||
distanceSensorCM = table.get("distanceSensorCM", distanceSensorCM); | ||
} | ||
} | ||
|
||
/** Updates the set of loggable inputs. */ | ||
public void updateInputs(IntakeInputs inputs); | ||
|
||
public void setArmAngle(double angle); | ||
|
||
public void setIntakeSpeed(double speed); | ||
} |
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,49 @@ | ||
// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs | ||
// https://www.team2106.org | ||
|
||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.intake; | ||
|
||
import com.revrobotics.spark.SparkBase.ControlType; | ||
import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
import com.revrobotics.spark.SparkMax; | ||
import frc.robot.util.IRBeamBreak; | ||
|
||
public class IO_IntakeReal implements IO_IntakeBase { | ||
|
||
private SparkMax armMotor; | ||
private SparkMax wheelMotor; | ||
|
||
private IRBeamBreak toggleSensor; | ||
|
||
public IO_IntakeReal() { | ||
|
||
armMotor = new SparkMax(0, MotorType.kBrushless); | ||
wheelMotor = new SparkMax(0, MotorType.kBrushless); | ||
toggleSensor = new IRBeamBreak(0); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IntakeInputs inputs) { | ||
|
||
inputs.armAngleDegrees = armMotor.getEncoder().getPosition(); | ||
inputs.armMotorCurrent = armMotor.getOutputCurrent(); | ||
inputs.wheelMotorCurrent = wheelMotor.getOutputCurrent(); | ||
inputs.wheelRPM = wheelMotor.getEncoder().getVelocity(); | ||
inputs.toggleSensor = toggleSensor.getState(); | ||
inputs.distanceSensorCM = 0; | ||
} | ||
|
||
@Override | ||
public void setArmAngle(double angle) { | ||
armMotor.getClosedLoopController().setReference(angle, ControlType.kMAXMotionPositionControl); | ||
} | ||
|
||
@Override | ||
public void setIntakeSpeed(double speed) { | ||
wheelMotor.set(speed); | ||
} | ||
} |
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,70 @@ | ||
// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs | ||
// https://www.team2106.org | ||
|
||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
public class SUB_Intake extends SubsystemBase { | ||
|
||
public enum State { | ||
STOWED(-15, 0.0), | ||
CORAL_STATION(120, -0.3), | ||
ALGAE_GROUND(45, -1.0), | ||
ALGAE_REMOVAL(85, 0.8), | ||
ALGAE_PROCESSOR(85, 1.0), | ||
ALGAE_BARGE(135, 0.25), | ||
L1_SCORING(30, 0.8), | ||
L2_L3_SCORING(45, 0.8), | ||
L4_SCORING(30, 0.8); | ||
|
||
private final int deg; | ||
private final double speed; | ||
|
||
State(int deg, double speed) { | ||
this.deg = deg; | ||
this.speed = speed; | ||
} | ||
|
||
public int getDeg() { | ||
return deg; | ||
} | ||
|
||
public double getSpeed() { | ||
return speed; | ||
} | ||
} | ||
|
||
private final IO_IntakeBase io; | ||
|
||
private final IO_IntakeBase.IntakeInputs inputs = new IO_IntakeBase.IntakeInputs(); | ||
|
||
public SUB_Intake(IO_IntakeBase io) { | ||
this.io = io; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
|
||
// Update inputs | ||
io.updateInputs(inputs); | ||
|
||
// Process inputs | ||
Logger.processInputs("Intake", inputs); | ||
} | ||
|
||
public Command setState(State state) { | ||
return new InstantCommand( | ||
() -> { | ||
io.setArmAngle(state.getDeg()); | ||
io.setIntakeSpeed(state.getSpeed()); | ||
}); | ||
} | ||
} |
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,34 @@ | ||
// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs | ||
// https://www.team2106.org | ||
|
||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.util; | ||
|
||
import edu.wpi.first.wpilibj.DigitalInput; | ||
|
||
public class IRBeamBreak { | ||
|
||
private final DigitalInput sensor; | ||
|
||
/** | ||
* Creates a new IRBeamBreak digital IR sensor object. | ||
* | ||
* @param channel The digital input channel | ||
*/ | ||
public IRBeamBreak(int channel) { | ||
sensor = new DigitalInput(channel); | ||
} | ||
|
||
/** | ||
* Get the the current state of the sensor. Returns true if the sensor is triggered (beam is | ||
* broken). | ||
* | ||
* @return The state obtained from the sensor | ||
*/ | ||
public boolean getState() { | ||
return !sensor.get(); | ||
} | ||
} |
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,35 @@ | ||
// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs | ||
// https://www.team2106.org | ||
|
||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.util; | ||
|
||
import com.revrobotics.spark.SparkMax; | ||
|
||
public class SparkConfigurator { | ||
|
||
public static void configureSparkMaxForPID(SparkMax sparkMax, double p, double i, double d) {} | ||
|
||
/* | ||
SparkMaxConfig sparkMaxConfig = new SparkMaxConfig(); | ||
ClosedLoopConfig closedLoopConfig = new ClosedLoopConfig(); | ||
closedLoopConfig.apply( | ||
new MAXMotionConfig(). | ||
) | ||
sparkMax.configure( | ||
new SparkMaxConfig().apply( | ||
new ClosedLoopConfig().apply | ||
), | ||
), SparkBase.ResetMode.kNoResetSafeParameters, SparkBase.PersistMode.kPersistParameters); | ||
} | ||
*/ | ||
} |