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

endeffector #3

Merged
merged 62 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
fc75ccf
change talonfx to sparkmax ._.
SourWasHere Jan 18, 2025
f3f81f7
move pid outside sparkmax implementation
SourWasHere Jan 18, 2025
71d2f99
add voltage methods
SourWasHere Jan 18, 2025
676b5eb
add todo
SourWasHere Jan 18, 2025
34e6643
add commands to claw subsystem
SourWasHere Jan 19, 2025
ae25e0e
add trigger
SourWasHere Jan 19, 2025
b6a1c39
moved commands to folder
SourWasHere Jan 19, 2025
e817052
updated robotcontainer
SourWasHere Jan 19, 2025
f4f15f7
added encoder to robotcontainer parameter
SourWasHere Jan 19, 2025
5d9b592
fix parameters
SourWasHere Jan 19, 2025
ef78723
cleanup
SourWasHere Jan 19, 2025
67a84ae
added move end wheel method
SourWasHere Jan 19, 2025
bcc5576
added small motor controllers
SourWasHere Jan 19, 2025
33e2937
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Jan 19, 2025
ca2aac4
claw constants
therbun Jan 19, 2025
a4f2374
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Jan 19, 2025
97f0289
add comments
SourWasHere Jan 19, 2025
1c9fb45
update for 2 motors
SourWasHere Jan 19, 2025
0f7bffc
fix
SourWasHere Jan 19, 2025
7b10f19
changed naming of sparkmax variables
therbun Jan 19, 2025
a75b362
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Jan 19, 2025
6be1862
minor changes to variable names and PID controller
therbun Jan 20, 2025
bc468b6
move position and velocity inputs to encoderio
SourWasHere Jan 20, 2025
a8dc870
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Jan 20, 2025
94fa5e0
update sim part of robotcontainer
SourWasHere Jan 20, 2025
e9e3b43
no errors
SourWasHere Jan 20, 2025
12d33bc
advantagekit logger
SourWasHere Jan 20, 2025
2537b04
refactor claw methods
SourWasHere Jan 25, 2025
0d168c7
refactor claw methods 2
SourWasHere Jan 25, 2025
d133867
refactor claw methods 3
SourWasHere Jan 25, 2025
9a914d5
make pid changeable for each implementation
SourWasHere Jan 25, 2025
3e2508a
added more constants and made each implmemetation have its own pid
SourWasHere Jan 25, 2025
217f489
fix
SourWasHere Jan 26, 2025
5eb1ae2
Merge remote-tracking branch 'origin/main' into endeffector
SourWasHere Jan 26, 2025
212d996
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Jan 26, 2025
9156fe3
add inputs for whether the claw has algae or coral
SourWasHere Jan 26, 2025
2954d49
made open and close functions change boolean
SourWasHere Jan 27, 2025
14e29c2
started inputs
SourWasHere Jan 27, 2025
e26d1c6
binded commands to triggers
SourWasHere Jan 27, 2025
b7a5a90
added input for whether claw is open ._.
SourWasHere Jan 27, 2025
12b5801
change coral detection
SourWasHere Jan 27, 2025
0a7a4a7
Merge remote-tracking branch 'origin/main' into endeffector
SourWasHere Jan 27, 2025
7636dd6
intake sim
SourWasHere Feb 3, 2025
126b660
uptate add coral
SourWasHere Feb 16, 2025
5f9102d
update periodic
SourWasHere Feb 16, 2025
73fe327
add intake sim files
SourWasHere Feb 16, 2025
36b83a5
add more files
SourWasHere Feb 16, 2025
b89e4ae
add updateinputs
SourWasHere Feb 16, 2025
31e9303
add files
SourWasHere Feb 17, 2025
b07c607
finish intake sim and add command
SourWasHere Feb 17, 2025
371fafb
finish intake sim and add pickup command ._.
SourWasHere Feb 17, 2025
8eaa06d
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Feb 22, 2025
2294019
i think everything in end effector is okay
therbun Feb 23, 2025
fa7a517
thrifty encoder ._.
SourWasHere Feb 23, 2025
79625d5
get velocity
SourWasHere Feb 23, 2025
69576bd
2nd constructor
SourWasHere Feb 23, 2025
6f216aa
intake spark max implementation
SourWasHere Feb 23, 2025
557a9b9
._.
SourWasHere Feb 23, 2025
069450a
Merge remote-tracking branch 'origin/endeffector' into endeffector
SourWasHere Feb 23, 2025
bc6bf2e
robotcontainer fix
SourWasHere Feb 23, 2025
93372f7
Thrifty ncoder implemented
SourWasHere Feb 23, 2025
211f7a2
Merge branch 'encoder' into endeffector
scotus-1 Feb 23, 2025
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BitBuckets robot code for 2025
BitBuckets robot code for 2025
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/OperatorInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class OperatorInput {

final Trigger resetEncoder = operatorControl.leftBumper();

final Trigger openClaw = driver.leftStick();
final Trigger closeClaw = driver.rightStick();

final Trigger IntakeOn = driver.a();

final Trigger xNotDesired =
Expand Down
36 changes: 26 additions & 10 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@
import frc.robot.commands.ElevatorCommands.ResetElevatorEncoderCommand;
import frc.robot.constants.Constants;
import frc.robot.constants.ElevatorConstants;
import frc.robot.constants.Constants;
import frc.robot.constants.DriveConstants;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.AlgaeManagementSubsystem.AlgaeManagementSubsystem;
import frc.robot.subsystems.Auto.AutoSubsystem;
import frc.robot.subsystems.ClawSubsystem.ClawSubsystem;
import frc.robot.subsystems.ClawSubsystem.*;
import frc.robot.subsystems.DriveSubsystem.*;
import frc.robot.subsystems.DriveSubsystem.DriveSubsystem;
import frc.robot.subsystems.DriveSubsystem.GyroIO;
import frc.robot.subsystems.DriveSubsystem.GyroIOPigeon2;
import frc.robot.subsystems.DriveSubsystem.ModuleIO;
import frc.robot.subsystems.DriveSubsystem.ModuleIOSim;
import frc.robot.subsystems.ElevatorSubsystem.*;
import frc.robot.subsystems.GroundIntakeSubsystem.GroundIntakeSubsystem;
import frc.robot.subsystems.AlgaeIntakeSubsystem.AlgaeIntakeSubsystem;
import frc.robot.subsystems.AlgaeIntakeSubsystem.IntakeIOSparkMax;
import frc.robot.subsystems.AlgaeIntakeSubsystem.IntakeIOSim;
import frc.robot.subsystems.LEDSubsytem.LEDSubsystem;
import frc.robot.subsystems.SingleJointedArmSubsystem.SingleJointedArmSubsystem;
import frc.robot.subsystems.VisionSubsystem.VisionIO;
Expand All @@ -50,10 +52,10 @@
import frc.robot.subsystems.VisionSubsystem.VisionSubsystem;
import org.ironmaple.simulation.SimulatedArena;
import org.ironmaple.simulation.drivesims.SwerveDriveSimulation;
import org.ironmaple.simulation.seasonspecific.reefscape2025.ReefscapeCoral;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;
import frc.robot.commands.*;

import java.util.function.DoubleSupplier;

Expand All @@ -65,7 +67,7 @@ public class RobotContainer {
private final ElevatorSubsystem elevatorSubsystem;
private final AlgaeManagementSubsystem algaeManagementSubsystem;
private final ClawSubsystem clawSubsystem;
private final GroundIntakeSubsystem groundIntakeSubsystem;
private final AlgaeIntakeSubsystem groundIntakeSubsystem;
private final LEDSubsystem ledSubsystem;
private final SingleJointedArmSubsystem singleJointedArmSubsystem;
private final VisionSubsystem visionSubsystem;
Expand Down Expand Up @@ -104,9 +106,9 @@ public RobotContainer() {
algaeManagementSubsystem =
new AlgaeManagementSubsystem(); //TODO
clawSubsystem =
new ClawSubsystem(); //TODO
new ClawSubsystem(new EndEffectorIOSparkMax(4, 5, new EndEffectorEncoderIOSim()));
groundIntakeSubsystem =
new GroundIntakeSubsystem(); //TODO
new AlgaeIntakeSubsystem(new IntakeIOSparkMax(13, 12)); //TODO replace placeholder
ledSubsystem =
new LEDSubsystem(); //TODO
singleJointedArmSubsystem =
Expand Down Expand Up @@ -138,9 +140,9 @@ public RobotContainer() {
algaeManagementSubsystem =
new AlgaeManagementSubsystem(); //TODO
clawSubsystem =
new ClawSubsystem(); //TODO
new ClawSubsystem(new EndEffectorIOSim());
groundIntakeSubsystem =
new GroundIntakeSubsystem(); //TODO
new AlgaeIntakeSubsystem(new IntakeIOSim(driveSimulation)); //TODO
ledSubsystem =
new LEDSubsystem(); //TODO
singleJointedArmSubsystem =
Expand All @@ -163,9 +165,9 @@ public RobotContainer() {
algaeManagementSubsystem =
new AlgaeManagementSubsystem(); //TODO
clawSubsystem =
new ClawSubsystem(); //TODO
new ClawSubsystem(new EndEffectorIOSparkMax(4, 5, new EndEffectorEncoderIOSim()));
groundIntakeSubsystem =
new GroundIntakeSubsystem(); //TODO
new AlgaeIntakeSubsystem(new IntakeIOSparkMax(13, 12)); //TODO replace with real intake
ledSubsystem =
new LEDSubsystem(); //TODO
singleJointedArmSubsystem =
Expand Down Expand Up @@ -220,6 +222,9 @@ public double getAsDouble() {
}));


operatorInput.openClaw.onTrue(new OpenClawCommand(clawSubsystem));
operatorInput.closeClaw.onTrue(new CloseClawCommand(clawSubsystem));

operatorInput.movementDesired.whileTrue(
new BaseDriveCommand(
drive,
Expand All @@ -244,9 +249,20 @@ public void resetSimulationField() {
SimulatedArena.getInstance().resetFieldForAuto();
}

public void addCoral() {
SimulatedArena.getInstance().addGamePiece(new ReefscapeCoral(new Pose2d(2, 2, Rotation2d.fromDegrees(90))));
Logger.recordOutput("FieldSimulation/Coral", SimulatedArena.getInstance().getGamePiecesArrayByType("Coral"));
}

public void displaySimFieldToAdvantageScope() {
if (Constants.currentMode != Constants.Mode.SIM) return;

Logger.recordOutput("FieldSimulation/RobotPosition", driveSimulation.getSimulatedDriveTrainPose());
}

public void periodic() {
Pose3d[] coralPoses = SimulatedArena.getInstance()
.getGamePiecesArrayByType("Coral");
Logger.recordOutput("FieldSimulation/CoralPositions", coralPoses);
}
}
21 changes: 21 additions & 0 deletions src/main/java/frc/robot/commands/CloseClawCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.ClawSubsystem.ClawSubsystem;

public class CloseClawCommand extends Command {
private final ClawSubsystem clawSubsystem;

public CloseClawCommand(ClawSubsystem clawSubsystem) {
this.clawSubsystem = clawSubsystem;
addRequirements(clawSubsystem);
}

public void initialize() {
clawSubsystem.close();
}

public boolean isFinished() {
return true;
}
}
21 changes: 21 additions & 0 deletions src/main/java/frc/robot/commands/IntakePickupCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.AlgaeIntakeSubsystem.AlgaeIntakeSubsystem;

public class IntakePickupCommand extends Command {
private final AlgaeIntakeSubsystem intakeSubsystem;

public IntakePickupCommand(AlgaeIntakeSubsystem intakeSubsystem) {
this.intakeSubsystem = intakeSubsystem;
addRequirements(intakeSubsystem);
}

public void initialize() {
intakeSubsystem.pickup();
}

public boolean isFinished() {
return true;
}
}

4 changes: 0 additions & 4 deletions src/main/java/frc/robot/commands/OpenClaw.java

This file was deleted.

22 changes: 22 additions & 0 deletions src/main/java/frc/robot/commands/OpenClawCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.ClawSubsystem.ClawSubsystem;

public class OpenClawCommand extends Command {
private final ClawSubsystem clawSubsystem;

public OpenClawCommand(ClawSubsystem clawSubsystem) {
this.clawSubsystem = clawSubsystem;
addRequirements(clawSubsystem);
}

public void initialize() {
clawSubsystem.open();
}

public boolean isFinished() {
return true;
}
}

13 changes: 13 additions & 0 deletions src/main/java/frc/robot/constants/ClawConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package frc.robot.constants;

import edu.wpi.first.math.system.plant.DCMotor;

public class ClawConstants {
public static DCMotor bigGearBox = new DCMotor(1, 0.5, 0.5, 0.5, 0.2, 1);
public static DCMotor smallGearBox = new DCMotor(1, 0.5, 0.5, 0.5, 0.2, 1);
public static double gearing = 0.1;
public static double kP = 0.0;
public static double kI = 0.0;
public static double kD = 0.0;
public static double mainSetpoint = 1.0;
}
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/constants/DriveConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public class DriveConstants {
public static final int frontRightTurnCanId = 6;
public static final int backRightTurnCanId = 8;

// Encoder Ports

public static final int frontLeftEncoderPort = 3;
public static final int frontRightEncoderPort = 2;
public static final int backLeftEncoderPort = 0;
public static final int backRightEncoderPort = 1;


// Drive motor configuration
public static final int driveMotorCurrentLimit = 50;
public static final double wheelRadiusMeters = TunerConstants.FrontLeft.WheelRadius;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/frc/robot/constants/IntakeConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package frc.robot.constants;

import edu.wpi.first.math.system.plant.DCMotor;

public class IntakeConstants {
public static DCMotor pivotGearBox = new DCMotor(1, 0.5, 0.5, 0.5, 0.2, 1);
public static DCMotor rollersGearBox = new DCMotor(1, 0.5, 0.5, 0.5, 0.2, 1);
public static double gearing = 0.1;
public static double pivotRotation = 0.3;
public static double kP = 0.0;
public static double kI = 0.0;
public static double kD = 0.0;
public static double rollerVoltsTarget = 1.0;
public static double pivotVoltsTarget = 1.0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.subsystems.AlgaeIntakeSubsystem;

import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class AlgaeIntakeSubsystem extends SubsystemBase {
private final IntakeIO intake;

public AlgaeIntakeSubsystem(IntakeIO intake){
this.intake = intake;
}

public void pickup() {
intake.pivotDown();
intake.pivotUp();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package frc.robot.subsystems.AlgaeIntakeSubsystem;

public interface IntakeEncoderIO {
public class IntakeEncoderInputs {
public static double velocityUnitsPerSec = 0.0;
public static double distance = 0.0;
}

public default double getPivotDistance() { return 0.0; }


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package frc.robot.subsystems.AlgaeIntakeSubsystem;

public class IntakeEncoderIOSim implements IntakeEncoderIO {
public IntakeEncoderIOSim() {

}

@Override
public double getPivotDistance() {
return 0.0;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.subsystems.AlgaeIntakeSubsystem;

import edu.wpi.first.math.controller.PIDController;
import frc.robot.subsystems.ClawSubsystem.EndEffectorEncoderIO;
import org.littletonrobotics.junction.AutoLog;

public interface IntakeIO {
@AutoLog
public class IntakeInputsAutoLogged {
public boolean hasCoral = false;
public boolean isRunning = false;
public double rollersVoltage = 0.0;
public double pivotVoltage = 0.0;
}

public default void setRunning(boolean state) {}
public default void pivotDown() {}
public default void pivotUp() {}
public default boolean getIsRunning() { return false; }
public default boolean coralInside() { return false; }
public default void updateInputs(IntakeInputsAutoLogged inputs) {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package frc.robot.subsystems.AlgaeIntakeSubsystem;

import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.math.system.plant.LinearSystemId;
import edu.wpi.first.wpilibj.simulation.DCMotorSim;
import frc.robot.constants.IntakeConstants;
import org.ironmaple.simulation.IntakeSimulation;
import org.ironmaple.simulation.drivesims.SwerveDriveSimulation;

import static edu.wpi.first.units.Units.Meters;

public class IntakeIOSim implements IntakeIO{
private final SwerveDriveSimulation driveSim;
private final IntakeSimulation intakeSim;
private boolean isRunning = false;
private final IntakeEncoderIOSim encoder = new IntakeEncoderIOSim();

private final DCMotorSim pivotWheel = new DCMotorSim(
LinearSystemId.createDCMotorSystem(IntakeConstants.pivotGearBox, 0.1, IntakeConstants.gearing),
IntakeConstants.pivotGearBox
);

private final DCMotorSim rollers = new DCMotorSim(
LinearSystemId.createDCMotorSystem(IntakeConstants.rollersGearBox, 0.1, IntakeConstants.gearing),
IntakeConstants.rollersGearBox
);

public IntakeIOSim(SwerveDriveSimulation driveSim) {
this.driveSim = driveSim;
this.intakeSim = IntakeSimulation.OverTheBumperIntake(
"Coral",
driveSim,
Meters.of(0.4),
Meters.of(0.2),
IntakeSimulation.IntakeSide.BACK, //where intake is attatched
1);
}

@Override
public void setRunning(boolean state) {
if (state) {
intakeSim.startIntake();
rollers.setInputVoltage(IntakeConstants.rollerVoltsTarget);
isRunning = true;
} else {
intakeSim.stopIntake();
rollers.setInputVoltage(0.0);
isRunning = false;
}
}

@Override
public void pivotDown() {
pivotWheel.setInputVoltage(IntakeConstants.pivotVoltsTarget);
setRunning(true);
}

@Override
public void pivotUp() {
setRunning(false);
pivotWheel.setInputVoltage(IntakeConstants.pivotVoltsTarget);
}

@Override
public boolean coralInside() {
return intakeSim.getGamePiecesAmount() != 0;
}

@Override
public boolean getIsRunning() {
return isRunning;
}

@Override
public void updateInputs(IntakeInputsAutoLogged inputs) {
inputs.hasCoral = coralInside();
inputs.isRunning = getIsRunning();
inputs.rollersVoltage = rollers.getInputVoltage();
inputs.pivotVoltage = pivotWheel.getInputVoltage();
}


}
Loading