Skip to content

Commit 188f7c0

Browse files
committed
fallback home location to drones location if not known
1 parent 0adb13a commit 188f7c0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tabs/mission_control.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,17 @@ TABS.mission_control.initialize = function (callback) {
317317
// var coord = ol.proj.fromLonLat([MISSION_PLANER.bufferPoint.lon, MISSION_PLANER.bufferPoint.lat]); //buzz
318318
// rthGeo.setCoordinates(coord);
319319
// });
320-
var h_lat = FC.curr_mav_state['HOME_POSITION'].latitude / 10000000;
321-
var h_lng = FC.curr_mav_state['HOME_POSITION'].longitude / 10000000;
320+
321+
// if the drone has given us its HOME_POSITION, then use that otherwise fall back to its current GPS co-ord.
322+
var h_lat;
323+
var h_lng;
324+
if ( FC.curr_mav_state['HOME_POSITION'] ) {
325+
h_lat = FC.curr_mav_state['HOME_POSITION'].latitude / 10000000;
326+
h_lng = FC.curr_mav_state['HOME_POSITION'].longitude / 10000000;
327+
} else {
328+
h_lat = FC.curr_mav_state['GLOBAL_POSITION_INT'].lat / 10000000;
329+
h_lng = FC.curr_mav_state['GLOBAL_POSITION_INT'].lon / 10000000;
330+
}
322331
// buzz set home..
323332
var coord = ol.proj.fromLonLat([h_lng, h_lat]);
324333
rthGeo.setCoordinates(coord);

0 commit comments

Comments
 (0)