From: Xavier L. <Ba...@us...> - 2013-04-18 13:43:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via a10ecb5f43d6247ced5b9ee5ac1ef8909e9f92a7 (commit) from 0140e38a6bc4281a82ece8fac326d852bcc9377c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a10ecb5f43d6247ced5b9ee5ac1ef8909e9f92a7 Author: Xavier Lagorce <Xav...@cr...> Date: Thu Apr 18 15:29:59 2013 +0200 [info/krobot-simulator] Added options to select what to simulate ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index c307a52..2ba335f 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -25,14 +25,18 @@ let time_step = 0.001 let fork = ref true let hil = ref false +let sensors_emu = ref true +let robot_sim = ref true let options = Arg.align [ "-no-fork", Arg.Clear fork, " Run in foreground"; + "-no-sensor", Arg.Clear sensors_emu, " Don't emulate sensor inputs"; + "-no-simulation", Arg.Clear robot_sim, " Don't simulate the robot"; "-hil", Arg.Set hil, " Run in hardware in the loop mode"; ] let usage = "\ -Usage: krobot-mc-simulator [options] +Usage: krobot-simulator [options] options are:" (* +-----------------------------------------------------------------+ @@ -349,7 +353,7 @@ let send_CAN_messages sim bus = let handle_message bus (timestamp, message) = match message with - | Kill "mc_simulator" -> + | Kill "simulator" -> exit 0 | CAN(_, frame) -> begin match !sim with @@ -502,16 +506,12 @@ lwt () = (* Handle krobot message. *) E.keep (E.map (handle_message bus) (Krobot_bus.recv bus)); - (* Kill any running mc_simulator. *) - lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Krobot_bus.Kill "mc_simulator") in + (* Kill any running simulator. *) + lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Krobot_bus.Kill "simulator") in (* Wait a bit to let the other handler release the connection *) lwt () = Lwt_unix.sleep 0.4 in - (* Set the motor_controller card in HIL mode if necessary *) - if !hil then - ignore (Krobot_message.send bus (Unix.gettimeofday (), Set_controller_mode true)) ; - (* Initial state of the simulator *) let local_sim = { state = { x = 0.; y = 0.; theta = 0. }; @@ -531,8 +531,17 @@ lwt () = } in sim := Some local_sim; - ignore(send_CAN_messages local_sim bus); - ignore(loop_urg local_sim bus); - - (* Loop forever. *) - Lwt_unix.run (loop bus local_sim) + if !robot_sim then begin + (* Set the motor_controller card in HIL mode if necessary *) + if !hil then + ignore (Krobot_message.send bus (Unix.gettimeofday (), Set_controller_mode true)) ; + ignore(send_CAN_messages local_sim bus); + ignore(loop bus local_sim) + end; + if !sensors_emu then begin + ignore(loop_urg local_sim bus) + end; + + (* Run forever *) + let t, _ = Lwt.wait () in + t hooks/post-receive -- krobot |