Autonomous
Endgame
-
-
{ if (count.trap < 3) handleCount('trap') }} style={{ fontSize: '30px'}}
- className='px-2 py-1 text-center bg-blue-300 rounded-md mr-2 block absolute left-24'>
- Trap Note: {count.trap}
-
+
+
{handleSubmit(); scrollTo(0, 0);}} style={{ fontSize: '30px' }}
className='px-2 py-1 text-center bg-green-500 rounded-md'>
- Submit
+ Submit
diff --git a/client/src/apps/pit/PitApp.tsx b/client/src/apps/pit/PitApp.tsx
index a8c1120..f406aee 100644
--- a/client/src/apps/pit/PitApp.tsx
+++ b/client/src/apps/pit/PitApp.tsx
@@ -1,9 +1,8 @@
import MultiButton from '../../components/MultiButton';
//import ToggleButton from '../../components/ToggleButton'
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import Checkbox from '../../components/Checkbox';
import { PitFile, teamRoles, drivebase } from 'requests';
-import { postJson } from '../../lib/postJson';
import LinkButton from '../../components/LinkButton';
import { MaterialSymbol } from 'react-material-symbols';
import TeamDropdown from '../../components/TeamDropdown';
@@ -12,6 +11,8 @@ import SignIn from '../../components/SignIn';
import ConeStacker from '../../components/ConeStacker';
import { usePreventUnload } from '../../lib/usePreventUnload';
import ImageUploader from '../../components/ImageUploader';
+import { useFetchJson } from '../../lib/useFetch';
+import { postJson } from '../../lib/postJson';
function PitApp() {
@@ -32,6 +33,7 @@ function PitApp() {
setAutoInputValues([...autoInputValues, '']);
};
+ const [scoutedTeams, refreshScoutedTeams] = useFetchJson
('/data/pit/scouted-teams');
const [autoInputValues, setAutoInputValues] = useState(['']);
const [role, setRole] = useState();
@@ -52,6 +54,10 @@ function PitApp() {
const [scouterName, setScouterName] = useState('');
const [robotImage, setRobotImage] = useState('');
+ useEffect(() => {
+ const timeout = setInterval(refreshScoutedTeams, 60 * 1000);
+ return () => clearInterval(timeout);
+ }, [refreshScoutedTeams]);
const handleSubmit = async() => {
if (!drivetrain || !role){
@@ -86,6 +92,7 @@ function PitApp() {
try {
const result = await postJson('/data/pit', data);
if (!result.ok) throw new Error('Request Did Not Succeed');
+ refreshScoutedTeams();
setAutoInputValues(['']);
setAmpChecked(false);
setAmpPrefChecked(false);
@@ -165,7 +172,7 @@ function PitApp() {
diff --git a/client/src/components/EndGameButton.tsx b/client/src/components/EndGameButton.tsx
index 938987c..8c4c296 100644
--- a/client/src/components/EndGameButton.tsx
+++ b/client/src/components/EndGameButton.tsx
@@ -1,17 +1,22 @@
import { Dispatch, SetStateAction } from 'react';
+import { MatchScores } from '../apps/match/MatchApp';
import { ClimbPosition, ScouterPosition } from 'requests';
import MultiButton from './MultiButton';
function EndgameButton({
setClimb,
+ setCount,
climbPosition,
alliance,
scouterPosition,
+ count,
}: {
setClimb: Dispatch>;
+ setCount: Dispatch>;
climbPosition: ClimbPosition;
alliance: boolean | undefined;
scouterPosition: ScouterPosition | undefined;
+ count: MatchScores;
}) {
// const [alliance, setAlliance] = useState(false); //false=red, true=blue, null=hollow purple
@@ -19,6 +24,13 @@ function EndgameButton({
setClimb(newClimb);
};
+ const handleTrap = () => {
+ setCount(prevCount => ({
+ ...prevCount,
+ ['trap']: prevCount['trap'] + 1,
+ }));
+ }
+
return (
<>
+
+ { if (count.trap < 3) handleTrap() }} style={{ fontSize: '30px'}}
+ className='px-2 py-1 text-center bg-blue-300 rounded-md'>
+ Trap Notes: {count.trap}
+
+
>
);
}
diff --git a/client/src/components/FieldButton.tsx b/client/src/components/FieldButton.tsx
index c8e1538..e4fa6ee 100644
--- a/client/src/components/FieldButton.tsx
+++ b/client/src/components/FieldButton.tsx
@@ -1,7 +1,6 @@
-import { Dispatch, SetStateAction, useState } from 'react';
+import { Dispatch, SetStateAction } from 'react';
import { MatchScores } from '../apps/match/MatchApp';
-import Checkbox from './Checkbox';
-import { PickupLocation, ScouterPosition } from 'requests';
+import { ScouterPosition } from 'requests';
import MultiButton from './MultiButton';
type countKeys = keyof MatchScores;
@@ -62,193 +61,47 @@ function FieldButton({
alliance: boolean | undefined;
scouterPosition: ScouterPosition | undefined;
}) {
- const [pickupLocation, setPickupLocation] = useState<
- PickupLocation | undefined
- >();
- const heldFromAuto =
- count.hold &&
- !(
- count.teleShootNear ||
- count.teleShootMid ||
- count.teleShootFar ||
- count.teleAmp ||
- count.teleMiss
- );
const handleCount = (autoKey: countKeys, teleKey: countKeys) => {
- if (pickupLocation) {
+ if (teleOp || !count.hold){
const finalKey = teleOp ? teleKey : autoKey;
setCount(prevCount => ({
...prevCount,
[finalKey]: prevCount[finalKey] + 1,
}));
- const pickupKeys = {
- preload: 'autoPreload',
- pickup: 'autoPickup',
- speaker: 'telePickupSpeaker',
- middle: 'telePickupMiddle',
- source: 'telePickupSource',
- } as const;
- setCount(prevCount => ({
- ...prevCount,
- [pickupKeys[pickupLocation]]:
- prevCount[pickupKeys[pickupLocation]] + 1,
- }));
- } else if (heldFromAuto && teleOp) {
- const finalKey = teleOp ? teleKey : autoKey;
- setCount(prevCount => ({
- ...prevCount,
- [finalKey]: prevCount[finalKey] + 1,
- }));
- } else if (
- (count.autoPreload || count.autoPickup) &&
- !count.hold &&
- !teleOp
- ) {
- const finalKey = teleOp ? teleKey : autoKey;
- const finalPickupLocation =
- pickupLocation == 'autoPreload' ? 'autoPreload' : 'autoPickup';
- setCount(prevCount => ({
- ...prevCount,
- [finalKey]: prevCount[finalKey] + 1,
- [finalPickupLocation]: prevCount[finalPickupLocation] + 1,
- }));
}
- setPickupLocation(undefined);
};
const handleLeave = () => {
setLeave?.(!leave);
};
+ const fieldColors = alliance ? ['bg-blue-300/70', 'bg-blue-500/70', 'bg-blue-700/70'] : ['bg-red-200/70', 'bg-red-400/70', 'bg-red-600/70'];
+
return (
<>
-
+
{!teleOp && (
-
- {' '}
- Did the robot leave?
-
- )}
-
-
- {/*
-
- red on right, blue alliance - red is source, blue is speaker
- red on right, red alliance - red is speaker, blue is source
- blue on right, blue alliance - red is source, blue is speaker
- blue on right, red alliance - red is speaker, blue is source
-
- */}
-
-
- {teleOp ? (
- !heldFromAuto ? (
- scouterPosition === 'red_right' ? (
- alliance ? (
-
- ) : (
-
- )
- ) : alliance ? (
-
- ) : (
-
- )
- ) : (
-
- Note held from auto
+ <>
+
+
Mobility?
+
The robot must cross the gray line to earn mobility.
- )
- ) : count.autoPreload || count.autoPickup ? (
-
- ) : (
-
+
+ >
)}
+ ${!teleOp && count.hold ? 'grayscale' : ''}`}>
{alliance ? (
<>
@@ -267,7 +120,7 @@ function FieldButton({
handleCount={handleCount}
autoKey='autoShootMid'
teleKey='teleShootMid'
- className='absolute left-[30%] top-[25%] z-10 h-[130%] w-[130%] overflow-hidden rounded-full bg-blue-400/70 text-left '
+ className={`absolute left-[30%] top-[25%] z-10 h-[130%] w-[130%] overflow-hidden rounded-full text-left ${fieldColors[1]}`}
textClassName='top-[3.5em] left-[3.5em] absolute'
scouterPosition={scouterPosition}
/>
@@ -277,7 +130,7 @@ function FieldButton({
handleCount={handleCount}
autoKey='autoShootFar'
teleKey='teleShootFar'
- className='absolute bottom-0 right-0 z-0 h-full w-full bg-red-400/70 text-left '
+ className={`absolute bottom-0 right-0 z-0 h-full w-full bg-green-200/70 text-left ${fieldColors[0]}`}
textClassName='top-[3.5em] left-[3em] absolute'
scouterPosition={scouterPosition}
/>
@@ -290,7 +143,7 @@ function FieldButton({
handleCount={handleCount}
autoKey='autoShootFar'
teleKey='teleShootFar'
- className='bottom-0 right-0 z-0 h-full w-full bg-red-400/70 p-[2.5em] text-right '
+ className={`bottom-0 right-0 z-0 h-full w-full p-[2.5em] text-right ${fieldColors[0]}`}
textClassName='top-[3.5em] right-[3em] absolute'
scouterPosition={scouterPosition}
/>
@@ -300,7 +153,7 @@ function FieldButton({
handleCount={handleCount}
autoKey='autoShootMid'
teleKey='teleShootMid'
- className='right-[30%] top-[25%] z-10 h-[130%] w-[130%] overflow-hidden rounded-full bg-blue-400/70 text-right '
+ className={`right-[30%] top-[25%] z-10 h-[130%] w-[130%] overflow-hidden rounded-full text-right ${fieldColors[1]}`}
textClassName='top-[3.25em] right-[3.5em] absolute'
scouterPosition={scouterPosition}
/>
@@ -310,7 +163,7 @@ function FieldButton({
handleCount={handleCount}
autoKey='autoShootNear'
teleKey='teleShootNear'
- className='bottom-[40px] left-[-120px] z-20 h-2/5 w-2/5 rounded-full bg-green-400/70 text-right'
+ className={`bottom-[40px] left-[-120px] z-20 h-2/5 w-2/5 rounded-full text-right ${fieldColors[2]}`}
textClassName='top-[2.2em] right-[1.5em] absolute'
scouterPosition={scouterPosition}
/>
@@ -319,9 +172,9 @@ function FieldButton({
- {count.hold === 0 || teleOp ? (
+ className={`flex w-[40em] flex-row gap-2 py-2 transition-[filter] duration-200
+ ${!teleOp && count.hold ? 'grayscale' : ''}`}>
+ {(
<>
)}
>
- ) : (
-
- Held: 1
-
)}
>
diff --git a/client/src/components/TeamDropdown.tsx b/client/src/components/TeamDropdown.tsx
index 738823b..fc15052 100644
--- a/client/src/components/TeamDropdown.tsx
+++ b/client/src/components/TeamDropdown.tsx
@@ -14,13 +14,17 @@ console.log(teamOptions);
function TeamDropdown({
value,
onChange,
+ disabledOptions,
}: {
value?: number | undefined;
onChange?: Dispatch
;
+ disabledOptions?: number[];
}) {
+ const options = disabledOptions ? teamOptions.map(e => ({...e, disabled: disabledOptions.includes(parseInt(e.value as string))})) : teamOptions;
+
return (
onChange?.(parseInt(value as string))}
search
diff --git a/client/src/index.css b/client/src/index.css
index 8c5cfdc..b3ecc12 100644
--- a/client/src/index.css
+++ b/client/src/index.css
@@ -10,6 +10,10 @@
html {
@apply snap-y;
}
+
+ body {
+ @apply overscroll-none;
+ }
}
@layer utilities {
diff --git a/requests/index.d.ts b/requests/index.d.ts
index c4b2dcf..2e43b3f 100644
--- a/requests/index.d.ts
+++ b/requests/index.d.ts
@@ -81,7 +81,7 @@ export interface SuperDataAggregations{
export interface MetaData {
scouterName: string;
matchNumber: number;
- robotTeam: number;
+ robotTeam?: number;
robotPosition: RobotPosition
}
diff --git a/server/src/server.ts b/server/src/server.ts
index 37e7cc5..4aea747 100644
--- a/server/src/server.ts
+++ b/server/src/server.ts
@@ -76,6 +76,10 @@ app.get('/data/retrieve/super', async (req, res) => {
res.send(await superAverageAndMax());
})
+app.get('/data/pit/scouted-teams', async (req, res) => {
+ res.send((await pitApp.find({}, {teamNumber: 1})).map(e => e.teamNumber));
+})
+
app.get('/image/:teamId.jpeg', async (req, res) => {
const { teamId } = req.params;
console.log(teamId);