Allow choosing the SITL frame in the frontend#3950
Conversation
The POST endpoint already existed; add the matching GET so the frontend can read the currently configured SITL frame. Co-authored-by: Cursor <cursoragent@cursor.com>
a208f88 to
fb6ba0d
Compare
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
SitlConfiguration.vue, consider callingfetchSitlFrame()once onmounted()in addition to wiring it intoOneMoreTime, so the initial selected frame reflects the backend state immediately rather than only after the first scheduled fetch. - The
SITLFrameenum values are shown directly as user-facing labels (e.g.+,x, lowercased names); adding a mapping to more descriptive and consistently formatted labels insitl_frame_optionswould improve clarity in the dropdown. - The new
/sitl_frameGET endpoint is typed to always return aSITLFrame, but the code returnsautopilot.current_sitl_frame; ensure this is neverNoneor explicitly handle theNonecase to avoid response model mismatches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `SitlConfiguration.vue`, consider calling `fetchSitlFrame()` once on `mounted()` in addition to wiring it into `OneMoreTime`, so the initial selected frame reflects the backend state immediately rather than only after the first scheduled fetch.
- The `SITLFrame` enum values are shown directly as user-facing labels (e.g. `+`, `x`, lowercased names); adding a mapping to more descriptive and consistently formatted labels in `sitl_frame_options` would improve clarity in the dropdown.
- The new `/sitl_frame` GET endpoint is typed to always return a `SITLFrame`, but the code returns `autopilot.current_sitl_frame`; ensure this is never `None` or explicitly handle the `None` case to avoid response model mismatches.
## Individual Comments
### Comment 1
<location path="core/frontend/src/components/autopilot/SitlConfiguration.vue" line_range="58-60" />
<code_context>
+ }
+ },
+ computed: {
+ sitl_frame_options(): {value: SITLFrame, text: string}[] {
+ return Object.values(SITLFrame)
+ .filter((frame) => frame !== SITLFrame.UNDEFINED)
+ .map((frame) => ({ value: frame, text: frame }))
+ },
</code_context>
<issue_to_address>
**issue (bug_risk):** Handling of SITLFrame.UNDEFINED can desync the selected value and the available items.
Because `SITLFrame.UNDEFINED` is filtered out here, `autopilot.sitl_frame` may still be `UNDEFINED` while the corresponding `<v-select>` has no matching `item`, causing an empty or inconsistent selection. Either normalize `UNDEFINED` to `null` in the store/setter, or include `UNDEFINED` in the options (e.g. as a disabled/placeholder entry).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Automated PR Review0. Summary
Adds a "SITL configuration" expansion panel to the Autopilot view that lets the user pick the SITL frame from a 1. Correctness & Implementation Bugs
5. UI / UX
6. Code Quality & Style
8. Documentation
Generated by PR Review Bot. This is advisory, a human reviewer must still approve. |
fb6ba0d to
b3779de
Compare
Add a dedicated expansion panel (visible only when SITL is the running board) with a frame-type dropdown. Selecting a frame POSTs to /sitl_frame and automatically restarts the autopilot so the new frame takes effect (matching set_board behavior), with a loading spinner and success snackbar for feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
b3779de to
d59735d
Compare
| export async function fetchSitlFrame(): Promise<void> { | ||
| try { | ||
| const response: AxiosResponse = await back_axios({ | ||
| method: 'get', | ||
| url: `${autopilot.API_URL}/sitl_frame`, | ||
| timeout: 10000, | ||
| }) | ||
| autopilot.setSitlFrame(response.data as SITLFrame) | ||
| } catch (error) { | ||
| autopilot.setSitlFrame(null) | ||
| notifier.pushBackError('AUTOPILOT_SITL_FRAME_FETCH_FAIL', error) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Any reason why not using the return back_axios({/*...*/}).then(/*...*/).catch(/*...*/) pattern used in the similar functions below?
Summary by Sourcery
Add frontend and API support for configuring and reading the current SITL frame type for the autopilot simulator.
New Features:
Enhancements: