diff --git a/conf/flight_plans/EMAV2008.xml b/conf/flight_plans/EMAV2008.xml index 1d81947daf..57fa34c38a 100644 --- a/conf/flight_plans/EMAV2008.xml +++ b/conf/flight_plans/EMAV2008.xml @@ -47,7 +47,7 @@ - + @@ -86,11 +86,11 @@ - + - + diff --git a/conf/flight_plans/EMAV2009.xml b/conf/flight_plans/EMAV2009.xml index 28c86bd6f1..e9f4de4d36 100644 --- a/conf/flight_plans/EMAV2009.xml +++ b/conf/flight_plans/EMAV2009.xml @@ -26,7 +26,7 @@ - + diff --git a/conf/flight_plans/EMAV2009_safety.xml b/conf/flight_plans/EMAV2009_safety.xml index 9982b628ca..5e2dca0b32 100644 --- a/conf/flight_plans/EMAV2009_safety.xml +++ b/conf/flight_plans/EMAV2009_safety.xml @@ -2,7 +2,7 @@ - + diff --git a/conf/flight_plans/IS.xml b/conf/flight_plans/IS.xml index 6d636cb7b1..598371aed5 100644 --- a/conf/flight_plans/IS.xml +++ b/conf/flight_plans/IS.xml @@ -101,15 +101,15 @@ - + - + - + @@ -147,7 +147,7 @@ - + diff --git a/conf/flight_plans/basic.xml b/conf/flight_plans/basic.xml index e404260c69..e690348416 100644 --- a/conf/flight_plans/basic.xml +++ b/conf/flight_plans/basic.xml @@ -35,7 +35,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/conf/flight_plans/corsica.xml b/conf/flight_plans/corsica.xml index 02db9b1e70..7b96b5ad8f 100644 --- a/conf/flight_plans/corsica.xml +++ b/conf/flight_plans/corsica.xml @@ -21,7 +21,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -74,7 +74,7 @@ - + diff --git a/conf/flight_plans/creidlitz.xml b/conf/flight_plans/creidlitz.xml index d4b34b0250..58bfa754c3 100644 --- a/conf/flight_plans/creidlitz.xml +++ b/conf/flight_plans/creidlitz.xml @@ -33,7 +33,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/conf/flight_plans/fp_tp_auto.xml b/conf/flight_plans/fp_tp_auto.xml index 444a7fc7c3..1c91224cc7 100644 --- a/conf/flight_plans/fp_tp_auto.xml +++ b/conf/flight_plans/fp_tp_auto.xml @@ -44,7 +44,7 @@ - + @@ -65,19 +65,19 @@ - + - + - + - + @@ -114,7 +114,7 @@ - + @@ -140,7 +140,7 @@ - + diff --git a/conf/flight_plans/generic.xml b/conf/flight_plans/generic.xml index b1fc8ab8ea..5cdf61eefc 100644 --- a/conf/flight_plans/generic.xml +++ b/conf/flight_plans/generic.xml @@ -24,7 +24,7 @@ - + diff --git a/conf/flight_plans/grosslobke_demo.xml b/conf/flight_plans/grosslobke_demo.xml index 6cdcaa5866..80343d88f0 100644 --- a/conf/flight_plans/grosslobke_demo.xml +++ b/conf/flight_plans/grosslobke_demo.xml @@ -53,7 +53,7 @@ - + @@ -78,7 +78,7 @@ - + diff --git a/conf/flight_plans/hsif.xml b/conf/flight_plans/hsif.xml index 19eb10dfb3..39808c6349 100644 --- a/conf/flight_plans/hsif.xml +++ b/conf/flight_plans/hsif.xml @@ -18,7 +18,7 @@ - + diff --git a/conf/flight_plans/ingolfsskali.xml b/conf/flight_plans/ingolfsskali.xml index f980b7a2cb..8cb378e8f1 100644 --- a/conf/flight_plans/ingolfsskali.xml +++ b/conf/flight_plans/ingolfsskali.xml @@ -58,22 +58,22 @@ - + - + - + - + diff --git a/conf/flight_plans/joystick.xml b/conf/flight_plans/joystick.xml index 6969aeb403..5e979f785e 100644 --- a/conf/flight_plans/joystick.xml +++ b/conf/flight_plans/joystick.xml @@ -33,7 +33,7 @@ - + @@ -82,7 +82,7 @@ - + diff --git a/conf/flight_plans/kalscott.xml b/conf/flight_plans/kalscott.xml index 49d59220b2..c9540c1192 100644 --- a/conf/flight_plans/kalscott.xml +++ b/conf/flight_plans/kalscott.xml @@ -26,48 +26,48 @@ - + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + diff --git a/conf/flight_plans/kv_svalbard.xml b/conf/flight_plans/kv_svalbard.xml index 2831ac9162..7dcfa2ba9b 100644 --- a/conf/flight_plans/kv_svalbard.xml +++ b/conf/flight_plans/kv_svalbard.xml @@ -35,7 +35,7 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/conf/flight_plans/landing.xml b/conf/flight_plans/landing.xml index f1f2aed593..b38a4de861 100644 --- a/conf/flight_plans/landing.xml +++ b/conf/flight_plans/landing.xml @@ -21,8 +21,8 @@ - - + + diff --git a/conf/flight_plans/mav06.xml b/conf/flight_plans/mav06.xml index 746dd37c1f..69bf4e8212 100644 --- a/conf/flight_plans/mav06.xml +++ b/conf/flight_plans/mav06.xml @@ -32,7 +32,7 @@ - + @@ -48,7 +48,7 @@ - + --> diff --git a/conf/flight_plans/mav07.xml b/conf/flight_plans/mav07.xml index 83c5ce09bb..7433aac8f2 100644 --- a/conf/flight_plans/mav07.xml +++ b/conf/flight_plans/mav07.xml @@ -72,7 +72,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/conf/flight_plans/mav08.xml b/conf/flight_plans/mav08.xml index 700b08d8a7..5ce3f7ae2c 100644 --- a/conf/flight_plans/mav08.xml +++ b/conf/flight_plans/mav08.xml @@ -41,7 +41,7 @@ - + @@ -100,7 +100,7 @@ - + diff --git a/conf/flight_plans/mission_fw.xml b/conf/flight_plans/mission_fw.xml index 8359db5d26..5c53485f74 100644 --- a/conf/flight_plans/mission_fw.xml +++ b/conf/flight_plans/mission_fw.xml @@ -26,7 +26,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/conf/flight_plans/muret_demo_1.xml b/conf/flight_plans/muret_demo_1.xml index 439ed05688..d0271dafe1 100644 --- a/conf/flight_plans/muret_demo_1.xml +++ b/conf/flight_plans/muret_demo_1.xml @@ -19,7 +19,7 @@ - + diff --git a/conf/flight_plans/muret_for.xml b/conf/flight_plans/muret_for.xml index 961a2816c4..1837fd6b7f 100644 --- a/conf/flight_plans/muret_for.xml +++ b/conf/flight_plans/muret_for.xml @@ -14,7 +14,7 @@ - + diff --git a/conf/flight_plans/nav_modules.xml b/conf/flight_plans/nav_modules.xml index 3f142d3d55..b527228872 100644 --- a/conf/flight_plans/nav_modules.xml +++ b/conf/flight_plans/nav_modules.xml @@ -50,7 +50,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/conf/flight_plans/nordlys.xml b/conf/flight_plans/nordlys.xml index f7778a7820..e526b31724 100644 --- a/conf/flight_plans/nordlys.xml +++ b/conf/flight_plans/nordlys.xml @@ -37,7 +37,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -87,7 +87,7 @@ - + diff --git a/conf/flight_plans/poles.xml b/conf/flight_plans/poles.xml index 7241254523..ccf1487b8c 100644 --- a/conf/flight_plans/poles.xml +++ b/conf/flight_plans/poles.xml @@ -32,7 +32,7 @@ - + @@ -73,7 +73,7 @@ - + diff --git a/conf/flight_plans/rotorcraft_basic_safety.xml b/conf/flight_plans/rotorcraft_basic_safety.xml index 75e3641daf..c11631d0b5 100644 --- a/conf/flight_plans/rotorcraft_basic_safety.xml +++ b/conf/flight_plans/rotorcraft_basic_safety.xml @@ -39,7 +39,7 @@ - + diff --git a/conf/flight_plans/rotorcraft_basic_superbitrf.xml b/conf/flight_plans/rotorcraft_basic_superbitrf.xml index 635610b6ae..aae3d4b9ce 100644 --- a/conf/flight_plans/rotorcraft_basic_superbitrf.xml +++ b/conf/flight_plans/rotorcraft_basic_superbitrf.xml @@ -39,7 +39,7 @@ - + diff --git a/conf/flight_plans/slayer_training.xml b/conf/flight_plans/slayer_training.xml index 794ec94e96..ab416079d4 100644 --- a/conf/flight_plans/slayer_training.xml +++ b/conf/flight_plans/slayer_training.xml @@ -35,7 +35,7 @@ - + @@ -77,7 +77,7 @@ - + diff --git a/conf/flight_plans/tcas.xml b/conf/flight_plans/tcas.xml index c5eeda466c..e3612c132d 100644 --- a/conf/flight_plans/tcas.xml +++ b/conf/flight_plans/tcas.xml @@ -33,7 +33,7 @@ - + @@ -74,7 +74,7 @@ - + diff --git a/conf/flight_plans/versatile.xml b/conf/flight_plans/versatile.xml index 5e4023afba..0887a889cf 100644 --- a/conf/flight_plans/versatile.xml +++ b/conf/flight_plans/versatile.xml @@ -45,7 +45,7 @@ - + @@ -70,25 +70,25 @@ - + - + - + - + - + @@ -127,7 +127,7 @@ - + @@ -153,7 +153,7 @@ - + @@ -168,7 +168,7 @@ - + diff --git a/conf/flight_plans/versatile_airspeed.xml b/conf/flight_plans/versatile_airspeed.xml index 3b9525bd00..ec1b0d3fdc 100644 --- a/conf/flight_plans/versatile_airspeed.xml +++ b/conf/flight_plans/versatile_airspeed.xml @@ -45,7 +45,7 @@ - + @@ -69,25 +69,25 @@ - + - + - + - + - + @@ -163,7 +163,7 @@ - + @@ -178,7 +178,7 @@ - + diff --git a/conf/flight_plans/versatile_carto_fixe_muret.xml b/conf/flight_plans/versatile_carto_fixe_muret.xml index dfd522ded7..fe9a0eb356 100644 --- a/conf/flight_plans/versatile_carto_fixe_muret.xml +++ b/conf/flight_plans/versatile_carto_fixe_muret.xml @@ -61,7 +61,7 @@ float varsweepsize=110; - + @@ -111,8 +111,8 @@ float varsweepsize=110; - - + + @@ -139,8 +139,8 @@ float varsweepsize=110; - - + + diff --git a/conf/flight_plans/xsens_cachejunction.xml b/conf/flight_plans/xsens_cachejunction.xml index 3d2fd30938..fca2f69c32 100644 --- a/conf/flight_plans/xsens_cachejunction.xml +++ b/conf/flight_plans/xsens_cachejunction.xml @@ -23,7 +23,7 @@ - + @@ -91,7 +91,7 @@ - + diff --git a/conf/flight_plans/zamboni_survey_test.xml b/conf/flight_plans/zamboni_survey_test.xml index 810c6a779d..9e43f0bb35 100644 --- a/conf/flight_plans/zamboni_survey_test.xml +++ b/conf/flight_plans/zamboni_survey_test.xml @@ -34,7 +34,7 @@ - + @@ -66,7 +66,7 @@ - + diff --git a/conf/messages.xml b/conf/messages.xml index ebdbe2acc1..d7c1d6f5c2 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -83,6 +83,7 @@ + @@ -2718,6 +2719,7 @@ + diff --git a/sw/airborne/firmwares/fixedwing/nav.c b/sw/airborne/firmwares/fixedwing/nav.c index 047bbf991c..bbeded6c73 100644 --- a/sw/airborne/firmwares/fixedwing/nav.c +++ b/sw/airborne/firmwares/fixedwing/nav.c @@ -452,7 +452,7 @@ void nav_periodic_task(void) { static void send_nav_ref(void) { DOWNLINK_SEND_NAVIGATION_REF(DefaultChannel, DefaultDevice, - &nav_utm_east0, &nav_utm_north0, &nav_utm_zone0); + &nav_utm_east0, &nav_utm_north0, &nav_utm_zone0, &ground_alt); } static void send_nav(void) { diff --git a/sw/airborne/firmwares/fixedwing/nav.h b/sw/airborne/firmwares/fixedwing/nav.h index 8a2af7b995..d7263d7431 100644 --- a/sw/airborne/firmwares/fixedwing/nav.h +++ b/sw/airborne/firmwares/fixedwing/nav.h @@ -199,6 +199,7 @@ bool_t nav_approaching_xy(float x, float y, float from_x, float from_y, float ap #define GetPosX() (stateGetPositionEnu_f()->x) #define GetPosY() (stateGetPositionEnu_f()->y) #define GetPosAlt() (stateGetPositionUtm_f()->alt) +#define GetAltRef() (ground_alt) #define SEND_NAVIGATION(_trans, _dev) { \ uint8_t _circle_count = NavCircleCount(); \ diff --git a/sw/airborne/firmwares/rotorcraft/navigation.c b/sw/airborne/firmwares/rotorcraft/navigation.c index ae345c8005..1692dbdb94 100644 --- a/sw/airborne/firmwares/rotorcraft/navigation.c +++ b/sw/airborne/firmwares/rotorcraft/navigation.c @@ -58,8 +58,6 @@ struct EnuCoor_i nav_last_point; uint8_t last_wp __attribute__ ((unused)); -int32_t ground_alt; - /** Maximum distance from HOME waypoint before going into failsafe mode */ #ifndef FAILSAFE_MODE_DISTANCE #define FAILSAFE_MODE_DISTANCE (1.5*MAX_DIST_FROM_HOME) @@ -149,7 +147,6 @@ void nav_init(void) { } nav_block = 0; nav_stage = 0; - ground_alt = POS_BFP_OF_REAL(GROUND_ALT); nav_altitude = POS_BFP_OF_REAL(SECURITY_HEIGHT); nav_flight_altitude = nav_altitude; flight_altitude = SECURITY_ALT; @@ -380,13 +377,11 @@ static inline void nav_set_altitude( void ) { /** Reset the geographic reference to the current GPS fix */ unit_t nav_reset_reference( void ) { ins_reset_local_origin(); - ground_alt = POS_BFP_OF_REAL(state.ned_origin_f.hmsl); return 0; } unit_t nav_reset_alt( void ) { ins_reset_altitude_ref(); - ground_alt = POS_BFP_OF_REAL(state.ned_origin_f.hmsl); return 0; } diff --git a/sw/airborne/firmwares/rotorcraft/navigation.h b/sw/airborne/firmwares/rotorcraft/navigation.h index 3658ad0864..1bbafb23c5 100644 --- a/sw/airborne/firmwares/rotorcraft/navigation.h +++ b/sw/airborne/firmwares/rotorcraft/navigation.h @@ -47,9 +47,6 @@ extern void nav_run(void); extern uint8_t last_wp __attribute__ ((unused)); -/** ground reference altitude in meters << #INT32_POS_FRAC */ -extern int32_t ground_alt; - extern uint8_t horizontal_mode; extern uint8_t nav_segment_start, nav_segment_end; extern uint8_t nav_circle_centre; @@ -209,13 +206,14 @@ bool_t nav_check_wp_time(uint8_t wp_idx, uint16_t stay_time); #define navigation_SetFlightAltitude(x) { \ flight_altitude = x; \ - nav_flight_altitude = POS_BFP_OF_REAL(flight_altitude) - ground_alt; \ + nav_flight_altitude = POS_BFP_OF_REAL(flight_altitude - state.ned_origin_f.hmsl); \ } #define GetPosX() (stateGetPositionEnu_f()->x) #define GetPosY() (stateGetPositionEnu_f()->y) -#define GetPosAlt() (stateGetPositionEnu_f()->z+ground_alt) +#define GetPosAlt() (stateGetPositionEnu_f()->z+state.ned_origin_f.hmsl) +#define GetAltRef() (state.ned_origin_f.hmsl) extern void navigation_update_wp_from_speed(uint8_t wp, struct Int16Vect3 speed_sp, int16_t heading_rate_sp ); diff --git a/sw/ground_segment/cockpit/gcs.glade b/sw/ground_segment/cockpit/gcs.glade index 7f00cf86ed..1bc9bebfe5 100644 --- a/sw/ground_segment/cockpit/gcs.glade +++ b/sw/ground_segment/cockpit/gcs.glade @@ -171,7 +171,7 @@ True - Above Ground Level (m), climb indicator, vertical speed (m/s) + Above Ground Level from SRTM if available, ground reference otherwise (m), climb indicator, vertical speed (m/s) True diff --git a/sw/ground_segment/cockpit/live.ml b/sw/ground_segment/cockpit/live.ml index 001c53950a..dacb0ad9d4 100644 --- a/sw/ground_segment/cockpit/live.ml +++ b/sw/ground_segment/cockpit/live.ml @@ -1288,10 +1288,12 @@ let listen_waypoint_moved = fun () -> let wp_id = Pprz.int_assoc "wp_id" vs in let a = fun s -> Pprz.float_assoc s vs in let geo = { posn_lat = (Deg>>Rad)(a "lat"); posn_long = (Deg>>Rad)(a "long") } - and altitude = a "alt" in + and altitude = a "alt" + and ground_alt = a "ground_alt" in try let w = ac.fp_group#get_wp wp_id in + w#set_ground_alt ground_alt; w#set ~altitude ~update:true geo with Not_found -> () (* Silently ignore unknown waypoints *) diff --git a/sw/ground_segment/tmtc/aircraft.ml b/sw/ground_segment/tmtc/aircraft.ml index ec5d564782..334b2961c3 100644 --- a/sw/ground_segment/tmtc/aircraft.ml +++ b/sw/ground_segment/tmtc/aircraft.ml @@ -121,6 +121,7 @@ type aircraft = { mutable climb : float; mutable nav_ref : nav_ref option; mutable d_hmsl : float; + mutable ground_alt : float; (* ground alt ref if no SRTM data *) mutable desired_pos : Latlong.geographic; mutable desired_altitude : float; mutable desired_course : float; @@ -169,7 +170,7 @@ let new_aircraft = fun id name fp airframe -> unix_time = 0.; itow = Int32.of_int 0; roll = 0.; pitch = 0.; gspeed=0.; airspeed= -1.; course = 0.; heading = 0.; alt=0.; climb=0.; agl = 0.; - nav_ref = None; d_hmsl = 0.; + nav_ref = None; d_hmsl = 0.; ground_alt = 0.; desired_pos = { Latlong.posn_lat = 0.; posn_long = 0. }; desired_course = 0.; desired_altitude = 0.; desired_climb = 0.; cur_block=0; cur_stage=0; diff --git a/sw/ground_segment/tmtc/aircraft.mli b/sw/ground_segment/tmtc/aircraft.mli index 85a7a2ad35..36528997df 100644 --- a/sw/ground_segment/tmtc/aircraft.mli +++ b/sw/ground_segment/tmtc/aircraft.mli @@ -87,6 +87,7 @@ type aircraft = { mutable climb : float; mutable nav_ref : nav_ref option; mutable d_hmsl : float; (* difference between geoid and ellipsoid *) + mutable ground_alt : float; (* ground alt ref if no SRTM data *) mutable desired_pos : Latlong.geographic; mutable desired_altitude : float; mutable desired_course : float; diff --git a/sw/ground_segment/tmtc/fw_server.ml b/sw/ground_segment/tmtc/fw_server.ml index 23bbffb302..610094afc3 100644 --- a/sw/ground_segment/tmtc/fw_server.ml +++ b/sw/ground_segment/tmtc/fw_server.ml @@ -113,7 +113,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> a.course <- norm_course ((Deg>>Rad)(fvalue "course" /. 10.)); if !heading_from_course then a.heading <- a.course; - a.agl <- a.alt -. float (try Srtm.of_wgs84 a.pos with _ -> 0); + a.agl <- a.alt -. (try float (Srtm.of_wgs84 a.pos) with _ -> a.ground_alt); if a.gspeed > 3. && a.ap_mode = _AUTO2 then Wind.update ac_name a.gspeed a.course end @@ -128,7 +128,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> a.course <- norm_course ((Deg>>Rad)(fvalue "course" /. 10.)); if !heading_from_course then a.heading <- a.course; - a.agl <- a.alt -. float (try Srtm.of_wgs84 a.pos with _ -> 0); + a.agl <- a.alt -. (try float (Srtm.of_wgs84 a.pos) with _ -> a.ground_alt); a.gps_mode <- check_index (ivalue "mode") gps_modes "GPS_MODE"; if a.gspeed > 3. && a.ap_mode = _AUTO2 then Wind.update ac_name a.gspeed a.course @@ -152,12 +152,14 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> a.desired_climb <- (try fvalue "climb" with _ -> fvalue "desired_climb"); begin try a.desired_course <- norm_course (fvalue "course") with _ -> () end | "NAVIGATION_REF" -> - a.nav_ref <- Some (Utm { utm_x = fvalue "utm_east"; utm_y = fvalue "utm_north"; utm_zone = ivalue "utm_zone" }) + a.nav_ref <- Some (Utm { utm_x = fvalue "utm_east"; utm_y = fvalue "utm_north"; utm_zone = ivalue "utm_zone" }); + a.ground_alt <- fvalue "ground_alt" | "NAVIGATION_REF_LLA" -> let lat = ivalue "lat" and lon = ivalue "lon" in let geo = make_geo (float lat /. 1e7) (float lon /. 1e7) in - a.nav_ref <- Some (Geo geo) + a.nav_ref <- Some (Geo geo); + a.ground_alt <- fvalue "ground_alt" | "ATTITUDE" -> let roll = fvalue "phi" and pitch = fvalue "theta" in @@ -316,7 +318,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> a.course <- norm_course (fvalue "course" /. 1e3); if !heading_from_course then a.heading <- a.course; - a.agl <- a.alt -. float (try Srtm.of_wgs84 a.pos with _ -> 0); + a.agl <- a.alt -. (try float (Srtm.of_wgs84 a.pos) with _ -> a.ground_alt); a.bat <- fvalue "vsupply" /. 10.; a.energy <- ivalue "energy" * 100; a.throttle <- fvalue "throttle"; diff --git a/sw/ground_segment/tmtc/rotorcraft_server.ml b/sw/ground_segment/tmtc/rotorcraft_server.ml index dded7be570..07c1a904dd 100644 --- a/sw/ground_segment/tmtc/rotorcraft_server.ml +++ b/sw/ground_segment/tmtc/rotorcraft_server.ml @@ -30,8 +30,6 @@ module LL = Latlong module U = Unix module Dl_Pprz = Pprz.Messages (struct let name = "datalink" end) -let nav_ref_alt = ref 0. -let nav_ref_hmsl = ref 0. (* FIXME: bound the loop *) let rec norm_course = @@ -168,7 +166,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> and vnorth = foi32value "vnorth" /. speed_frac in a.gspeed <- sqrt(vnorth*.vnorth +. veast*.veast); a.climb <- foi32value "vup" /. speed_frac; - a.agl <- a.alt -. float (try Srtm.of_wgs84 a.pos with _ -> 0); + a.agl <- a.alt -. (try float (Srtm.of_wgs84 a.pos) with _ -> a.ground_alt); a.course <- norm_course ((Rad>>Deg) (foi32value "psi" /. angle_frac)); a.heading <- norm_course (foi32value "psi" /. angle_frac); a.roll <- foi32value "phi" /. angle_frac; @@ -200,6 +198,7 @@ let log_and_parse = fun ac_name (a:Aircraft.aircraft) msg values -> let nav_ref_ecef = LL.make_ecef [| x; y; z |] in a.nav_ref <- Some (Ltp nav_ref_ecef); a.d_hmsl <- hmsl -. alt; + a.ground_alt <- hmsl; | "ROTORCRAFT_NAV_STATUS" -> a.block_time <- ivalue "block_time"; a.stage_time <- ivalue "stage_time"; diff --git a/sw/ground_segment/tmtc/server.ml b/sw/ground_segment/tmtc/server.ml index fe7afc012b..af1b52da70 100644 --- a/sw/ground_segment/tmtc/server.ml +++ b/sw/ground_segment/tmtc/server.ml @@ -294,7 +294,8 @@ let send_moved_waypoints = fun a -> "wp_id", Pprz.Int wp_id; "long", Pprz.Float ((Rad>>Deg)geo.posn_long); "lat", Pprz.Float ((Rad>>Deg)geo.posn_lat); - "alt", Pprz.Float wp.altitude] in + "alt", Pprz.Float wp.altitude; + "ground_alt", Pprz.Float (try float (Srtm.of_wgs84 geo) with _ -> a.ground_alt)] in Ground_Pprz.message_send my_id "WAYPOINT_MOVED" vs) a.waypoints diff --git a/sw/lib/ocaml/mapCanvas.ml b/sw/lib/ocaml/mapCanvas.ml index 5e380f07e2..9077564795 100644 --- a/sw/lib/ocaml/mapCanvas.ml +++ b/sw/lib/ocaml/mapCanvas.ml @@ -645,7 +645,7 @@ object (self) class widget = fun ?(height=800) ?(srtm=false) ?width ?projection ?georef () -> - let srtm = GMenu.check_menu_item ~label:"SRTM" ~active:srtm () in + let srtm = GMenu.check_menu_item ~label:"display SRTM alt" ~active:srtm () in let lbl_xy = GMisc.label () and lbl_geo = GMisc.label () and lbl_alt = GMisc.label () @@ -676,6 +676,7 @@ class widget = fun ?(height=800) ?(srtm=false) ?width ?projection ?georef () -> let bg_menu = my_check_menu_item "Background" ~active:true ~callback:self#switch_background ~packing:self#file_menu#append () in let tooltips = GData.tooltips () in + tooltips#set_tip srtm#coerce ~text:"Display SRTM alt at pointer position (will request for download if not available)"; let b = GButton.button ~packing:toolbar#add () in ignore (b#connect#clicked (fun _ -> bg_menu#activate ())); @@ -777,7 +778,9 @@ class widget = fun ?(height=800) ?(srtm=false) ?width ?projection ?georef () -> method display_alt = fun wgs84 -> if srtm#active then - lbl_alt#set_text (sprintf " SRTM:%dm"(self#altitude wgs84)) + lbl_alt#set_text (sprintf " SRTM:%dm"(self#altitude wgs84)) + else if not (Srtm.available wgs84) then + lbl_alt#set_text (sprintf " SRTM: N/A") method display_group = fun s -> lbl_group#set_text s diff --git a/sw/lib/ocaml/mapWaypoints.ml b/sw/lib/ocaml/mapWaypoints.ml index bd2f8dd45e..38c5f820e0 100644 --- a/sw/lib/ocaml/mapWaypoints.ml +++ b/sw/lib/ocaml/mapWaypoints.ml @@ -74,6 +74,7 @@ object (self) val label = new CL.widget ~name:name ~color:"white" s 0. wpt_group val mutable name = name (* FIXME: already in label ! *) val mutable alt = alt + val mutable ground_alt = 0. val mutable moved = None val mutable deleted = false val mutable commit_cb = None @@ -145,7 +146,7 @@ object (self) ea#set_adjustment adj; ea#set_value alt; (* this should be done by set_adjustment but seems to fail on ubuntu 13.10 (at least) *) - let agl = alt -. float (try Srtm.of_wgs84 initial_wgs84 with _ -> 0) in + let agl = alt -. (try float (Srtm.of_wgs84 initial_wgs84) with _ -> ground_alt) in let agl_lab = GMisc.label ~text:(sprintf " AGL: %4.0fm" agl) ~packing:ha#add () in let plus10= GButton.button ~label:"+10" ~packing:ha#add () in let change_alt = fun x -> @@ -202,7 +203,7 @@ object (self) try set_coordinates (); let wgs84 = self#pos in - let agl = ea#value -. float (try Srtm.of_wgs84 wgs84 with _ -> 0) in + let agl = ea#value -. (try float (Srtm.of_wgs84 wgs84) with _ -> ground_alt) in agl_lab#set_text (sprintf " AGL: %4.0fm" agl) with _ -> () in @@ -282,6 +283,7 @@ object (self) if update then updated () | (None, false) | (Some _, true) -> () | Some _, false -> self#reset_moved () + method set_ground_alt ga = ground_alt <- ga method delete () = deleted <- true; (* BOF *) wpt_group#destroy () diff --git a/sw/lib/ocaml/mapWaypoints.mli b/sw/lib/ocaml/mapWaypoints.mli index 25d9ec5fa5..09c18514f8 100644 --- a/sw/lib/ocaml/mapWaypoints.mli +++ b/sw/lib/ocaml/mapWaypoints.mli @@ -52,6 +52,7 @@ class waypoint : method move : float -> float -> unit method name : string method set : ?altitude:float -> ?update:bool -> Latlong.geographic -> unit + method set_ground_alt : float -> unit method set_name : string -> unit method xy : float * float method zoom : float -> unit diff --git a/sw/lib/ocaml/srtm.ml b/sw/lib/ocaml/srtm.ml index 672744f070..22d3b7a1ae 100644 --- a/sw/lib/ocaml/srtm.ml +++ b/sw/lib/ocaml/srtm.ml @@ -79,6 +79,9 @@ let of_wgs84 = fun geo -> let of_utm = fun utm -> of_wgs84 (Latlong.of_utm WGS84 utm) +let available = fun geo -> + try ignore(of_wgs84 geo); true with _ -> false + let area_of_tile = fun tile -> let area = open_compressed "srtm.data.bz2" in let rec _area_of_tile = fun () -> diff --git a/sw/lib/ocaml/srtm.mli b/sw/lib/ocaml/srtm.mli index c3742b41bf..8c0a9becc7 100644 --- a/sw/lib/ocaml/srtm.mli +++ b/sw/lib/ocaml/srtm.mli @@ -33,11 +33,14 @@ exception Tile_not_found of error val error : error -> string +val available : Latlong.geographic -> bool +(** [available wgs84_pos] Returns true if srtm tile is available *) + val of_utm : Latlong.utm -> int (** [of_utm utm_pos] Returns the altitude of the given UTM position *) val of_wgs84 : Latlong.geographic -> int -(** [of_utm utm_pos] Returns the altitude of the given geographic position *) +(** [of_wgs84 wgs84_pos] Returns the altitude of the given geographic position *) val area_of_tile : string -> string diff --git a/sw/simulator/nps/nps_fdm_jsbsim.c b/sw/simulator/nps/nps_fdm_jsbsim.c index 19702fea82..b0d711d5e7 100644 --- a/sw/simulator/nps/nps_fdm_jsbsim.c +++ b/sw/simulator/nps/nps_fdm_jsbsim.c @@ -385,6 +385,9 @@ static void init_jsbsim(double dt) { //initRunning for all engines FDMExec->GetPropulsion()->InitRunning(-1); + // LLA initial coordinates (geodetic lat, geoid alt) + struct LlaCoor_d lla0; + JSBSim::FGInitialCondition *IC = FDMExec->GetIC(); if(!jsbsim_ic_name.empty()) { if ( ! IC->Load(jsbsim_ic_name)) { @@ -394,6 +397,12 @@ static void init_jsbsim(double dt) { delete FDMExec; exit(-1); } + + lla0 = { + FDMExec->GetPropagate()->GetLongitude(), + FDMExec->GetPropagate()->GetGeodLatitudeRad(), + FDMExec->GetPropagate()->GetAltitudeASLmeters() + }; } else { // FGInitialCondition::SetAltitudeASLFtIC @@ -421,17 +430,18 @@ static void init_jsbsim(double dt) { exit(-1); } - // compute offset between geocentric and geodetic ecef - struct LlaCoor_d lla0 = { RadOfDeg(NAV_LON0 / 1e7), gd_lat, (double)(NAV_ALT0+NAV_MSL0)/1000. }; - ecef_of_lla_d(&offset, &lla0); - struct EcefCoor_d ecef0 = { - MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(1)), - MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(2)), - MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(3)) - }; - VECT3_DIFF(offset, offset, ecef0); + lla0 = { RadOfDeg(NAV_LON0 / 1e7), gd_lat, (double)(NAV_ALT0+NAV_MSL0)/1000. }; } + // compute offset between geocentric and geodetic ecef + ecef_of_lla_d(&offset, &lla0); + struct EcefCoor_d ecef0 = { + MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(1)), + MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(2)), + MetersOfFeet(FDMExec->GetPropagate()->GetLocation().Entry(3)) + }; + VECT3_DIFF(offset, offset, ecef0); + // calculate vehicle max radius in m vehicle_radius_max = 0.01; // specify not 0.0 in case no gear int num_gear = FDMExec->GetGroundReactions()->GetNumGearUnits(); diff --git a/sw/simulator/sim.ml b/sw/simulator/sim.ml index 059afe960e..44228c7e49 100644 --- a/sw/simulator/sim.ml +++ b/sw/simulator/sim.ml @@ -195,7 +195,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct Some s -> begin try s.Gps.alt -. float (Srtm.of_wgs84 s.Gps.wgs84) with - _ -> s.Gps.alt + _ -> s.Gps.alt -. !alt0 end | None -> 0. in FM.state_update !state FM.nominal_airspeed (!wind_x, !wind_y, !wind_z) agl fm_period