Skip to content

Commit 41046dd

Browse files
TurnlingsCopilotNexInfinite
authored
Add option to start simulator via docker (#944)
* Add start simulation button * Fix port * Add stop simulation button * Working error messages (only if using string literal) * Move onSimulationResult to different set of events * Add feedback of running state from backend * Give feedback on first time use * Docker stubs * Resolve minor feedback * Resolve more feedback * Update requirements for stubs * Exception handling for image pull * Add docker to mypi ignore * Add simulation modal * Add dropdown to select vehicle type * Add fields for the other ardupilot params * Copy * Pass params to simulator startup * npx * Remove ArduRover for now as is not valid * Cleanup of args parsing * Wait for YOU CAN CONNECT message * Disable if not connected to socket * Add connect after simulator start * linting * Backend refactor and comments * Add port option to also allow for tests * Add cleanup to the first test * Generate tests for the other functions * Resolve minor copilot feedback * Lint * Pass connect arg through backend * Use port 5763 for tests * Potential fix for test * Background task for wait for container result * Better error messages on stopping simulation * CI friendly cleanup container * Resolve minor copilot feedback * Improve test coverage * Remove container reload because it breaks logs * Potential test fix * Catch exceptions from streaming container * Clamp input values * Image downloading progress messages * Message on closing modal * Errors and exceptions * More tests * Linting * Remove unused import * Update radio/app/endpoints/simulation.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Resolve final copilot comments * Rename function in tests * Resolve minor feedback * Fix non-deterministic tests * minor copilot feedback * Close old notification if new loading has begun * Rewrite waiting for container * Resolve MORE minor copilot feedback * Remove extra parameters * Cleanup missed references * Use correct port on auto-connect * Selection for both host and container ports * Add more tests for failure routes * Fix tests * Resolve copilot feedback * Just a couple more copilot comments * Minor copilot feedback * Even more copilot feedback * Rewrite waiting function to use since and tail * Frontend changes * Get rid of all the tests * Catch bubble up exception * Copy * Option for multiple port mappings * Refactor simulation params into their own slice * Duplicate port validation * Refactor port validation into helper functions * Fix None unpacking * Linting * Use exceptions rather than returning None * Store simulation loading id states * Linting * Minor changes * Resolve what are becoming more and more pointless comments * These edge cases are literally never gonna happen * Check for duplicate container ports aswell * Copy * Type annotations * Fix typing * Fix the final none hallucinated issues * Linting * Please * Use uuids for ports * Use worker thread for log polling * Remove unused reference to index * MAYBE these ones are relevant * Hide button on default with opt-in experimental developer setting * Resolve the trivial parts of the feedback * Use docker types * Add custom type for command parameters * Optional type, because it is * Rename cleanup_container to stop_container * Use trash icon instead of X * Add connection progress bar to simulation modal footer * Remove now unused Progress import * Disconnect from drone when stopping simulation if connected to ANYTHING * Disconnect from simulator on stop simulation * Block connecting to simulator if already connected to drone * Fix issue with merge --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Julian Jones <37962677+NexInfinite@users.noreply.github.com>
1 parent 236750b commit 41046dd

14 files changed

Lines changed: 1024 additions & 17 deletions

File tree

gcs/data/default_settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
"default": false,
3232
"type": "boolean",
3333
"display": "Speech Announcements"
34+
},
35+
"experimentalDeveloperFeatures": {
36+
"default": false,
37+
"type": "boolean",
38+
"display": "Experimental Developer Features",
39+
"description": "These may be unstable and can cause unexpected bugs or crashes."
3440
}
3541
},
3642
"Dashboard": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Progress } from "@mantine/core"
2+
3+
export default function ConnectionProgress({ connecting, status }) {
4+
return (
5+
<>
6+
{connecting &&
7+
status.message !== null &&
8+
typeof status.progress === "number" && (
9+
<>
10+
<p className="text-center my-4">{status.message}</p>
11+
<Progress
12+
animated
13+
size="lg"
14+
transitionDuration={300}
15+
value={status.progress}
16+
className="w-full mx-auto my-auto"
17+
/>
18+
</>
19+
)}
20+
</>
21+
)
22+
}

gcs/src/components/navbar.jsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
Group,
1717
LoadingOverlay,
1818
Modal,
19-
Progress,
2019
SegmentedControl,
2120
Select,
2221
Tabs,
@@ -78,6 +77,10 @@ import { useEffect } from "react"
7877
import { twMerge } from "tailwind-merge"
7978
import { showErrorNotification } from "../helpers/notification.js"
8079

80+
// Modals
81+
import SimulationModal from "./toolbar/simulationModal.jsx"
82+
import ConnectionProgress from "./connectionProgress.jsx"
83+
8184
export default function Navbar() {
8285
// Redux
8386
const dispatch = useDispatch()
@@ -320,22 +323,10 @@ export default function Navbar() {
320323
</Group>
321324
</form>
322325

323-
{connecting &&
324-
droneConnectionStatus.message !== null &&
325-
typeof droneConnectionStatus.progress === "number" && (
326-
<>
327-
<p className="text-center my-4">
328-
{droneConnectionStatus.message}
329-
</p>
330-
<Progress
331-
animated
332-
size="lg"
333-
transitionDuration={300}
334-
value={droneConnectionStatus.progress}
335-
className="w-full mx-auto my-auto"
336-
/>
337-
</>
338-
)}
326+
<ConnectionProgress
327+
connecting={connecting}
328+
status={droneConnectionStatus}
329+
/>
339330
</Modal>
340331

341332
<Modal
@@ -402,6 +393,8 @@ export default function Navbar() {
402393
)}
403394
</Modal>
404395

396+
<SimulationModal />
397+
405398
<div className="w-full flex justify-between gap-x-4 xl:grid xl:grid-cols-2 xl:gap-0">
406399
<div className="flex items-center wrap">
407400
{/* Navigation */}

gcs/src/components/toolbar/menus/advanced.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
// Local Imports
66
import { useDispatch } from "react-redux"
77
import { setForwardingAddressModalOpened } from "../../../redux/slices/droneConnectionSlice"
8+
import { setSimulationModalOpened } from "../../../redux/slices/simulationParamsSlice"
89
import MenuItem from "./menuItem"
910
import MenuTemplate from "./menuTemplate"
11+
import { useSettings } from "../../../helpers/settings"
1012

1113
export default function AdvancedMenu(props) {
1214
const dispatch = useDispatch()
15+
const { getSetting } = useSettings()
1316
return (
1417
<MenuTemplate
1518
title="Advanced"
@@ -28,6 +31,14 @@ export default function AdvancedMenu(props) {
2831
dispatch(setForwardingAddressModalOpened(true))
2932
}}
3033
/>
34+
{getSetting("General.experimentalDeveloperFeatures") && (
35+
<MenuItem
36+
name="SITL Simulator"
37+
onClick={() => {
38+
dispatch(setSimulationModalOpened(true))
39+
}}
40+
/>
41+
)}
3142
</MenuTemplate>
3243
)
3344
}

0 commit comments

Comments
 (0)