Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
09cd8f4
started climb io layers
imroot07 Jan 11, 2025
cb0cb50
stubbed out climb subsystem
imroot07 Jan 11, 2025
f931e74
started the LEDsubsystem
PotatoBoyH4 Jan 16, 2025
66e4da0
did some small things
PotatoBoyH4 Jan 21, 2025
83a6794
made proggress in knowing what subdivisions to make. also made initia…
PotatoBoyH4 Jan 24, 2025
a78dcc7
spotlessApply
PotatoBoyH4 Jan 24, 2025
e8132ea
made Leds work on normal mode
PotatoBoyH4 Jan 25, 2025
1d4f932
added tons of setpoints
PotatoBoyH4 Jan 28, 2025
1376efc
added a ton of traj's. fixed small problems and started on flipping t…
PotatoBoyH4 Jan 29, 2025
cdc2512
started making our first full auton command
PotatoBoyH4 Jan 31, 2025
97a6220
added a bunch of measures to LEDSubsystem
PotatoBoyH4 Feb 3, 2025
494b88b
added a new constant to choreo, the deep startpoint
PotatoBoyH4 Feb 3, 2025
82e4acd
added some more setpoints and related paths
PotatoBoyH4 Feb 5, 2025
0f3cc2a
added climbing states.
PotatoBoyH4 Feb 5, 2025
4af74e2
fixed two constants
PotatoBoyH4 Feb 10, 2025
f3e3c6f
Merge branch 'main' into path-creation-1
PotatoBoyH4 Feb 10, 2025
eb0c5fc
added the game in LEDSubsystem
PotatoBoyH4 Feb 10, 2025
810c3c4
Merge branch 'main' into lights
PotatoBoyH4 Feb 11, 2025
daec791
changed some constants
BB7209 Feb 21, 2025
c6192e1
made all the nessecary changes
PotatoBoyH4 Feb 21, 2025
88599f9
edge cases
ds12a Feb 22, 2025
3a962d5
auto algae tuning
ds12a Feb 22, 2025
f562771
Merge branch 'main' into lights
mwitcpalek Feb 23, 2025
98a9de0
add LED subsystem calls to robotState
mwitcpalek Feb 23, 2025
732740f
clean up and vision testing
ds12a Feb 23, 2025
5af022c
light testing, color picking
ds12a Feb 23, 2025
0778ab5
Merge branch 'main' into lights
PotatoBoyH4 Feb 24, 2025
6c1f3b0
Merge branch 'lights' of https://github.com/strykeforce/reefscape int…
PotatoBoyH4 Feb 24, 2025
7025585
Merge branch 'main' into path-creation-1
PotatoBoyH4 Feb 24, 2025
773923a
post merge
PotatoBoyH4 Feb 24, 2025
a35af84
sort of did stuff
PotatoBoyH4 Feb 25, 2025
8f516bc
drive tuning
ds12a Feb 25, 2025
912f283
merge lights
ds12a Feb 25, 2025
867578b
defer processor stowing
ds12a Feb 25, 2025
e5d4307
fixed everything except pathHandler
PotatoBoyH4 Feb 25, 2025
9412d2e
initial v
ds12a Feb 25, 2025
c00bcde
merge path-creation-1
ds12a Feb 25, 2025
2d38ce9
drive practice
ds12a Feb 26, 2025
78886b0
untested vision adjustments
ds12a Feb 26, 2025
ce9a58b
fxs drive
ds12a Feb 26, 2025
95716d3
bump thirdcoast, fix swerve inversion problems
mwitcpalek Feb 26, 2025
a3da027
tag align tuning, yaw good
ds12a Feb 27, 2025
5a1e20b
First real commit. Focus before St. Joe is state machine.
KaydenLee456 Feb 28, 2025
91eaac2
only odometry drive
ds12a Feb 28, 2025
15d3efe
current
ds12a Feb 28, 2025
da4965c
bugs, end drive
ds12a Mar 1, 2025
a0beac7
autoscoring
ds12a Mar 1, 2025
27fd2f4
clean up
ds12a Mar 1, 2025
9b0c237
something
ds12a Mar 2, 2025
104c5c5
bad paths, good cameras
ds12a Mar 2, 2025
c2c3774
fix up so files build
mwitcpalek Mar 2, 2025
8f901c2
Merge branch 'climb' into comp-bot
mwitcpalek Mar 2, 2025
958bf02
add in initial climb test
mwitcpalek Mar 2, 2025
580deb6
constants tweak
mwitcpalek Mar 3, 2025
3f5bd10
add zero check to modules
mwitcpalek Mar 3, 2025
a5a42f7
Changed a few constants and stuff after testing
KaydenLee456 Mar 4, 2025
c8965d7
Hope this resolves build conflicts
KaydenLee456 Mar 4, 2025
d87287f
Added stuff to prepClimb, but IDK if it's right or not
KaydenLee456 Mar 5, 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
150 changes: 149 additions & 1 deletion src/main/java/frc/robot/constants/ClimbConstants.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,151 @@
package frc.robot.constants;

