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

Algae #29

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
85ae7c0
Added an elevator coral and elevator algae subsystem
Merridew1 Jan 18, 2025
ee5f669
fixed ak
txrnqt Jan 18, 2025
9ef2be1
fixed io issues
txrnqt Jan 18, 2025
6888511
fixed some linting errors
Merridew1 Jan 22, 2025
a5d54f8
fixed more linting
Merridew1 Jan 22, 2025
5cc5d8f
more linting
Merridew1 Jan 22, 2025
41fc4b4
linting test
Merridew1 Jan 22, 2025
8306024
added asterisk
Merridew1 Jan 22, 2025
97f33f6
More linting-added tags
Merridew1 Jan 22, 2025
54afce1
got rid of coral, added neutral config
Merridew1 Jan 22, 2025
c80d775
added hasAlgae
Merridew1 Jan 23, 2025
3eecb7f
fixed method names to be consistent
Merridew1 Jan 23, 2025
4c32beb
fixed commands and removed non java file
Merridew1 Jan 24, 2025
577ee27
added stop when algae is present
Merridew1 Jan 24, 2025
c0a91e4
fixed hasAlgae
Merridew1 Jan 24, 2025
40fa314
trigger needed
Merridew1 Jan 24, 2025
1de24f8
added algae led trigger (unimplemented yet)
Merridew1 Jan 24, 2025
e07f912
Merge branch 'main' into Algae
Merridew1 Jan 25, 2025
098de47
Merge branch 'main' into Algae
Merridew1 Jan 25, 2025
cb22cc3
added import for instantcommand
Merridew1 Jan 25, 2025
b91170a
fixed linting again
Merridew1 Jan 25, 2025
7a88fb2
fixed linting
Merridew1 Jan 25, 2025
80e928d
Merge remote-tracking branch 'origin/main' into Algae
Merridew1 Jan 26, 2025
a48e957
binded has algae led to a trigger, added real runtime type
Merridew1 Jan 26, 2025
5d8af87
Merge branch 'main' into Algae
Merridew1 Feb 1, 2025
b6178c3
Merge branch 'main' into Algae
Merridew1 Feb 1, 2025
69c7508
fixed comments from github
Merridew1 Feb 1, 2025
6ebdb82
Merge branch 'main' into Algae, updated CAN IDs for coral and algae
Merridew1 Feb 7, 2025
c344076
linting
Merridew1 Feb 7, 2025
23e3f10
fixed leds command
Merridew1 Feb 7, 2025
06a996a
temporary test bindings
Merridew1 Feb 7, 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
19 changes: 19 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,31 @@ public final class Constants {
public static final int operatorId = 1;

public static final boolean tuningMode = false;
/**
* Current threshold that indicates an algae is in possestion
*/
public static final double HAS_ALGAE_CURRENT_THRESHOLD = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the prototype and see if this logic works


/**
* Algae misc values
*/
public static final class Algae {
public static final int VOLTAGE = 0;
public static final int NEGATIVE_VOLTAGE = 0;
public static final int BEAM_BRAKE_ID = 0;
}
/**
* Motor CAN id's.
*/

Merridew1 marked this conversation as resolved.
Show resolved Hide resolved

public static final class Motors {
/**
* Algae Motor CAN id's
*/
public static final class AlgaeMotors {
public static final int ALGAE_MOTOR_ID = 0;
}

}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.lib.util.viz.FieldViz;
import frc.lib.util.viz.Viz2025;
import frc.robot.Robot.RobotRunType;
import frc.robot.subsystems.LEDs;
import frc.robot.subsystems.elevator_algae.ElevatorAlgae;
import frc.robot.subsystems.swerve.Swerve;
import frc.robot.subsystems.swerve.SwerveIO;
import frc.robot.subsystems.swerve.SwerveReal;
Expand Down Expand Up @@ -48,11 +50,15 @@ public class RobotContainer {
private final RobotState state;

/* Subsystems */

private ElevatorAlgae s_ElevatorAlgae;
private LEDs leds = new LEDs();
private final Swerve s_Swerve;
private final Vision s_Vision;

/* Triggers */
private Trigger algaeInIntake = new Trigger(() -> s_ElevatorAlgae.hasAlgae());


/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
Expand Down Expand Up @@ -90,6 +96,12 @@ public RobotContainer(RobotRunType runtimeType) {
* {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings(RobotRunType runtimeType) {
driver.rightBumper()
.whileTrue(s_ElevatorAlgae.setMotorVoltageCommand(Constants.Algae.VOLTAGE));
driver.leftBumper()
.whileTrue(s_ElevatorAlgae.setMotorVoltageCommand(Constants.Algae.NEGATIVE_VOLTAGE));


driver.y().onTrue(new InstantCommand(() -> s_Swerve.resetFieldRelativeOffset()));
driver.a().onTrue(new Command() {
Timer timer = new Timer();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package frc.robot.subsystems.elevator_algae;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;

/**
* Elevator Algae class
*/
public class ElevatorAlgae extends SubsystemBase {
ElevatorAlgaeIO io;
AlgaeIOInputsAutoLogged inputs = new AlgaeIOInputsAutoLogged();

/*
* Constructor for Elevator Algae class
*/
public ElevatorAlgae(ElevatorAlgaeIO io) {
this.io = io;
io.updateInputs(inputs);
}

@Override
public void periodic() {
io.updateInputs(inputs);
}


public void setAlgaeMotorVoltage(double voltage) { // set motor speed function
io.setAlgaeMotorVoltage(voltage);
}

public boolean hasAlgae() {
legoguy1000 marked this conversation as resolved.
Show resolved Hide resolved
return inputs.algaeMotorCurrent > Constants.HAS_ALGAE_CURRENT_THRESHOLD;
}

public Command setMotorVoltageCommand(double speed) { // set motor speed Command
return runEnd(() -> setAlgaeMotorVoltage(speed), () -> setAlgaeMotorVoltage(0))
.until(() -> hasAlgae());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package frc.robot.subsystems.elevator_algae;

import org.littletonrobotics.junction.AutoLog;

/**
* elevator algae io class
*/
public interface ElevatorAlgaeIO {
/**
* Elevator Algae inputs
*/
@AutoLog
public class AlgaeIOInputs {
double algaeMotorCurrent;
boolean beamBrakeStatus;
}

public default void setAlgaeMotorVoltage(double voltage) {}

public default void updateInputs(AlgaeIOInputs inputs) {}

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

import com.revrobotics.spark.SparkBase.PersistMode;
import com.revrobotics.spark.SparkBase.ResetMode;
import com.revrobotics.spark.SparkFlex;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
import com.revrobotics.spark.config.SparkFlexConfig;
import frc.robot.Constants;

/**
* Algae Real Class
*/
public class ElevatorAlgaeReal implements ElevatorAlgaeIO {
private final SparkFlex algaeMotor = // Algae motor
new SparkFlex(Constants.Motors.AlgaeMotors.ALGAE_MOTOR_ID, MotorType.kBrushless);
private final SparkFlexConfig algaeMotorConfig = new SparkFlexConfig();

/**
* Algae Real constructor
*/
public ElevatorAlgaeReal() {
algaeMotorConfig.idleMode(IdleMode.kBrake);
algaeMotor.configure(algaeMotorConfig, ResetMode.kResetSafeParameters,
PersistMode.kPersistParameters);
}

@Override
public void updateInputs(AlgaeIOInputs inputs) { // update inputs to IO layer
inputs.algaeMotorCurrent = algaeMotor.getOutputCurrent();
}

@Override
public void setAlgaeMotorVoltage(double voltage) { // set hardware speed
algaeMotor.setVoltage(voltage);
}

}
4 changes: 2 additions & 2 deletions vendordeps/maple-sim.json
Merridew1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "maple-sim.json",
"name": "maplesim",
"version": "0.3.2",
"version": "0.3.1",
"frcYear": "2025",
"uuid": "c39481e8-4a63-4a4c-9df6-48d91e4da37b",
"mavenUrls": [
Expand All @@ -13,7 +13,7 @@
{
"groupId": "org.ironmaple",
"artifactId": "maplesim-java",
"version": "0.3.2"
"version": "0.3.1"
},
{
"groupId": "org.dyn4j",
Expand Down
Loading