From: Pierre C. <Ba...@us...> - 2012-04-25 23:07:49
|
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 b64fde9d0632479d027d3ebba220d7de086b645a (commit) from f089f8fedd909a0c41a4fe75fc52e2584b31f7f1 (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 b64fde9d0632479d027d3ebba220d7de086b645a Author: chicco <cha...@cr...> Date: Thu Apr 26 01:02:25 2012 +0200 [krobot_dump_ax12] small tool to record ax12 positions ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 08eb04c..7409387 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -222,12 +222,18 @@ Executable "krobot-can-display" Executable "krobot-ax12-control" Path: src/tools - Build$: flag(gtk) - Install$: flag(gtk) + Install: true CompiledObject: best MainIs: krobot_ax12_control.ml BuildDepends: krobot.can, lwt.syntax +Executable "krobot-dump-ax12" + Path: src/tools + Install: true + CompiledObject: best + MainIs: krobot_dump_ax12.ml + BuildDepends: krobot.can, lwt.syntax + # +-------------------------------------------------------------------+ # | Examples | # +-------------------------------------------------------------------+ diff --git a/info/control2011/_tags b/info/control2011/_tags index b45f0f4..3049ac4 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: 3852a61af000802215e40b6ad6830d71) +# DO NOT EDIT (digest: 77bb0a0cf22171b21400c7924cce86fe) # 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 @@ -91,10 +91,6 @@ <src/tools/krobot_ax12_control.{native,byte}>: pkg_lwt.syntax <src/tools/krobot_ax12_control.{native,byte}>: pkg_lwt.react <src/tools/krobot_ax12_control.{native,byte}>: pkg_bitstring -<src/tools/*.ml{,i}>: use_krobot-can -<src/tools/*.ml{,i}>: pkg_sexplib.syntax -<src/tools/*.ml{,i}>: pkg_sexplib -<src/tools/*.ml{,i}>: pkg_bitstring # Executable krobot-viewer <src/tools/krobot_viewer.{native,byte}>: use_krobot <src/tools/krobot_viewer.{native,byte}>: pkg_lwt.unix @@ -185,6 +181,19 @@ <src/tools/krobot_plot.{native,byte}>: pkg_cairo.lablgtk2 <src/tools/*.ml{,i}>: pkg_lwt.glib <src/tools/*.ml{,i}>: pkg_cairo.lablgtk2 +# Executable krobot-dump-ax12 +<src/tools/krobot_dump_ax12.{native,byte}>: use_krobot-can +<src/tools/krobot_dump_ax12.{native,byte}>: use_krobot +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_sexplib.syntax +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_sexplib +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_lwt.syntax +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_lwt.react +<src/tools/krobot_dump_ax12.{native,byte}>: pkg_bitstring +<src/tools/*.ml{,i}>: use_krobot-can +<src/tools/*.ml{,i}>: pkg_sexplib.syntax +<src/tools/*.ml{,i}>: pkg_sexplib +<src/tools/*.ml{,i}>: pkg_bitstring # Executable krobot-dump <src/tools/krobot_dump.{native,byte}>: use_krobot <src/tools/krobot_dump.{native,byte}>: pkg_lwt.unix diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index e2a975d..ef14fdf 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: ebf28739fe9d63028b7611d27a835a73) *) +(* DO NOT EDIT (digest: 3f1f69c4008e4511460ad8227132b513) *) (* Regenerated by OASIS v0.3.0~rc3 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5575,16 +5575,8 @@ let setup_t = cs_plugin_data = []; }, { - bs_build = - [ - (OASISExpr.EBool true, false); - (OASISExpr.EFlag "gtk", true) - ]; - bs_install = - [ - (OASISExpr.EBool true, false); - (OASISExpr.EFlag "gtk", true) - ]; + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; bs_path = "src/tools"; bs_compiled_object = Best; bs_build_depends = @@ -6053,6 +6045,36 @@ let setup_t = {exec_custom = false; exec_main_is = "krobot_plot.ml"; }); Executable ({ + cs_name = "krobot-dump-ax12"; + 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-can"; + 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_dump_ax12.ml"; + }); + Executable + ({ cs_name = "krobot-dump"; cs_data = PropList.Data.create (); cs_plugin_data = []; @@ -6143,13 +6165,13 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.3.0~rc3"; - oasis_digest = Some "\252#\185\030(\181\232\r\160\214B\172\240o\156_"; + oasis_digest = Some "q\1674\179\017\0115F\190\024gsXI=$"; oasis_exec = None; oasis_setup_args = []; };; let setup () = BaseSetup.setup setup_t;; -# 6154 "setup.ml" +# 6176 "setup.ml" (* OASIS_STOP *) let () = setup ();; diff --git a/info/control2011/src/tools/krobot_dump_ax12.ml b/info/control2011/src/tools/krobot_dump_ax12.ml new file mode 100644 index 0000000..8b95a5e --- /dev/null +++ b/info/control2011/src/tools/krobot_dump_ax12.ml @@ -0,0 +1,52 @@ +open Krobot_bus +open Krobot_message +open Lwt_react + +lwt bus = Krobot_bus.get () + +type ax12_info = + { id : int; + pos : int; + speed : int; + torque : int; + time : float } + +module IntMap = Map.Make(struct type t = int let compare = compare end) + +let previous = ref IntMap.empty +let is_previous info = + try + let v = IntMap.find info.id !previous in + (v.pos,v.speed) = (info.pos,info.speed) + with + | Not_found -> false + +let print_info ({ id; pos; speed; torque; time } as info) = + previous := IntMap.add id info !previous; + Printf.printf "id %i,pos %i, speed %i, torque %i, time %f\n%!" id pos speed torque time + +let log () = + E.keep + (E.map + (fun (time, message) -> + match message with + | CAN(_, frame) -> + begin + match Krobot_message.decode frame with + | Ax12_State (id,pos,speed,torque) -> + let info = { id;pos;speed;torque;time } in + if not (is_previous info) + then print_info info + | _ -> () + end + | _ -> ()) + (Krobot_bus.recv bus)) + +let rec loop_request () = + lwt () = Lwt_unix.sleep 0.01 in + lwt () = Lwt_list.iter_s (fun i -> Krobot_bus.send bus (Unix.gettimeofday (), CAN (Info, Krobot_message.encode (Ax12_Request_State i)))) [2;3] in + loop_request () + +let t = loop_request () +let () = log () +lwt () = fst (Lwt.wait ()) hooks/post-receive -- krobot |