public class ClimbConstants {}
import static edu.wpi.first.units.Units.Degrees;
import static edu.wpi.first.units.Units.DegreesPerSecond;

import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.HardwareLimitSwitchConfigs;
import com.ctre.phoenix6.configs.MotionMagicConfigs;
import com.ctre.phoenix6.configs.MotorOutputConfigs;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.SoftwareLimitSwitchConfigs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.signals.ForwardLimitSourceValue;
import com.ctre.phoenix6.signals.ForwardLimitTypeValue;
import com.ctre.phoenix6.signals.GravityTypeValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.ctre.phoenix6.signals.ReverseLimitSourceValue;
import com.ctre.phoenix6.signals.ReverseLimitTypeValue;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.AngularVelocity;

public class ClimbConstants {
public static int kWheelFxId = 0;
public static int kArmFxId = 0;

public static final AngularVelocity kWheelCloseEnough = DegreesPerSecond.of(5.0);
public static final Angle kArmCloseEnough = Degrees.of(5.0);
public static final Angle kArmMaxFwd = Degrees.of(100);
public static final Angle kArmMaxRev = Degrees.of(-100);
public static final Angle kArmZeroTicks = Degrees.of(1530);

public static TalonFXConfiguration getWheelFXConfig() {
TalonFXConfiguration wheelFxConfig = new TalonFXConfiguration();

CurrentLimitsConfigs current =
new CurrentLimitsConfigs()
.withStatorCurrentLimit(10)
.withStatorCurrentLimitEnable(false)
.withStatorCurrentLimit(20)
.withSupplyCurrentLimit(10)
.withSupplyCurrentLowerLimit(8)
.withSupplyCurrentLowerTime(0.02)
.withSupplyCurrentLimitEnable(true);
wheelFxConfig.CurrentLimits = current;

HardwareLimitSwitchConfigs hwLimit =
new HardwareLimitSwitchConfigs()
.withForwardLimitAutosetPositionEnable(false)
.withForwardLimitEnable(false)
.withForwardLimitType(ForwardLimitTypeValue.NormallyOpen)
.withForwardLimitSource(ForwardLimitSourceValue.LimitSwitchPin)
.withReverseLimitAutosetPositionEnable(false)
.withReverseLimitEnable(false)
.withReverseLimitType(ReverseLimitTypeValue.NormallyOpen)
.withReverseLimitSource(ReverseLimitSourceValue.LimitSwitchPin);
wheelFxConfig.HardwareLimitSwitch = hwLimit;

Slot0Configs slot0 =
new Slot0Configs()
.withKP(0)
.withKI(0)
.withKD(0)
.withGravityType(GravityTypeValue.Elevator_Static)
.withKG(0)
.withKS(0)
.withKV(0)
.withKA(0);
wheelFxConfig.Slot0 = slot0;

MotionMagicConfigs motionMagic =
new MotionMagicConfigs()
.withMotionMagicAcceleration(0)
.withMotionMagicCruiseVelocity(0)
.withMotionMagicExpo_kA(0)
.withMotionMagicExpo_kV(0)
.withMotionMagicJerk(0);
wheelFxConfig.MotionMagic = motionMagic;

MotorOutputConfigs motorOut =
new MotorOutputConfigs()
.withDutyCycleNeutralDeadband(0.01)
.withNeutralMode(NeutralModeValue.Coast);
wheelFxConfig.MotorOutput = motorOut;

return wheelFxConfig;
}

public static TalonFXConfiguration getArmFxConfig() {
TalonFXConfiguration armFxConfig = new TalonFXConfiguration();

CurrentLimitsConfigs current =
new CurrentLimitsConfigs()
.withStatorCurrentLimit(10)
.withStatorCurrentLimitEnable(false)
.withStatorCurrentLimit(20)
.withSupplyCurrentLimit(10)
.withSupplyCurrentLowerLimit(8)
.withSupplyCurrentLowerTime(0.02)
.withSupplyCurrentLimitEnable(true);
armFxConfig.CurrentLimits = current;

HardwareLimitSwitchConfigs hwLimit =
new HardwareLimitSwitchConfigs()
.withForwardLimitAutosetPositionEnable(false)
.withForwardLimitEnable(false)
.withForwardLimitType(ForwardLimitTypeValue.NormallyOpen)
.withForwardLimitSource(ForwardLimitSourceValue.LimitSwitchPin)
.withReverseLimitAutosetPositionEnable(false)
.withReverseLimitEnable(false)
.withReverseLimitType(ReverseLimitTypeValue.NormallyOpen)
.withReverseLimitSource(ReverseLimitSourceValue.LimitSwitchPin);
armFxConfig.HardwareLimitSwitch = hwLimit;

SoftwareLimitSwitchConfigs swLimit =
new SoftwareLimitSwitchConfigs()
.withForwardSoftLimitEnable(true)
.withForwardSoftLimitThreshold(kArmMaxFwd)
.withReverseSoftLimitEnable(true)
.withReverseSoftLimitThreshold(kArmMaxRev);
armFxConfig.SoftwareLimitSwitch = swLimit;

Slot0Configs slot0 =
new Slot0Configs()
.withKP(0)
.withKI(0)
.withKD(0)
.withGravityType(GravityTypeValue.Elevator_Static)
.withKG(0)
.withKS(0)
.withKV(0)
.withKA(0);
armFxConfig.Slot0 = slot0;

MotionMagicConfigs motionMagic =
new MotionMagicConfigs()
.withMotionMagicAcceleration(0)
.withMotionMagicCruiseVelocity(0)
.withMotionMagicExpo_kA(0)
.withMotionMagicExpo_kV(0)
.withMotionMagicJerk(0);
armFxConfig.MotionMagic = motionMagic;

MotorOutputConfigs motorOut =
new MotorOutputConfigs()
.withDutyCycleNeutralDeadband(0.01)
.withNeutralMode(NeutralModeValue.Coast);
armFxConfig.MotorOutput = motorOut;

return armFxConfig;
}
}
23 changes: 23 additions & 0 deletions src/main/java/frc/robot/subsystems/climb/ClimbArmIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package frc.robot.subsystems.climb;

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

