From: Jérémie D. <Ba...@us...> - 2011-05-29 15:28:32
|
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 23679818e579d02c51823757eac4e73395bfacbd (commit) from 1d0c8230aad0db42e828d14eed6bc7728308ceb7 (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 23679818e579d02c51823757eac4e73395bfacbd Author: Jérémie Dimino <je...@di...> Date: Sun May 29 17:27:54 2011 +0200 [info] keep krobot-objects for testing ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index f75063a..337a6f5 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -155,6 +155,13 @@ Executable "krobot-planner" MainIs: krobot_planner.ml BuildDepends: krobot, lwt.syntax, ocamlgraph +Executable "krobot-objects" + Path: src/tools + Install: true + CompiledObject: best + MainIs: krobot_objects.ml + BuildDepends: krobot, lwt.syntax + Executable "krobot-webcam" Path: src/tools Install: true diff --git a/info/control2011/_tags b/info/control2011/_tags index f229535..14d98e6 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: 658e3c296fe6ed07c286a18053ad18f1) +# DO NOT EDIT (digest: 2b0a35e51cf2e902c1aae093db385268) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -97,6 +97,11 @@ <src/tools/krobot_webcam.{native,byte}>: pkg_lwt.unix <src/tools/krobot_webcam.{native,byte}>: pkg_lwt.syntax <src/tools/krobot_webcam.{native,byte}>: pkg_lwt.react +# Executable krobot-objects +<src/tools/krobot_objects.{native,byte}>: use_krobot +<src/tools/krobot_objects.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_objects.{native,byte}>: pkg_lwt.syntax +<src/tools/krobot_objects.{native,byte}>: pkg_lwt.react # Executable krobot-replay <src/tools/krobot_replay.{native,byte}>: use_krobot <src/tools/krobot_replay.{native,byte}>: pkg_lwt.unix diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 1270096..b4b7d73 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 9b4431568a1901300432755d30aeb373) *) +(* DO NOT EDIT (digest: 710ef41bf3f100a1f1ecd818da6623e3) *) (* Regenerated by OASIS v0.2.1~alpha1 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5388,6 +5388,34 @@ let setup_t = {exec_custom = false; exec_main_is = "krobot_webcam.ml"; }); Executable ({ + cs_name = "krobot-objects"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; + bs_path = "src/tools"; + bs_compiled_object = Best; + bs_build_depends = + [ + InternalLibrary "krobot"; + FindlibPackage ("lwt.syntax", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])]; + }, + {exec_custom = false; exec_main_is = "krobot_objects.ml"; + }); + Executable + ({ cs_name = "krobot-replay"; cs_data = PropList.Data.create (); cs_plugin_data = []; diff --git a/info/control2011/src/tools/krobot_objects.ml b/info/control2011/src/tools/krobot_objects.ml new file mode 100644 index 0000000..0c2d681 --- /dev/null +++ b/info/control2011/src/tools/krobot_objects.ml @@ -0,0 +1,115 @@ +(* + * krobot_objects.ml + * ----------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Service handling the position of the objects on the board. *) + +open Lwt +open Lwt_react +open Krobot_bus +open Krobot_geom + +let section = Lwt_log.Section.make "krobot(objects)" + +(* +-----------------------------------------------------------------+ + | Types | + +-----------------------------------------------------------------+ *) + +type objects = { + bus : Krobot_bus.t; + (* The message bus used to communicate with the robot. *) + + mutable objects : vertice list; + (* The list of objects on the board. *) +} + +(* +-----------------------------------------------------------------+ + | Message handling | + +-----------------------------------------------------------------+ *) + +let handle_message objects (timestamp, message) = + match message with + | Kill "objects" -> + exit 0 + + | Send -> + ignore ( + let ts = Unix.gettimeofday () in + Krobot_bus.send objects.bus (ts, Objects objects.objects) + ) + + | _ -> + () + +(* +-----------------------------------------------------------------+ + | Command-line arguments | + +-----------------------------------------------------------------+ *) + +let fork = ref true + +let options = Arg.align [ + "-no-fork", Arg.Clear fork, " Run in foreground"; +] + +let usage = "\ +Usage: krobot-planner [options] +options are:" + +(* +-----------------------------------------------------------------+ + | Entry point | + +-----------------------------------------------------------------+ *) + +lwt () = + Arg.parse options ignore usage; + + (* Display all informative messages. *) + Lwt_log.append_rule "*" Lwt_log.Info; + + (* Open the krobot bus. *) + lwt bus = Krobot_bus.get () in + + (* Fork if not prevented. *) + if !fork then Lwt_daemon.daemonize (); + + (* Kill any running planner. *) + lwt () = Krobot_bus.send bus (Unix.gettimeofday (), Krobot_bus.Kill "objects") in + + (* Create a new planner. *) + let objects = { + bus; + objects = [ + { x = 0.800; y = 0.350 }; + { x = 1.150; y = 0.350 }; + { x = 1.850; y = 0.350 }; + { x = 2.200; y = 0.350 }; + { x = 1.500; y = 1.050 }; + { x = 0.800; y = 1.400 }; + { x = 2.200; y = 1.400 }; + { x = 1.150; y = 1.750 }; + { x = 1.850; y = 1.750 }; + { x = 0.200; y = 0.290 }; + { x = 0.200; y = 0.570 }; + { x = 0.200; y = 0.850 }; + { x = 0.200; y = 1.130 }; + { x = 0.200; y = 1.410 }; + { x = 2.800; y = 0.290 }; + { x = 2.800; y = 0.570 }; + { x = 2.800; y = 0.850 }; + { x = 2.800; y = 1.130 }; + { x = 2.800; y = 1.410 }; + ]; + } in + + (* Handle krobot message. *) + E.keep (E.map (handle_message objects) (Krobot_bus.recv bus)); + + (* Sends initial objects. *) + lwt () = Krobot_bus.send objects.bus (Unix.gettimeofday (), Objects objects.objects) in + + (* Wait forever. *) + fst (wait ()) hooks/post-receive -- krobot |