Skip to content

Commit 46e2341

Browse files
committed
Show number bot substitutions left and time left
1 parent 0cb3351 commit 46e2341

File tree

6 files changed

+99
-26
lines changed

6 files changed

+99
-26
lines changed

frontend/src/components/StatusBar.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const online = ref(false)
88
const team = ref(Team.UNKNOWN)
99
const maxRobots = ref(0)
1010
const numRobots = ref(0)
11+
const diffRobots = ref("")
1112
const yellowCardsDue = ref(defaultYellowCardsDue)
1213
const api = inject<ApiController>('api')
1314
let onlineTimer: NodeJS.Timeout
@@ -27,6 +28,8 @@ api?.RegisterStateConsumer((s) => {
2728
team.value = s.team || Team.UNKNOWN
2829
maxRobots.value = s.maxRobots
2930
numRobots.value = s.robotsOnField
31+
const robotDiff = s.maxRobots - s.robotsOnField
32+
diffRobots.value = robotDiff <= 0 ? `${robotDiff}` : `+${robotDiff}`
3033
yellowCardsDue.value = s.yellowCardsDue.sort((a: number, b: number) => a - b)
3134
if (onlineTimer) {
3235
clearTimeout(onlineTimer)
@@ -44,7 +47,7 @@ online.value = false
4447

4548
<div class="left-bar">
4649
<div class="left-bar-element">
47-
Robots: <strong>{{ numRobots }}</strong> / <strong>{{ maxRobots }}</strong>
50+
Robots: <strong>{{ numRobots }}</strong> / <strong>{{ maxRobots }}</strong> (<strong>{{ diffRobots }}</strong>)
4851
</div>
4952
<div class="left-bar-element">
5053
Yellow cards due:

frontend/src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ if (import.meta.env.PROD) {
2020
timeoutsLeft: 0,
2121
timeoutTimeLeft: 0,
2222
canSubstituteRobot: false,
23+
botSubstitutionsLeft: 0,
24+
botSubstitutionTimeLeft: 0,
2325
}
2426
} else {
2527
latestState = {
@@ -39,6 +41,8 @@ if (import.meta.env.PROD) {
3941
timeoutsLeft: 4,
4042
timeoutTimeLeft: 251.5,
4143
canSubstituteRobot: false,
44+
botSubstitutionsLeft: 5,
45+
botSubstitutionTimeLeft: 1.5,
4246
}
4347
}
4448

frontend/src/proto/ssl_gc_rcon_remotecontrol.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ export interface RemoteControlTeamState {
174174
yellowCardsDue: number[];
175175
/** if true, team is allowed to substitute robots */
176176
canSubstituteRobot: boolean;
177+
/** number of bot substitutions left by the team in this halftime */
178+
botSubstitutionsLeft: number;
179+
/** number of seconds left for current bot substitution */
180+
botSubstitutionTimeLeft: number;
177181
}
178182

179183
function createBaseRemoteControlRegistration(): RemoteControlRegistration {
@@ -507,6 +511,8 @@ function createBaseRemoteControlTeamState(): RemoteControlTeamState {
507511
robotsOnField: 0,
508512
yellowCardsDue: [],
509513
canSubstituteRobot: false,
514+
botSubstitutionsLeft: 0,
515+
botSubstitutionTimeLeft: 0,
510516
};
511517
}
512518

@@ -554,6 +560,12 @@ export const RemoteControlTeamState = {
554560
if (message.canSubstituteRobot === true) {
555561
writer.uint32(88).bool(message.canSubstituteRobot);
556562
}
563+
if (message.botSubstitutionsLeft !== 0) {
564+
writer.uint32(104).uint32(message.botSubstitutionsLeft);
565+
}
566+
if (message.botSubstitutionTimeLeft !== 0) {
567+
writer.uint32(117).float(message.botSubstitutionTimeLeft);
568+
}
557569
return writer;
558570
},
559571

@@ -675,6 +687,20 @@ export const RemoteControlTeamState = {
675687

676688
message.canSubstituteRobot = reader.bool();
677689
continue;
690+
case 13:
691+
if (tag != 104) {
692+
break;
693+
}
694+
695+
message.botSubstitutionsLeft = reader.uint32();
696+
continue;
697+
case 14:
698+
if (tag != 117) {
699+
break;
700+
}
701+
702+
message.botSubstitutionTimeLeft = reader.float();
703+
continue;
678704
}
679705
if ((tag & 7) == 4 || tag == 0) {
680706
break;
@@ -702,6 +728,8 @@ export const RemoteControlTeamState = {
702728
robotsOnField: isSet(object.robotsOnField) ? Number(object.robotsOnField) : 0,
703729
yellowCardsDue: Array.isArray(object?.yellowCardsDue) ? object.yellowCardsDue.map((e: any) => Number(e)) : [],
704730
canSubstituteRobot: isSet(object.canSubstituteRobot) ? Boolean(object.canSubstituteRobot) : false,
731+
botSubstitutionsLeft: isSet(object.botSubstitutionsLeft) ? Number(object.botSubstitutionsLeft) : 0,
732+
botSubstitutionTimeLeft: isSet(object.botSubstitutionTimeLeft) ? Number(object.botSubstitutionTimeLeft) : 0,
705733
};
706734
},
707735

@@ -731,6 +759,8 @@ export const RemoteControlTeamState = {
731759
obj.yellowCardsDue = [];
732760
}
733761
message.canSubstituteRobot !== undefined && (obj.canSubstituteRobot = message.canSubstituteRobot);
762+
message.botSubstitutionsLeft !== undefined && (obj.botSubstitutionsLeft = Math.round(message.botSubstitutionsLeft));
763+
message.botSubstitutionTimeLeft !== undefined && (obj.botSubstitutionTimeLeft = message.botSubstitutionTimeLeft);
734764
return obj;
735765
},
736766

@@ -752,6 +782,8 @@ export const RemoteControlTeamState = {
752782
message.robotsOnField = object.robotsOnField ?? 0;
753783
message.yellowCardsDue = object.yellowCardsDue?.map((e) => e) || [];
754784
message.canSubstituteRobot = object.canSubstituteRobot ?? false;
785+
message.botSubstitutionsLeft = object.botSubstitutionsLeft ?? 0;
786+
message.botSubstitutionTimeLeft = object.botSubstitutionTimeLeft ?? 0;
755787
return message;
756788
},
757789
};

frontend/src/views/ControlButtons.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ const emergencyStopRequested = computed(() => state.value.activeRequests.include
2525
const timeoutRequested = computed(() => state.value.activeRequests.includes(RemoteControlRequestType.TIMEOUT))
2626
const robotSubstitutionRequested = computed(() => state.value.activeRequests.includes(RemoteControlRequestType.ROBOT_SUBSTITUTION))
2727
const robotDiff = computed(() => {
28-
const diff = state.value.maxRobots - state.value.robotsOnField
29-
if (diff > 0) {
30-
return `Add up to ${diff} robots`
28+
const botSubstitutionsLeftMsg = `${state.value.botSubstitutionsLeft} free left`
29+
if (state.value.botSubstitutionTimeLeft > 0) {
30+
return `${botSubstitutionsLeftMsg} (${Math.round(state.value.botSubstitutionTimeLeft)} s)`
3131
}
32-
if (diff < 0) {
33-
return `Remove ${diff} robots`
32+
return botSubstitutionsLeftMsg
33+
})
34+
const botSubstitutionRequestedMsg = computed(() => {
35+
if (state.value.canSubstituteRobot) {
36+
return 'Finish Robot Substitution'
3437
}
35-
return ''
38+
return 'Cancel Robot Substitution Request'
3639
})
3740
3841
const requestChallengeFlag = () => router.push('/confirm-challenge-flag')
@@ -107,8 +110,8 @@ const requestRobotSubstitution = (request: boolean) => api?.Send({
107110
class="two-columns"
108111
:can-request="canRequestRobotSubstitution"
109112
:requested="robotSubstitutionRequested"
110-
text="Robot Substitution"
111-
text-requested="Stop Robot Substitution"
113+
text="Request Robot Substitution"
114+
:text-requested="botSubstitutionRequestedMsg"
112115
:text-additional="robotDiff"
113116
@request="requestRobotSubstitution"
114117
/>

internal/rcon/ssl_gc_rcon_remotecontrol.pb.go

Lines changed: 42 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ssl_gc_rcon_remotecontrol.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ message RemoteControlTeamState {
9797

9898
// if true, team is allowed to substitute robots
9999
optional bool can_substitute_robot = 11;
100+
101+
// number of bot substitutions left by the team in this halftime
102+
optional uint32 bot_substitutions_left = 13;
103+
104+
// number of seconds left for current bot substitution
105+
optional float bot_substitution_time_left = 14;
100106
}
101107

102108
// All possible request types that the remote control can make

0 commit comments

Comments
 (0)