Skip to content

Commit 5d8539e

Browse files
committed
Show a hint when ball needs to be placed manually
1 parent 1ebec47 commit 5d8539e

File tree

6 files changed

+268
-142
lines changed

6 files changed

+268
-142
lines changed

frontend/src/proto/ssl_gc_engine.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface GcState {
1313
trackers?: { [key: string]: string };
1414
/** the next actions that can be executed when continuing */
1515
continueActions?: ContinueAction[];
16+
/** the next actions that can be executed when continuing */
17+
continueHints?: ContinueHint[];
1618
}
1719

1820
export interface GcState_TeamStateEntry {
@@ -325,6 +327,10 @@ export function continueAction_StateToJSON(object: ContinueAction_State): string
325327
}
326328
}
327329

330+
export interface ContinueHint {
331+
message?: string;
332+
}
333+
328334
export const GcState = {
329335
fromJSON(object: any): GcState {
330336
return {
@@ -349,6 +355,9 @@ export const GcState = {
349355
continueActions: Array.isArray(object?.continueActions)
350356
? object.continueActions.map((e: any) => ContinueAction.fromJSON(e))
351357
: [],
358+
continueHints: Array.isArray(object?.continueHints)
359+
? object.continueHints.map((e: any) => ContinueHint.fromJSON(e))
360+
: [],
352361
};
353362
},
354363

@@ -377,6 +386,11 @@ export const GcState = {
377386
} else {
378387
obj.continueActions = [];
379388
}
389+
if (message.continueHints) {
390+
obj.continueHints = message.continueHints.map((e) => e ? ContinueHint.toJSON(e) : undefined);
391+
} else {
392+
obj.continueHints = [];
393+
}
380394
return obj;
381395
},
382396
};
@@ -564,6 +578,18 @@ export const ContinueAction = {
564578
},
565579
};
566580

581+
export const ContinueHint = {
582+
fromJSON(object: any): ContinueHint {
583+
return { message: isSet(object.message) ? String(object.message) : "" };
584+
},
585+
586+
toJSON(message: ContinueHint): unknown {
587+
const obj: any = {};
588+
message.message !== undefined && (obj.message = message.message);
589+
return obj;
590+
},
591+
};
592+
567593
function fromTimestamp(t: Timestamp): Date {
568594
let millis = t.seconds * 1_000;
569595
millis += t.nanos / 1_000_000;

frontend/src/views/MatchView.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const continueWithAction = (id: number) => {
2424
}
2525
}
2626
27+
const continueHints = computed(() => {
28+
return gcStore.gcState.continueHints || []
29+
})
30+
2731
const toggleAutoContinue = () => {
2832
control?.ChangeConfig({autoContinue: !gcStore.config.autoContinue})
2933
}
@@ -96,6 +100,12 @@ onUnmounted(() => {
96100
<SwitchSidesButton/>
97101
</div>
98102
</template>
103+
<template v-for="(hint, index) in continueHints" :key="index">
104+
<div class="row justify-center items-center">
105+
<q-icon name="warning" class="q-mx-sm"></q-icon>
106+
{{ hint.message }}
107+
</div>
108+
</template>
99109
<ContinueActionButtonList/>
100110
</div>
101111
<div class="col q-gutter-md q-mr-md" style="min-width: 300px">

internal/app/engine/process_continue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
func (e *Engine) processContinue() {
88

9-
e.gcState.ContinueActions = e.nextActions()
9+
e.gcState.ContinueActions, e.gcState.ContinueHints = e.nextActions()
1010

1111
var defaultAction = e.defaultAction()
1212
if *e.config.AutoContinue &&

internal/app/engine/process_continue_next_action.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package engine
22

33
import (
4+
"fmt"
45
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/geom"
56
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/state"
67
"log"
78
"math"
89
)
910

10-
func (e *Engine) nextActions() (actions []*ContinueAction) {
11+
func (e *Engine) nextActions() (actions []*ContinueAction, hints []*ContinueHint) {
1112
if e.currentState.Stage.IsPausedStage() {
1213
if *e.currentState.Stage.Next() != *e.currentState.Stage {
1314
actions = append(actions, createContinueAction(
@@ -134,6 +135,12 @@ func (e *Engine) nextActions() (actions []*ContinueAction) {
134135
placingTeam,
135136
ContinueAction_READY_AUTO,
136137
))
138+
} else {
139+
hint := fmt.Sprintf("Manually place the ball at x: %.2fm, y: %.2fm",
140+
*e.currentState.PlacementPos.X, *e.currentState.PlacementPos.Y)
141+
hints = append(hints, &ContinueHint{
142+
Message: &hint,
143+
})
137144
}
138145
}
139146
if e.currentState.NextCommand != nil {

0 commit comments

Comments
 (0)