Automate match team based on driver station#108
Conversation
Teams often assign scouts to focus on the same driver station across matches. This PR adds support for a special "driverStation" field value that, when set, automatically selects the team number based on their assigned driver station position. The impact of this change is that scouts can "set and forget" their assigned driver stations. As soon as the form as reset and the match number is incremented, the correct team number is automatically selected. This saves scouts time and significantly reduces the likelihood of error, leading to more reliable scouting data for alliance selection.
luanzeba
left a comment
There was a problem hiding this comment.
Thanks so much for this contribution!! This is a good idea (:
I included a suggestion for better long-term support but that can be done in a follow up PR so we can land this more quickly.
As soon as you update that comment and remove the package-lock.json updates, we can merge this.
| // Scouts are often assigned to a single robot position | ||
| // Remember this when changing match numbers | ||
| const driverStation = useQRScoutState(() => { | ||
| return getFieldValue("driverStation"); |
There was a problem hiding this comment.
This works great, but the behavior is currently implicit (you have to know about "driverStation").
For long-term support, it would be better to make this explicit in TBA-team-and-robot config and schema.
Rough direction:
src/components/inputs/BaseInputProps.ts(tbaTeamAndRobotInputSchema):
autoAssignFromFieldCode: z.string().optional() const sourceCode = data.autoAssignFromFieldCode;
const assignedStation = useQRScoutState(() =>
sourceCode ? getFieldValue(sourceCode) : undefined
);If you want, would you be interested in opening that follow-up PR too? We’d be happy to review it.
There was a problem hiding this comment.
That plan works for me!
| return typeof value === 'number' ? value : null; | ||
| }); | ||
| // Scouts are often assigned to a single robot position | ||
| // Remember this when changing match numbers |
There was a problem hiding this comment.
Could you expand on this comment explaining this temporary convention (expected values R1/R2/R3/B1/B2/B3, and that it’s intended to become a formal config option later)? That’ll help maintainers until the schema-backed option we mentioned in the other comment lands.
There was a problem hiding this comment.
The expected values come from the robotPosition defined in this same component. I can certainly document that this solution is temporary.
There was a problem hiding this comment.
Do you mind reverting the changes to this lockfile? They seem unrelated.
There was a problem hiding this comment.
Ah yes sorry about that! I was working in a codespace and didn't notice.
|
@luanzeba Thanks for the review! I'll give the config a go in a separate PR. How does this version look? |
luanzeba
left a comment
There was a problem hiding this comment.
This is great, thanks so much for contributing!
Hi! I'm a mentor from FRC 6201. We have a new feature to suggest. :)
Teams often assign scouts to focus on the same driver station across matches. This PR adds support for a special "driverStation" field value that, when set, automatically selects the team number based on their assigned driver station position.
The impact of this change is that scouts can "set and forget" their assigned driver stations. As soon as the form as reset and the match number is incremented, the correct team number is automatically selected. This saves scouts time and significantly reduces the likelihood of error, leading to more reliable scouting data for alliance selection.
Example config snippet:
{ "title": "Driver Station", "description": "If you are scouting the same driver station each match, choose here.", "type": "select", "required": false, "code": "driverStation", "formResetBehavior": "preserve", "defaultValue": "", "choices": { "R1": "Red 1", "R2": "Red 2", "R3": "Red 3", "B1": "Blue 1", "B2": "Blue 2", "B3": "Blue 3" } },