import edu.wpi.first.units.measure.Angle;
import org.littletonrobotics.junction.AutoLog;
import org.strykeforce.telemetry.TelemetryService;

public interface ClimbArmIO {

@AutoLog
static class ClimbArmIOInputs {
public Angle position = Rotations.of(0.0);
}

public default void setPosition(Angle position) {}

public default void updateInputs(ClimbArmIOInputs inputs) {}

public default void zero() {}

public default void registerWith(TelemetryService telemetryService) {}
}
65 changes: 65 additions & 0 deletions src/main/java/frc/robot/subsystems/climb/ClimbArmIOFX.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package frc.robot.subsystems.climb;

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

import com.ctre.phoenix6.StatusSignal;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.configs.TalonFXConfigurator;
import com.ctre.phoenix6.controls.MotionMagicDutyCycle;
import com.ctre.phoenix6.hardware.TalonFX;
import edu.wpi.first.units.measure.Angle;
import frc.robot.constants.ClimbConstants;
import frc.robot.constants.ExampleConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClimbArmIOFX implements ClimbArmIO {
private Logger logger;
private TalonFX talonFx;

private final Angle absSensorInitial;
private Angle relSetpointOffset;
private Angle setpoint;

TalonFXConfigurator configurator;
private MotionMagicDutyCycle positionRequest =
new MotionMagicDutyCycle(0).withEnableFOC(false).withFeedForward(0).withSlot(0);
StatusSignal<Angle> curPosition;

public ClimbArmIOFX() {
logger = LoggerFactory.getLogger(this.getClass());
talonFx = new TalonFX(ClimbConstants.kArmFxId);
absSensorInitial =
talonFx.getPosition().getValue(); // relative encoder starts up as absolute position offset

configurator = talonFx.getConfigurator();
configurator.apply(new TalonFXConfiguration()); // Factory default motor controller
configurator.apply(ClimbConstants.getArmFxConfig());

curPosition = talonFx.getPosition();
}

@Override
public void setPosition(Angle position) {
setpoint = position.plus(relSetpointOffset);

logger.info("Setting position to {} rotations", setpoint.in(Rotations));

talonFx.setControl(positionRequest.withPosition(setpoint));
}

@Override
public void updateInputs(ClimbArmIOInputs inputs) {
inputs.position = curPosition.refresh().getValue();
}

@Override
public void zero() {
relSetpointOffset = ExampleConstants.kZeroTicks;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be able to actually write to the encoder as we will have an encoder on the shaft that tilts the cage in (using a winch) instead of saving off a zero

logger.info(
"Abs: {}, Zero Pos: {}, Offset: {}",
absSensorInitial,
ExampleConstants.kZeroTicks,
absSensorInitial.minus(ExampleConstants.kZeroTicks));
}
}
88 changes: 87 additions & 1 deletion src/main/java/frc/robot/subsystems/climb/ClimbSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,89 @@
package frc.robot.subsystems.climb;

