Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Create UNSET enum #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/common/ControlPanelColorSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public static enum ControlPanelColor {
RED(new Color(0.325, 0.453, 0.221)),
GREEN(new Color(0.269, 0.550, 0.181)),
BLUE(new Color(0.175, 0.469, 0.356)),
YELLOW(new Color(0.188, 0.503, 0.310));
YELLOW(new Color(0.188, 0.503, 0.310)),
UNSET(null);
Copy link
Member

Choose a reason for hiding this comment

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

I would actually make this UNKNOWN rather than UNSET because without context, if a color isn't one of those it's uknown. Only in the context of the driverstation sending a color is it unset. It'll also make sense if you return UNKNOWN when the confidence for the color matcher is low, whereas UNSET wouldn't make as much sense in that context

Copy link
Member

Choose a reason for hiding this comment

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

And I think you should give it a default value of either 0,0,0 or 1,1,1. Setting null will cause an NPE when the color matcher tries to match to it.


private Color color;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ControlPanelSubsystem extends SubsystemBase {
private WPI_VictorSPX cpMotor = new WPI_VictorSPX(CONTROL_PANEL_MOTOR);
private ControlPanelColorSensor colorSensor = new ControlPanelColorSensor(Port.kOnboard);
private DriverStation ds = DriverStation.getInstance();
private ControlPanelColor turnToColor;
private ControlPanelColor turnToColor = ControlPanelColor.UNSET;

public void spin(double speed) {
cpMotor.set(ControlMode.PercentOutput, speed);
Expand Down