Skip to content

Commit 41e9404

Browse files
Pez357DylanTaylor29nlaverdurecaparomula
authored
Leds (#101)
* added feedforward to the elevator * changed most things to units updated the kV * added feedforward values to constants * Changed internal elevator logic to meters * added kg and changed ks * Updates for new robot * Merge and fix * Remove unused imports * added method that refreshes the relative turning encoder every 0.1 seconds * ran spotless * added DIO ports and leds for auto selector * fixed issues with overlapping DIO ports * fixed auto selector to display correct value * added the rest of the auto routines * changed climber deploy position to 14 inches and created branch for practice testing * tweakd elevator heights and intake voltages * Added algaemode indicator LEDs * fix auto selector * reanabled default command * Remove unused imports * more robot tweaks * Mostly re-wrote the LED code. * Added some comments, did a little cleanup * added command for retracting the climber to a position * fixed elevator feed forward, tested and worked * more tuning * Remove unused imports * Added intake/outtake annimation, ran spotless. * cancelled all running led commands on init (yet to be tested) * led commands change with game state * Animate scrolling blocks of appropriate color on intake/outtake * Remove teleop periodic call to LED subsystem * Added simple implementation for displayPoseSeek() * Ran spotless * Fix swapped rotation colors * Make sure to clear bottom segment that is not lit. * tweaked units for better accuracy * Remove timeout from roller animation command. Add some debug code. * Add method to immediately replace default command on LED subsystem * Added method to LEDs to immediately replace default command * Change some pose-seek display colors * spotless * Removed some unused variables * removed unused imports * Increase middle segment size, reduce animation speed, use RPM threshold to determine roller motion. Animations still only going one direction. Believe somehow the logic for determining whether it's intake or outtake is incorrect in a subtle way. * Fix logic to use dynamic values in animation command instead of fixing the ones at command creation time. * spotless * Initialize color and roller direction on Command.initialize() so it uses the state when the command is first scheduled. * Overlay auto selection on top of pose-seek info. * Added stub to create effect on auto selection * Fix null object in Optional * added the andymark april tag layout * Fixed hasAlgae typo * spotless --------- Co-authored-by: DylanTaylor29 <[email protected]> Co-authored-by: nlaverdure <[email protected]> Co-authored-by: Christopher Larrieu <[email protected]>
1 parent 4e18380 commit 41e9404

File tree

10 files changed

+723
-125
lines changed

10 files changed

+723
-125
lines changed

src/main/java/frc/lib/AutoOption.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import edu.wpi.first.math.geometry.Pose2d;
44
import edu.wpi.first.wpilibj.DriverStation.Alliance;
5+
import edu.wpi.first.wpilibj.util.Color;
56
import edu.wpi.first.wpilibj2.command.Command;
67
import frc.robot.auto.AutoMode;
8+
import frc.util.Util;
79
import java.util.Optional;
810

911
public class AutoOption {
@@ -37,14 +39,21 @@ public AutoOption(Alliance color, int option) {
3739
/**
3840
* @return Alliance for which the option is valid
3941
*/
40-
public Alliance getColor() {
42+
public Alliance getAlliance() {
4143
return this.allianceColor;
4244
}
4345

46+
/**
47+
* @return Color of the associated alliance
48+
*/
49+
public Color getAllianceColor() {
50+
return Util.allianceToColor(getAlliance());
51+
}
52+
4453
/**
4554
* @return Selector switch index for which the option is valid
4655
*/
47-
public int getOption() {
56+
public int getOptionNumber() {
4857
return this.switchNumber;
4958
}
5059

src/main/java/frc/lib/AutoSelector.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Optional;
1616
import java.util.function.Supplier;
1717

18-
public class AutoSelector {
18+
public class AutoSelector implements Supplier<Optional<AutoOption>> {
1919

2020
private Optional<AutoOption> currentAutoOption;
2121
private DigitalInput[] switchPositions;
@@ -72,14 +72,14 @@ public int getBinarySwitchPosition() {
7272
return sum;
7373
}
7474

75-
private Alliance getAllianceColor() {
75+
private Alliance getAlliance() {
7676
return allianceColorSupplier.get();
7777
}
7878

7979
private Optional<AutoOption> findMatchingOption() {
8080
return autoOptions.stream()
81-
.filter(o -> o.getColor() == getAllianceColor())
82-
.filter(o -> o.getOption() == getBinarySwitchPosition())
81+
.filter(o -> o.getAlliance() == getAlliance())
82+
.filter(o -> o.getOptionNumber() == getBinarySwitchPosition())
8383
.findFirst();
8484
}
8585

@@ -92,6 +92,11 @@ private boolean updateAuto() {
9292
return true;
9393
}
9494

95+
@Override
96+
public Optional<AutoOption> get() {
97+
return currentAutoOption;
98+
}
99+
95100
/**
96101
* @return Object for binding a command to a change in autonomous mode selection
97102
*/

src/main/java/frc/robot/Constants.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import edu.wpi.first.units.measure.Time;
1818
import edu.wpi.first.wpilibj.Filesystem;
1919
import edu.wpi.first.wpilibj.TimedRobot;
20+
import edu.wpi.first.wpilibj.util.Color;
2021

2122
public final class Constants {
2223

@@ -294,9 +295,12 @@ public static final class ClimberConstants {
294295

295296
public static final class LedConstants {
296297
public static final int kLedPort = 9;
297-
public static final int kLedBufferLength = 40;
298+
public static final int kLedPixelCount = 40;
298299

299300
public static final int kLEDsPerBlock = 2;
300301
public static final int kLEDsBetweenBlocks = 1;
302+
303+
public static final Color algaeColor = Color.kGreen;
304+
public static final Color coralColor = Color.kCoral;
301305
}
302306
}

0 commit comments

Comments
 (0)