public class ClimbSubsystem {}
import static edu.wpi.first.units.Units.Rotations;

import edu.wpi.first.units.measure.Angle;
import frc.robot.constants.ClimbConstants;
import frc.robot.standards.ClosedLoopPosSubsystem;
import java.util.Set;
import org.littletonrobotics.junction.Logger;
import org.strykeforce.telemetry.TelemetryService;
import org.strykeforce.telemetry.measurable.MeasurableSubsystem;
import org.strykeforce.telemetry.measurable.Measure;

public class ClimbSubsystem extends MeasurableSubsystem implements ClosedLoopPosSubsystem {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming most of these are because you aren't done yet but you'll need methods like the following:

  • setSpeed() for the wheels
  • startClimb() to initiate state machine
  • isClimbFinished() to check state

private final ClimbArmIO io;
private final ClimbWheelIO wheelIo;

private final ClimbArmIOInputsAutoLogged inputs = new ClimbArmIOInputsAutoLogged();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to add wheelIOInputsAutoLogged as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

may want to rename so it is clear which is armInputs and which is wheelInputs

private Angle setpoint = Rotations.of(0.0);
private ClimbState curState = ClimbState.INIT;

public ClimbSubsystem(ClimbArmIO io, ClimbWheelIO wheelIo) {
this.io = io;
this.wheelIo = wheelIo;

zero();
}

@Override
public Angle getPosition() {
return inputs.position;
}

@Override
public void setPosition(Angle position) {
io.setPosition(position);
}

@Override
public boolean isFinished() {
return setpoint.minus(inputs.position).abs(Rotations)
<= ClimbConstants.kArmCloseEnough.in(Rotations);
}

@Override
public void zero() {
io.zero();

curState = ClimbState.ZEROED;
}

@Override
public void periodic() {
// Read Inputs
io.updateInputs(inputs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add processInputs(), see example subsystem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will need to update/process both sets of inputs


// State Machine
switch (curState) {
case INIT:
break;
case ZEROED:
break;
default:
break;
}

// Log Outputs
Logger.recordOutput("Coral/curState", curState.ordinal());
Logger.recordOutput("Coral/setpoint", setpoint.in(Rotations));
}

@Override
public void registerWith(TelemetryService telemetryService) {
super.registerWith(telemetryService);
wheelIo.registerWith(telemetryService);
io.registerWith(telemetryService);
}

@Override
public Set<Measure> getMeasures() {
return Set.of();
}

public enum ClimbState {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Likely will end up having more states, but we probably don't know enough yet to write them

INIT,
ZEROED
}
}
10 changes: 10 additions & 0 deletions src/main/java/frc/robot/subsystems/climb/ClimbWheelIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package frc.robot.subsystems.climb;

import org.strykeforce.telemetry.TelemetryService;

public interface ClimbWheelIO {

public default void setPercent(double pct) {}

public default void registerWith(TelemetryService telemetryService) {}
}
37 changes: 37 additions & 0 deletions src/main/java/frc/robot/subsystems/climb/ClimbWheelIOFX.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package frc.robot.subsystems.climb;

import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.configs.TalonFXConfigurator;
import com.ctre.phoenix6.hardware.TalonFX;
import frc.robot.constants.ClimbConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.strykeforce.telemetry.TelemetryService;

public class ClimbWheelIOFX implements ClimbWheelIO {
private Logger logger;
private TalonFX talonFx;

TalonFXConfigurator configurator;

public ClimbWheelIOFX() {
logger = LoggerFactory.getLogger(this.getClass());
talonFx = new TalonFX(ClimbConstants.kWheelFxId);

configurator = talonFx.getConfigurator();
configurator.apply(new TalonFXConfiguration()); // Factory default motor controller
configurator.apply(ClimbConstants.getWheelFXConfig());
}

@Override
public void setPercent(double pct) {
logger.info("Setting percent to {}", pct);

talonFx.set(pct);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change this to a setControl with a dutycCycle request

}

@Override
public void registerWith(TelemetryService telemetryService) {
telemetryService.register(talonFx, true);
}
}
Loading