From: Jérémie D. <Ba...@us...> - 2010-05-09 17:13:55
|
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 ba76d82676dc69f2b4d19d4ebb879c01cf839090 (commit) from 52b5193323033b0809ef32a3a4dcd1c5eeda496f (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 ba76d82676dc69f2b4d19d4ebb879c01cf839090 Author: Jérémie Dimino <je...@di...> Date: Sun May 9 19:13:16 2010 +0200 add a test which compute an average value for the infrared sensors ----------------------------------------------------------------------- Changes: diff --git a/info/control/myocamlbuild.ml b/info/control/myocamlbuild.ml index e436a62..4efa331 100644 --- a/info/control/myocamlbuild.ml +++ b/info/control/myocamlbuild.ml @@ -86,6 +86,7 @@ let targets = List.filter_opt (function (true, target) -> Some target | (false, (have_lwt_unix && have_obus, "tests/trajectories.best"); (have_lwt_unix && have_obus, "tests/move.best"); (have_lwt_unix && have_obus, "tests/scan_infrared.best"); + (have_lwt_unix && have_obus, "tests/infrared.best"); ] (* +-----------------------------------------------------------------+ diff --git a/info/control/tests/infrared.ml b/info/control/tests/infrared.ml new file mode 100644 index 0000000..8b3a8f2 --- /dev/null +++ b/info/control/tests/infrared.ml @@ -0,0 +1,22 @@ +(* + * infrared.ml + * ----------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +open Lwt + +lwt () = + lwt krobot = Krobot.create () in + lwt infrareds = OBus_property.monitor (Krobot.Infrared.states krobot) in + let rec loop acc1 acc2 n = + let i1, i2 = React.S.value infrareds in + let acc1 = acc1 + i1 and acc2 = acc2 + i2 in + lwt () = Lwt_io.printlf "%d %d" (acc1 / n) (acc2 / n) in + lwt () = Lwt_unix.sleep 0.05 in + loop acc1 acc2 (n + 1) + in + loop 0 0 1 hooks/post-receive -- krobot |