From f85359e0d1095a30461d03c9175171b2fa11029d Mon Sep 17 00:00:00 2001 From: Kush Makkapati Date: Sun, 28 Sep 2025 12:48:24 +0100 Subject: [PATCH 1/2] Add motor test warning modal --- gcs/src/components/config/motorTest.jsx | 45 +++++++++++++++++--- gcs/src/redux/middleware/socketMiddleware.js | 2 + gcs/src/redux/slices/configSlice.js | 8 ++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/gcs/src/components/config/motorTest.jsx b/gcs/src/components/config/motorTest.jsx index 0c175ca36..2850a346b 100644 --- a/gcs/src/components/config/motorTest.jsx +++ b/gcs/src/components/config/motorTest.jsx @@ -7,7 +7,7 @@ import { useEffect, useState } from "react" // 3rd Party Imports -import { Button, NumberInput } from "@mantine/core" +import { Button, Modal, NumberInput } from "@mantine/core" // Styling imports import resolveConfig from "tailwindcss/resolveConfig" @@ -18,11 +18,8 @@ const tailwindColors = resolveConfig(tailwindConfig).theme.colors import { MOTOR_LETTER_LABELS } from "../../helpers/mavlinkConstants" // Redux + import { useDispatch, useSelector } from "react-redux" -import { - emitSetState, - selectConnectedToDrone, -} from "../../redux/slices/droneConnectionSlice" import { emitGetFrameConfig, emitTestAllMotors, @@ -33,7 +30,13 @@ import { selectFrameTypeName, selectFrameTypeOrder, selectNumberOfMotors, + selectShowMotorTestWarningModal, + setShowMotorTestWarningModal, } from "../../redux/slices/configSlice" +import { + emitSetState, + selectConnectedToDrone, +} from "../../redux/slices/droneConnectionSlice" export default function MotorTestPanel() { const dispatch = useDispatch() @@ -43,6 +46,7 @@ export default function MotorTestPanel() { const frameTypename = useSelector(selectFrameTypeName) const frameClass = useSelector(selectFrameClass) const numberOfMotors = useSelector(selectNumberOfMotors) + const showMotorTestWarningModal = useSelector(selectShowMotorTestWarningModal) const [selectedThrottle, setSelectedThrottle] = useState(10) const [selectedDuration, setSelectedDuration] = useState(2) @@ -90,6 +94,37 @@ export default function MotorTestPanel() { return (
+ dispatch(setShowMotorTestWarningModal(false))} + closeOnClickOutside={false} + closeOnEscape={false} + withCloseButton={false} + centered + overlayProps={{ + backgroundOpacity: 0.55, + blur: 3, + }} + > +
+

+ Ensure all propellers are removed and the drone is secured before + testing the motors. +

+

+ Improper testing can lead to injury or damage. +

+ +
+ +
+
+
{/* Input throttle and duration/delay of the test*/}
diff --git a/gcs/src/redux/middleware/socketMiddleware.js b/gcs/src/redux/middleware/socketMiddleware.js index 277e7bd9f..a2b628fc2 100644 --- a/gcs/src/redux/middleware/socketMiddleware.js +++ b/gcs/src/redux/middleware/socketMiddleware.js @@ -43,6 +43,7 @@ import { setNumberOfMotors, setRadioChannels, setRefreshingFlightModeData, + setShowMotorTestWarningModal, } from "../slices/configSlice.js" import { setAttitudeData, @@ -303,6 +304,7 @@ const socketMiddleware = (store) => { store.dispatch(setRebootData({})) store.dispatch(setAutoPilotRebootModalOpen(false)) store.dispatch(setShouldFetchAllMissionsOnDashboard(true)) + store.dispatch(setShowMotorTestWarningModal(true)) }) // Link stats diff --git a/gcs/src/redux/slices/configSlice.js b/gcs/src/redux/slices/configSlice.js index 22b0b4fa3..876d4b1d5 100644 --- a/gcs/src/redux/slices/configSlice.js +++ b/gcs/src/redux/slices/configSlice.js @@ -20,6 +20,7 @@ const configSlice = createSlice({ frameTypeName: null, frameClass: null, numberOfMotors: 4, + showMotorTestWarningModal: true, radioChannels: { 1: 0, 2: 0, @@ -81,6 +82,10 @@ const configSlice = createSlice({ if (action.payload === state.numberOfMotors) return state.numberOfMotors = action.payload }, + setShowMotorTestWarningModal: (state, action) => { + if (action.payload === state.showMotorTestWarningModal) return + state.showMotorTestWarningModal = action.payload + }, setRadioChannels: (state, action) => { if (action.payload === state.radioChannels) return state.radioChannels = action.payload @@ -113,6 +118,7 @@ const configSlice = createSlice({ selectFrameTypeName: (state) => state.frameTypeName, selectFrameClass: (state) => state.frameClass, selectNumberOfMotors: (state) => state.numberOfMotors, + selectShowMotorTestWarningModal: (state) => state.showMotorTestWarningModal, selectRadioChannels: (state) => state.radioChannels, selectRadioChannelsConfig: (state) => state.radioChannelsConfig, }, @@ -129,6 +135,7 @@ export const { setFrameTypeName, setFrameClass, setNumberOfMotors, + setShowMotorTestWarningModal, setRadioChannels, setChannelsConfig, @@ -156,6 +163,7 @@ export const { selectFrameTypeName, selectFrameClass, selectNumberOfMotors, + selectShowMotorTestWarningModal, selectRadioChannels, selectRadioChannelsConfig, } = configSlice.selectors From b3df2e63316928a883446a945decbf4b92c1493f Mon Sep 17 00:00:00 2001 From: Kush Makkapati Date: Sun, 28 Sep 2025 12:50:11 +0100 Subject: [PATCH 2/2] Update gcs/src/components/config/motorTest.jsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- gcs/src/components/config/motorTest.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcs/src/components/config/motorTest.jsx b/gcs/src/components/config/motorTest.jsx index 2850a346b..be9e117ce 100644 --- a/gcs/src/components/config/motorTest.jsx +++ b/gcs/src/components/config/motorTest.jsx @@ -106,7 +106,7 @@ export default function MotorTestPanel() { blur: 3, }} > -
+

Ensure all propellers are removed and the drone is secured before testing the motors.