Skip to content

Commit 2ad4083

Browse files
authored
Add prearm check status to dashboard (#1073)
* Add prearm check status to dashboard * Address copilot review comments
1 parent 6edf413 commit 2ad4083

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

gcs/src/components/dashboard/telemetrySection/telemetry.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
selectHomePosition,
1717
selectIsArmed,
1818
selectNavController,
19+
selectReadyToArm,
1920
selectTelemetry,
2021
} from "../../../redux/slices/droneInfoSlice"
2122
import EkfDisplay from "./ekfDisplay"
@@ -32,6 +33,7 @@ export default function TelemetrySection({
3233
const flightMode = useSelector(selectFlightModeString)
3334
const gpsData = useSelector(selectGPS)
3435
const isArmed = useSelector(selectIsArmed)
36+
const readyToArm = useSelector(selectReadyToArm)
3537
const telemetryData = useSelector(selectTelemetry)
3638
const attitudeData = useSelector(selectAttitude)
3739
const navControllerOutputData = useSelector(selectNavController)
@@ -58,6 +60,14 @@ export default function TelemetrySection({
5860
<div>
5961
{/* Information above indicators */}
6062
<div className="flex flex-col items-center gap-4 py-4 cursor-default">
63+
{!isArmed && (
64+
<Text
65+
size={`${telemetryFontSize * 1.5}rem`}
66+
c={readyToArm ? "green.6" : "red.6"}
67+
>
68+
{readyToArm ? "Ready to arm" : "Not ready to arm"}
69+
</Text>
70+
)}
6171
<Text
6272
fw={700}
6373
size={`${telemetryFontSize * 1.5}rem`}

gcs/src/redux/middleware/socketMiddleware.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ import {
6262
setRadioPwmChannels,
6363
setRefreshingFlightModeData,
6464
setRefreshingGripperConfigData,
65-
setShowMotorTestWarningModal,
6665
setServoConfig,
6766
setServoPwmOutputs,
67+
setShowMotorTestWarningModal,
6868
updateChannelsConfigParam,
6969
updateGripperConfigParam,
7070
updateServoConfigParam,
@@ -90,6 +90,7 @@ import {
9090
setLoiterRadius,
9191
setNavControllerOutput,
9292
setOnboardControlSensorsEnabled,
93+
setOnboardControlSensorsHealth,
9394
setRSSIData,
9495
setTelemetryData,
9596
setTotalTimeFlying,
@@ -272,6 +273,9 @@ const socketMiddleware = (store) => {
272273
store.dispatch(
273274
setOnboardControlSensorsEnabled(msg.onboard_control_sensors_enabled),
274275
)
276+
store.dispatch(
277+
setOnboardControlSensorsHealth(msg.onboard_control_sensors_health),
278+
)
275279
break
276280
case "GPS_RAW_INT": {
277281
// MAVLink GPS_RAW_INT provides 'eph' (HDOP * 100).

gcs/src/redux/slices/droneInfoSlice.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
MAV_STATE,
99
} from "../../helpers/mavlinkConstants"
1010

11+
const MAV_SYS_STATUS_PREARM_CHECK = 268435456
12+
1113
// TODO: Make this configurable in the future?
1214
const GPS_TRACK_MAX_LENGTH = 300
1315

@@ -56,6 +58,7 @@ const droneInfoSlice = createSlice({
5658
systemStatus: 0,
5759
},
5860
onboardControlSensorsEnabled: 0,
61+
onboardControlSensorsHealth: 0,
5962
gpsRawIntData: {
6063
fixType: 0,
6164
satellitesVisible: 0,
@@ -259,6 +262,11 @@ const droneInfoSlice = createSlice({
259262
state.onboardControlSensorsEnabled = action.payload
260263
}
261264
},
265+
setOnboardControlSensorsHealth: (state, action) => {
266+
if (action.payload !== state.onboardControlSensorsHealth) {
267+
state.onboardControlSensorsHealth = action.payload
268+
}
269+
},
262270
setRSSIData: (state, action) => {
263271
if (action.payload !== state.rssi) {
264272
state.rssi = action.payload
@@ -345,8 +353,18 @@ const droneInfoSlice = createSlice({
345353
selectNotificationSound: (state) => state.notificationSound,
346354
selectFlightMode: (state) => state.heartbeatData.customMode,
347355
selectSystemStatus: (state) => MAV_STATE[state.heartbeatData.systemStatus],
348-
selectPrearmEnabled: (state) =>
349-
state.onboardControlSensorsEnabled & 268435456,
356+
selectReadyToArm: (state) => {
357+
const isEnabled = !!(
358+
state.onboardControlSensorsEnabled & MAV_SYS_STATUS_PREARM_CHECK
359+
)
360+
const isHealthy = !!(
361+
state.onboardControlSensorsHealth & MAV_SYS_STATUS_PREARM_CHECK
362+
)
363+
364+
// If pre-arm check is enabled, it must also be healthy
365+
// If pre-arm check is disabled, just check if it's healthy
366+
return isEnabled ? isHealthy : isHealthy
367+
},
350368
selectGPSRawInt: (state) => state.gpsRawIntData,
351369
selectGPS2RawInt: (state) => state.gps2RawIntData,
352370
selectHasSecondaryGps: (state) => state.hasSecondaryGps,
@@ -386,6 +404,7 @@ export const {
386404
setHasEverHadGpsFix,
387405
setBatteryData,
388406
setOnboardControlSensorsEnabled,
407+
setOnboardControlSensorsHealth,
389408
setRSSIData,
390409
setGraphValues,
391410
setLastGraphMessage,
@@ -498,7 +517,7 @@ export const {
498517
selectHeartbeat,
499518
selectIsArmed,
500519
selectIsFlying,
501-
selectPrearmEnabled,
520+
selectReadyToArm,
502521
selectGPSRawInt,
503522
selectGPS2RawInt,
504523
selectHasSecondaryGps,

0 commit comments

Comments
 (0)