Skip to content

Commit

Permalink
Merging main into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaxking committed Nov 3, 2024
1 parent 2e6317f commit de58e26
Show file tree
Hide file tree
Showing 25 changed files with 434 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
sh gh-actions/tatorscout/release.sh
sh gh-actions/tatorscout/release.sh
2 changes: 1 addition & 1 deletion client/models/FIRST/match-scouting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const checkRanks: {
groundPicks: 0,
penalized: 3,
spectator: 3,
lob: 0,
lob: 0
};

export const rankColor: {
Expand Down
8 changes: 6 additions & 2 deletions client/models/FIRST/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export class Check extends EventEmitter<CheckEvents> {
const checks = data.map(d => d.split(':') as [string, string]);

return teams.map(t => {
const c = checks.filter(c => +c[0] === t).map(c => c.slice(1).join(':'));
const c = checks
.filter(c => +c[0] === t)
.map(c => c.slice(1).join(':'));
return new Check(t, c, strategy);
}) as [Check, Check, Check, Check, Check, Check];
});
Expand Down Expand Up @@ -248,7 +250,9 @@ export class Check extends EventEmitter<CheckEvents> {

remove(check: string) {
this.checks = this.checks.filter(c => c !== check);
this.strategy.checks = this.strategy.checks.filter(c => c !== `${this.team}:${check}`);
this.strategy.checks = this.strategy.checks.filter(
c => c !== `${this.team}:${check}`
);
this.emit('remove-check', check);
return this.change();
}
Expand Down
16 changes: 11 additions & 5 deletions client/models/FIRST/whiteboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ type WhiteboardEvents = {
};

type GlobalWhiteboardEvents = {
'new': FIRSTWhiteboard;
}
new: FIRSTWhiteboard;
};

