Skip to content

Commit 2acca2d

Browse files
859 dispalay gps hdop on dashboard (#864)
* added hdop to setGPSRawintData in droneInfo slice * Added hdop logic to middleware. The difference between hdop and eph confused me for a bit so added in a check incase we ever are in a situation where hdop is sent from mavlink instead of eph * front end hdop finished * spelling error * more spelling errors * changed status bar condition from hdop != 0 to hdop > 0 as per copilot reccomendation * linter fix :) * copilot fix * added hdop to setGPSRawintData in droneInfo slice * Added hdop logic to middleware. The difference between hdop and eph confused me for a bit so added in a check incase we ever are in a situation where hdop is sent from mavlink instead of eph * front end hdop finished * spelling error * more spelling errors * changed status bar condition from hdop != 0 to hdop > 0 as per copilot reccomendation * linter fix :) * copilot fix * removed check from .hdop presense in middlware * made HDOP always visible on stausbar * switched to IconTarget icon * moved hdop section across in status bar to between lat/lon and gps * changed hdop to display no gps instead of 0.00 * linters :) * changed HDOP to display 0.00 when no gps available instead of "NO GPS" * Removed "precision" from HDoP tooltip
1 parent 5db9299 commit 2acca2d

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

gcs/src/components/dashboard/statusBar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export default function StatusBar(props) {
136136
style={{ backgroundColor: GetOutsideVisibilityColor() }}
137137
>
138138
{props.children}
139+
139140
<StatusSection
140141
icon={isConnectedToSocket ? <IconNetwork /> : <IconNetworkOff />}
141142
value=""

gcs/src/dashboard.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
IconGps,
2323
IconRadar,
2424
IconSatellite,
25+
IconTarget,
2526
} from "@tabler/icons-react"
2627
import { ResizableBox } from "react-resizable"
2728

@@ -75,7 +76,10 @@ export default function Dashboard() {
7576
const batteryData = useSelector(selectBatteryData)
7677
const statustextMessages = useSelector(selectMessages)
7778
const armedNotification = useSelector(selectNotificationSound)
78-
const { fixType, satellitesVisible } = useSelector(selectGPSRawInt)
79+
const { fixType, satellitesVisible, hdop } = useSelector(selectGPSRawInt)
80+
81+
const hdopDisplay = hdop != null ? hdop.toFixed(2) : "0.00"
82+
7983
const connectedToDrone = useSelector(selectConnectedToDrone)
8084

8185
// Telemetry panel sizing
@@ -197,6 +201,11 @@ export default function Dashboard() {
197201
value={GPS_FIX_TYPES[fixType]}
198202
tooltip="GPS fix type"
199203
/>
204+
<StatusSection
205+
icon={<IconTarget />}
206+
value={hdopDisplay}
207+
tooltip="GPS HDoP"
208+
/>
200209
<StatusSection
201210
icon={<IconGps />}
202211
value={`(${lat !== undefined ? lat.toFixed(7) : 0}, ${

gcs/src/redux/middleware/socketMiddleware.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,19 @@ const socketMiddleware = (store) => {
214214
setOnboardControlSensorsEnabled(msg.onboard_control_sensors_enabled),
215215
)
216216
break
217-
case "GPS_RAW_INT":
218-
store.dispatch(setGpsRawIntData(msg))
217+
case "GPS_RAW_INT": {
218+
// MAVLink GPS_RAW_INT provides 'eph' (HDOP * 100).
219+
const hdop = msg.eph != null ? msg.eph / 100.0 : null
220+
221+
store.dispatch(
222+
setGpsRawIntData({
223+
...msg,
224+
hdop,
225+
}),
226+
)
219227
store.dispatch(calculateGpsTrackHeadingThunk())
220228
break
229+
}
221230
case "RC_CHANNELS":
222231
// NOTE: UNABLE TO TEST IN SIMULATOR!
223232
store.dispatch(setRSSIData(msg.rssi))

gcs/src/redux/slices/droneInfoSlice.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const droneInfoSlice = createSlice({
5757
satellitesVisible: 0,
5858
velocity: 0,
5959
courseOverGround: 0,
60+
hdop: 0,
6061
},
6162
rssi: 0.0,
6263
notificationSound: "",
@@ -179,6 +180,7 @@ const droneInfoSlice = createSlice({
179180
state.gpsRawIntData.fixType = action.payload.fix_type
180181
state.gpsRawIntData.velocity = action.payload.vel / 100.0 // cm/s to m/s
181182
state.gpsRawIntData.courseOverGround = centiDegToDeg(action.payload.cog)
183+
state.gpsRawIntData.hdop = action.payload.hdop ?? 0
182184
}
183185
},
184186
setOnboardControlSensorsEnabled: (state, action) => {

0 commit comments

Comments
 (0)