diff --git a/conf/messages.xml b/conf/messages.xml index bfc9a6ec82..00af2a2946 100644 --- a/conf/messages.xml +++ b/conf/messages.xml @@ -367,9 +367,9 @@ - + - + diff --git a/sw/airborne/autopilot/main.c b/sw/airborne/autopilot/main.c index 7d4da6ce88..d1a2cc918b 100644 --- a/sw/airborne/autopilot/main.c +++ b/sw/airborne/autopilot/main.c @@ -475,10 +475,13 @@ inline void periodic_task( void ) { DOWNLINK_SEND_CIRCLE(&circle_x, &circle_y, &circle_radius); } if (in_segment) { DOWNLINK_SEND_SEGMENT(&segment_x_1, &segment_y_1, &segment_x_2, &segment_y_2); } - if (calib_status == WAITING_CALIB_CONTRAST) { - DOWNLINK_SEND_CALIB_START(); } - if (calib_status == CALIB_DONE && !estimator_flight_time) { - DOWNLINK_SEND_CALIB_CONTRAST(&ir_contrast); } + if (!estimator_flight_time) { + if (calib_status == WAITING_CALIB_CONTRAST) { + DOWNLINK_SEND_CALIB_START(); + } else if (calib_status == CALIB_DONE) { + DOWNLINK_SEND_CALIB_CONTRAST(&ir_contrast); + } + } } switch(_4Hz) { case 0: diff --git a/sw/ground_segment/tmtc/receive.ml b/sw/ground_segment/tmtc/receive.ml index f6b24cd2c4..01c4535a3f 100644 --- a/sw/ground_segment/tmtc/receive.ml +++ b/sw/ground_segment/tmtc/receive.ml @@ -54,6 +54,7 @@ let ap_modes = [|"MANUAL";"AUTO1";"AUTO2";"HOME"|] let gaz_modes = [|"MANUAL";"GAZ";"CLIMB";"ALT"|] let lat_modes = [|"MANUAL";"ROLL_RATE";"ROLL";"COURSE"|] let gps_modes = [|"NOFIX";"DRO";"2D";"3D";"GPSDRO"|] +let gps_hybrid_modes = [|"OFF";"ON"|] let if_modes = [|"OFF";"DOWN";"UP"|] let horiz_modes = [|"WAYPOINT";"ROUTE";"CIRCLE"|] @@ -263,7 +264,9 @@ let log_and_parse = fun log ac_name a msg values -> a.rpm <- a.throttle *. 100.; a.bat <- fvalue "voltage" /. 10.; a.stage_time <- ivalue "stage_time"; - a.block_time <- ivalue "block_time" + a.block_time <- ivalue "block_time"; + if a.flight_time > 0 && a.infrared.contrast_status = "WAITING" then + a.infrared.contrast_status <- "SKIPPED" | "PPRZ_MODE" -> a.ap_mode <- check_index (ivalue "ap_mode") ap_modes "AP_MODE"; a.gaz_mode <- check_index (ivalue "ap_gaz") gaz_modes "AP_GAZ"; @@ -284,7 +287,7 @@ let log_and_parse = fun log ac_name a msg values -> else if mcu1_status land 0b100 > 0 then "AUTO" else "MANUAL"; - a.infrared.gps_hybrid_mode <- ivalue "lls_calib" + a.infrared.gps_hybrid_mode <- check_index (ivalue "lls_calib") gps_hybrid_modes "HYBRID MODE" | "CAM" -> a.cam.phi <- (Deg>>Rad) (fvalue "phi"); a.cam.theta <- (Deg>>Rad) (fvalue "theta"); @@ -356,8 +359,9 @@ let send_fbw = fun a -> Ground_Pprz.message_send my_id "FLY_BY_WIRE" values let send_infrared = fun a -> + let gps_hybrid_mode = get_indexed_value gps_hybrid_modes a.infrared.gps_hybrid_mode in let values = [ "ac_id", Pprz.String a.id; - "gps_hybrid_mode", Pprz.Int a.infrared.gps_hybrid_mode; + "gps_hybrid_mode", Pprz.String gps_hybrid_mode; "gps_hybrid_factor", Pprz.Float a.infrared.gps_hybrid_factor; "contrast_status", Pprz.String a.infrared.contrast_status; "contrast_value", Pprz.Int a.infrared.contrast_value diff --git a/sw/lib/ocaml/pprz.ml b/sw/lib/ocaml/pprz.ml index 5644aadaaa..801b4f7d18 100644 --- a/sw/lib/ocaml/pprz.ml +++ b/sw/lib/ocaml/pprz.ml @@ -120,17 +120,24 @@ let field_of_xml = fun xml -> let f = try Xml.attrib xml "format" with _ -> default_format t in (ExtXml.attrib xml "name", { _type = t; fformat = f }) +let string_of_values = fun vs -> + String.concat " " (List.map (fun (a,v) -> sprintf "%s=%s" a (string_of_value v)) vs) + +let assoc = fun a vs -> + try List.assoc a vs with Not_found -> + failwith (sprintf "Attribute '%s' not found in '%s'" a (string_of_values vs)) + let float_assoc = fun (a:string) vs -> - match List.assoc a vs with + match assoc a vs with Float x -> x | _ -> invalid_arg "Pprz.float_assoc" let int_assoc = fun (a:string) vs -> - match List.assoc a vs with + match assoc a vs with Int x -> x | _ -> invalid_arg "Pprz.int_assoc" -let string_assoc = fun (a:string) (vs:values) -> string_of_value (List.assoc a vs) +let string_assoc = fun (a:string) (vs:values) -> string_of_value (assoc a vs) diff --git a/sw/simulator/sim.ml b/sw/simulator/sim.ml index 82cfc29001..f3ef0a2e82 100644 --- a/sw/simulator/sim.ml +++ b/sw/simulator/sim.ml @@ -123,7 +123,7 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct gps_availability := Pprz.int_assoc "gps_availability" vs; wind_x := Pprz.float_assoc "wind_east" vs; wind_y := Pprz.float_assoc "wind_north" vs; - infrared_contrast := Pprz.float_assoc "ir_contrast" vs; (** FIXME *) + infrared_contrast := Pprz.float_assoc "ir_contrast" vs; time_scale#set_value (Pprz.float_assoc "time_scale" vs) in diff --git a/sw/simulator/sim_ap.c b/sw/simulator/sim_ap.c index 2a42254d18..b2b5fdab31 100644 --- a/sw/simulator/sim_ap.c +++ b/sw/simulator/sim_ap.c @@ -1,5 +1,5 @@ /* Definitions and declarations required to compile autopilot code on a - i386 architecture. Binding for OCaml. */ + i386 architecture. Bindings for OCaml. */ #include #include diff --git a/sw/simulator/sim_ir.c b/sw/simulator/sim_ir.c index 4c97e74251..eae0a6b04a 100644 --- a/sw/simulator/sim_ir.c +++ b/sw/simulator/sim_ir.c @@ -1,4 +1,9 @@ -/* Infrared soft simulation. OCaml binding. */ +/** \file sim_ir.c + * \brief Regroup functions to simulate autopilot/infrared.c + * + * Infrared soft simulation. OCaml binding. + */ + #include #include "airframe.h"