export class FIRSTWhiteboard extends Cache<WhiteboardEvents> {
public static readonly cache = new Map<string, FIRSTWhiteboard>();

public static readonly emitter = new EventEmitter<GlobalWhiteboardEvents>();

public static on = FIRSTWhiteboard.emitter.on.bind(FIRSTWhiteboard.emitter);
public static off = FIRSTWhiteboard.emitter.off.bind(FIRSTWhiteboard.emitter);
public static emit = FIRSTWhiteboard.emitter.emit.bind(FIRSTWhiteboard.emitter);
public static once = FIRSTWhiteboard.emitter.once.bind(FIRSTWhiteboard.emitter.once.bind(FIRSTWhiteboard.emitter));
public static off = FIRSTWhiteboard.emitter.off.bind(
FIRSTWhiteboard.emitter
);
public static emit = FIRSTWhiteboard.emitter.emit.bind(
FIRSTWhiteboard.emitter
);
public static once = FIRSTWhiteboard.emitter.once.bind(
FIRSTWhiteboard.emitter.once.bind(FIRSTWhiteboard.emitter)
);

public static fromStrategy(strategyId: string) {
return attemptAsync(async () => {
Expand Down
3 changes: 2 additions & 1 deletion client/views/components/main/MatchSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
defaultValue="Select Match"
bind:options
bind:value
on:change="{handleChange}" />
on:change="{handleChange}"
/>
197 changes: 96 additions & 101 deletions client/views/components/robot-display/ActionHeatmap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,112 +45,107 @@
height: 1
});
const generate = async (team?: FIRSTTeam) => {
if (!team) return;
checks = [];
traceArray = [];
const allChecks = Object.keys(actions)
// .keys(actions[2024]) // for development
.map((k, i) => ({
key: k,
action: actions[k as keyof typeof actions],
enabled: true,
color: colors[i % colors.length] // loop through the colors
}));
const ctx = canvas.getContext('2d');
if (!ctx) return;
const scouting = await team.getMatchScouting();
if (!c) {
c = new Canvas(ctx);
c.adaptable = true;
c.ratio = 2;
c.height = 500;
c.width = 1000;
}
c.clearDrawables();
if (scouting.isOk()) {
// traceArray = generateTrace(10).filter((p => !!p[3])); // used only for development
const matchesRes = await team.event.getMatches();
if (matchesRes.isErr()) return console.error(matchesRes.error);
const matches = matchesRes.value;
traceArray = (
await Promise.all(
scouting.value.map(async m => {
const match = matches.find(
match =>
match.number === m.matchNumber &&
match.compLevel === m.compLevel
);
// if on red alliance, do x = 1 - x
// not doing .indexOf because I don't know if the caches are the same, they likely are but I don't want to assume
let trace = m.trace.slice();
const teams = await match?.getTeams();
if (!teams || teams.isErr())
return {
...m,
trace
};
if (
match &&
teams.value.findIndex(
t => t && t.number === team.number
) > 2
) {
// we don't want to modify the original trace, so we make a copy
trace = m.trace.map(p => [
p[0],
1 - p[1],
p[2],
p[3]
]);
}
const generate = async (team?: FIRSTTeam) => {
if (!team) return;
checks = [];
traceArray = [];
const allChecks = Object.keys(actions)
// .keys(actions[2024]) // for development
.map((k, i) => ({
key: k,
action: actions[k as keyof typeof actions],
enabled: true,
color: colors[i % colors.length] // loop through the colors
}));
const ctx = canvas.getContext('2d');
if (!ctx) return;
const scouting = await team.getMatchScouting();
if (!c) {
c = new Canvas(ctx);
c.adaptable = true;
c.ratio = 2;
c.height = 500;
c.width = 1000;
}
c.clearDrawables();
if (scouting.isOk()) {
// traceArray = generateTrace(10).filter((p => !!p[3])); // used only for development
const matchesRes = await team.event.getMatches();
if (matchesRes.isErr()) return console.error(matchesRes.error);
const matches = matchesRes.value;
traceArray = (
await Promise.all(
scouting.value.map(async m => {
const match = matches.find(
match =>
match.number === m.matchNumber &&
match.compLevel === m.compLevel
);
// if on red alliance, do x = 1 - x
// not doing .indexOf because I don't know if the caches are the same, they likely are but I don't want to assume
let trace = m.trace.slice();
const teams = await match?.getTeams();
if (!teams || teams.isErr())
return {
...m,
trace
};
})
)
if (
match &&
teams.value.findIndex(
t => t && t.number === team.number
) > 2
) {
// we don't want to modify the original trace, so we make a copy
trace = m.trace.map(p => [p[0], 1 - p[1], p[2], p[3]]);
}
return {
...m,
trace
};
})
)
.map(m => m.trace)
.flat()
.filter(p => !!p[3]);
container.children = traceArray.map(t => {
const c = new Circle([t[1], t[2]], 0.02);
const action = t[3] as Action;
const found = allChecks.find(c => c.key === action);
checks = [...checks, found].filter(
(c, i, a) => a.indexOf(c) === i
) as typeof checks;
c.properties.fill.color = Color.fromBootstrap(
found?.color || 'dark'
).toString('rgb');
c.properties.line.color = 'transparent';
return c;
});
c.add(img, container);
c.animate();
} else {
return console.error(scouting.error);
}
};
const filter = (trace: TraceArray) => {
container.filter(
(c, i) =>
checks.filter(Boolean).find(c => c.key === trace[i][3])
?.enabled ?? true
);
};
)
.map(m => m.trace)
.flat()
.filter(p => !!p[3]);
container.children = traceArray.map(t => {
const c = new Circle([t[1], t[2]], 0.02);
const action = t[3] as Action;
const found = allChecks.find(c => c.key === action);
checks = [...checks, found].filter(
(c, i, a) => a.indexOf(c) === i
) as typeof checks;
c.properties.fill.color = Color.fromBootstrap(
found?.color || 'dark'
).toString('rgb');
c.properties.line.color = 'transparent';
return c;
});
c.add(img, container);
c.animate();
} else {
return console.error(scouting.error);
}
};
const filter = (trace: TraceArray) => {
container.filter(
(c, i) =>
checks.filter(Boolean).find(c => c.key === trace[i][3])?.enabled ??
true
);
};
$: generate(team);
$: filter(traceArray);
Expand Down
Loading

0 comments on commit de58e26

Please sign in to comment.