Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gcs/src/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import {
selectDroneCoords,
selectFlightMode,
selectGPSRawInt,
selectGPS2RawInt,
selectNotificationSound,
selectRSSI,
soundPlayed,
selectHasSecondaryGps,
} from "./redux/slices/droneInfoSlice"
import { selectMessages } from "./redux/slices/statusTextSlice"

Expand Down Expand Up @@ -81,6 +83,10 @@ export default function Dashboard() {
const hdopDisplay = hdop != null ? hdop.toFixed(2) : "0.00"

const connectedToDrone = useSelector(selectConnectedToDrone)
const gps2 = useSelector(selectGPS2RawInt)
const hasSecondaryGps = useSelector(selectHasSecondaryGps)

const secondaryGpsFixLabel = GPS_FIX_TYPES[gps2.fixType]

// Telemetry panel sizing
const [telemetryPanelSize, setTelemetryPanelSize] = useLocalStorage({
Expand Down Expand Up @@ -201,6 +207,13 @@ export default function Dashboard() {
value={GPS_FIX_TYPES[fixType]}
tooltip="GPS fix type"
/>
{hasSecondaryGps && (
<StatusSection
icon={<IconRadar />}
value={secondaryGpsFixLabel}
tooltip="GPS2 fix type"
/>
)}
<StatusSection
icon={<IconTarget />}
value={hdopDisplay}
Expand Down
13 changes: 13 additions & 0 deletions gcs/src/redux/middleware/socketMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
setFlightSwVersion,
setGpsData,
setGpsRawIntData,
setGps2RawIntData,
setGuidedModePinData,
setHeartbeatData,
setHomePosition,
Expand Down Expand Up @@ -227,6 +228,18 @@ const socketMiddleware = (store) => {
store.dispatch(calculateGpsTrackHeadingThunk())
break
}
case "GPS2_RAW": {
// MAVLink GPS2_RAW provides 'eph' (HDOP * 100).
const hdop = msg.eph != null ? msg.eph / 100.0 : null

store.dispatch(
setGps2RawIntData({
...msg,
hdop,
}),
)
break
}
case "RC_CHANNELS":
// NOTE: UNABLE TO TEST IN SIMULATOR!
store.dispatch(setRSSIData(msg.rssi))
Expand Down
27 changes: 27 additions & 0 deletions gcs/src/redux/slices/droneInfoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ const droneInfoSlice = createSlice({
courseOverGround: 0,
hdop: 0,
},
gps2RawIntData: {
fixType: 0,
satellitesVisible: 0,
velocity: 0,
courseOverGround: 0,
hdop: 0,
},
hasSecondaryGps: false,
rssi: 0.0,
notificationSound: "",
aircraftType: 0, // TODO: This should be in local storage but I have no idea how :D,
Expand Down Expand Up @@ -183,6 +191,20 @@ const droneInfoSlice = createSlice({
state.gpsRawIntData.hdop = action.payload.hdop ?? 0
}
},
setGps2RawIntData: (state, action) => {
if (action.payload !== state.gps2RawIntData) {
state.gps2RawIntData.satellitesVisible =
action.payload.satellites_visible
state.gps2RawIntData.fixType = action.payload.fix_type
state.gps2RawIntData.velocity = action.payload.vel / 100.0 // cm/s to m/s
state.gps2RawIntData.courseOverGround = centiDegToDeg(
action.payload.cog,
)
state.gps2RawIntData.hdop = action.payload.hdop ?? 0

state.hasSecondaryGps = true // Reducer called => gps2 exists
}
},
setOnboardControlSensorsEnabled: (state, action) => {
if (action.payload !== state.onboardControlSensorsEnabled) {
state.onboardControlSensorsEnabled = action.payload
Expand Down Expand Up @@ -273,6 +295,8 @@ const droneInfoSlice = createSlice({
selectPrearmEnabled: (state) =>
state.onboardControlSensorsEnabled & 268435456,
selectGPSRawInt: (state) => state.gpsRawIntData,
selectGPS2RawInt: (state) => state.gps2RawIntData,
selectHasSecondaryGps: (state) => state.hasSecondaryGps,
selectRSSI: (state) => state.rssi,
selectAircraftType: (state) => state.aircraftType,
selectBatteryData: (state) =>
Expand Down Expand Up @@ -303,6 +327,7 @@ export const {
setAttitudeData,
setNavControllerOutput,
setGpsRawIntData,
setGps2RawIntData,
setBatteryData,
setOnboardControlSensorsEnabled,
setRSSIData,
Expand Down Expand Up @@ -417,6 +442,8 @@ export const {
selectArmed,
selectPrearmEnabled,
selectGPSRawInt,
selectGPS2RawInt,
selectHasSecondaryGps,
selectRSSI,
selectHeading,
selectSystemStatus,
Expand Down
1 change: 1 addition & 0 deletions radio/app/endpoints/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SetStateType(TypedDict):
"NAV_CONTROLLER_OUTPUT",
"SYS_STATUS",
"GPS_RAW_INT",
"GPS2_RAW",
"RC_CHANNELS",
"ESC_TELEMETRY_5_TO_8",
"MISSION_CURRENT",
Expand Down
3 changes: 1 addition & 2 deletions radio/tests/test_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def test_setState_dashboard_state(
"""Test setting state to dashboard"""
socketio_client.emit("set_state", {"state": "dashboard"})
assert len(socketio_client.get_received()) == 0
# TODO: These values don't seem right to me, they don't include the STATUSTEXT listener?
assert len(droneStatus.drone.message_listeners) == 15
assert len(droneStatus.drone.message_listeners) == 16


@falcon_test(pass_drone_status=True)
Expand Down