Skip to content

Commit

Permalink
Stack light Status (#158)
Browse files Browse the repository at this point in the history
Update stack light status to show disconnected robots during a match.
  • Loading branch information
ejordan376 authored Sep 30, 2023
1 parent 637732d commit 5dd21f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions field/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ func (arena *Arena) handlePlcInputOutput() {
redScore := &arena.RedRealtimeScore.CurrentScore
blueScore := &arena.BlueRealtimeScore.CurrentScore
redChargeStationLevel, blueChargeStationLevel := arena.Plc.GetChargeStationsLevel()
redAllianceReady := arena.checkAllianceStationsReady("R1", "R2", "R3") == nil
blueAllianceReady := arena.checkAllianceStationsReady("B1", "B2", "B3") == nil

switch arena.MatchState {
case PreMatch:
Expand All @@ -843,8 +845,6 @@ func (arena *Arena) handlePlcInputOutput() {
case PostTimeout:
// Set the stack light state -- solid alliance color(s) if robots are not connected, solid orange if scores are
// not input, or blinking green if ready.
redAllianceReady := arena.checkAllianceStationsReady("R1", "R2", "R3") == nil
blueAllianceReady := arena.checkAllianceStationsReady("B1", "B2", "B3") == nil
greenStackLight := redAllianceReady && blueAllianceReady && arena.Plc.GetCycleState(2, 0, 2)
arena.Plc.SetStackLights(!redAllianceReady, !blueAllianceReady, false, greenStackLight)
arena.Plc.SetStackBuzzer(redAllianceReady && blueAllianceReady)
Expand Down Expand Up @@ -883,14 +883,15 @@ func (arena *Arena) handlePlcInputOutput() {
}
case AutoPeriod:
arena.Plc.SetStackBuzzer(false)
arena.Plc.SetStackLights(false, false, false, true)
arena.Plc.SetStackLights(!redAllianceReady, !blueAllianceReady, false, true)
fallthrough
case PausePeriod:
// Game-specific PLC functions.
arena.Plc.SetChargeStationLights(redChargeStationLevel, blueChargeStationLevel)
case TeleopPeriod:
// Game-specific PLC functions.
arena.Plc.SetChargeStationLights(redChargeStationLevel, blueChargeStationLevel)
arena.Plc.SetStackLights(!redAllianceReady, !blueAllianceReady, false, true)
if arena.lastMatchState != TeleopPeriod {
// Capture a single reading of the charge station levels after the autonomous pause.
redScore.AutoChargeStationLevel, blueScore.AutoChargeStationLevel = arena.Plc.GetChargeStationsLevel()
Expand Down

0 comments on commit 5dd21f1

Please sign in to comment.