From: Jérémie D. <Ba...@us...> - 2010-05-08 18:17:59
|
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 6fb26acfacd1d4dad6c0548a468b0f306a592b96 (commit) via a4259c9b12f2c296cbba23bf555f87e21ed58c79 (commit) via 88da80d088b3f40b7573bcc5b2738df471f81501 (commit) via 7558634aade35227628e140f81b58cef7d602af8 (commit) from 34f24485d963204ad50c2b4adbf4b1be679cffb2 (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 6fb26acfacd1d4dad6c0548a468b0f306a592b96 Author: Jérémie Dimino <je...@di...> Date: Sat May 8 20:17:17 2010 +0200 remove commands for the AX12 with id=1 commit a4259c9b12f2c296cbba23bf555f87e21ed58c79 Author: Jérémie Dimino <je...@di...> Date: Sat May 8 20:03:15 2010 +0200 add a simple scanner commit 88da80d088b3f40b7573bcc5b2738df471f81501 Author: Jérémie Dimino <je...@di...> Date: Sat May 8 19:36:04 2010 +0200 add infrared status in the controller commit 7558634aade35227628e140f81b58cef7d602af8 Author: Jérémie Dimino <je...@di...> Date: Sat May 8 18:17:40 2010 +0200 add the object for infrared sensors ----------------------------------------------------------------------- Changes: diff --git a/info/control/clients/controller.ml b/info/control/clients/controller.ml index f038d41..cbe8baf 100644 --- a/info/control/clients/controller.ml +++ b/info/control/clients/controller.ml @@ -173,6 +173,7 @@ let draw krobot = Krobot.dev_motor = false; Krobot.dev_ax12 = false; Krobot.dev_lcd = false; + Krobot.dev_infrared = false; } in @@ -318,6 +319,19 @@ let draw krobot = return () end in + lwt () = + if driver && devices.Krobot.dev_infrared then begin + lwt i1, i2 = OBus_property.get (Krobot.infrared_states krobot) in + Draw.textc zone x 5 [textf "infrared 1: %d" i1]; + Draw.textc zone x 6 [textf "infrared 2: %d" i2]; + return () + end else begin + for i = 5 to 6 do + Draw.textc zone x i [fg red; text "unavailable"] + done; + return () + end + in (* ===== History ===== *) diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index 7130a43..b1d59ca 100644 --- a/info/control/driver/driver.ml +++ b/info/control/driver/driver.ml @@ -56,7 +56,7 @@ let get_card card = (* List of services, by cards *) let services = [ - card_interface, ["Servo"; "Compass"; "AX12"; "LCD"; "Gate"]; + card_interface, ["Servo"; "Compass"; "AX12"; "LCD"; "Gate"; "Infrared"]; card_monitoring, ["Power"]; card_sensor, ["LogicSensors"; "RangeFinders"]; card_motor, ["Motors"]; @@ -152,6 +152,31 @@ struct }] end + +(* +-----------------------------------------------------------------+ + | Infrared | + +-----------------------------------------------------------------+ *) + +module Infrared = +struct + include Service(struct let name = "Infrared" end) + + open Krobot_interfaces.Fr_krobot_Device_Infrared + + let states = + poll card (0, 0) + (fun card -> + lwt ar = USBCard.call Commands.Infrared.get_state card () in + return (ar.(0), ar.(1))) + + let () = + OBus_object.add_interfaces obus + [make ~notify_mode + { + p_States = (fun () -> React.S.map (fun (i1, i2) -> (Int32.of_int i1, Int32.of_int i2)) states); + }] +end + (* +-----------------------------------------------------------------+ | Compass | +-----------------------------------------------------------------+ *) @@ -314,17 +339,17 @@ struct USBCard.call Commands.AX12.action (get_card card) 0xfe let grip_up () = - set_ax12 [{ aa_id = 1; + set_ax12 [(*{ aa_id = 1; aa_position = 190; - aa_velocity = 50 }; + aa_velocity = 50 };*) { aa_id = 2; aa_position = 180; aa_velocity = 50 }] let grip_down () = - set_ax12 [{ aa_id = 1; + set_ax12 [(*{ aa_id = 1; aa_position = 490; - aa_velocity = 50 }; + aa_velocity = 50 };*) { aa_id = 2; aa_position = 510; aa_velocity = 50 }; @@ -1211,6 +1236,7 @@ lwt () = OBus_object.export bus Range_finders.obus; OBus_object.export bus Motors.obus; OBus_object.export bus Gate.obus; + OBus_object.export bus Infrared.obus; OBus_object.export bus (Card.make card_interface ["fr"; "krobot"; "Cards"; "Interface"]).Card.obus; OBus_object.export bus (Card.make card_sensor ["fr"; "krobot"; "Cards"; "Sensor"]).Card.obus; diff --git a/info/control/lib-krobot/krobot.ml b/info/control/lib-krobot/krobot.ml index b2ae4f6..e436389 100644 --- a/info/control/lib-krobot/krobot.ml +++ b/info/control/lib-krobot/krobot.ml @@ -44,6 +44,7 @@ type devices_status = { dev_motor : bool; dev_ax12 : bool; dev_lcd : bool; + dev_infrared : bool; } let devices_status krobot = @@ -55,6 +56,7 @@ let devices_status krobot = dev_motor = List.assoc "Motors" l; dev_ax12 = List.assoc "AX12" l; dev_lcd = List.assoc "LCD" l; + dev_infrared = List.assoc "Infrared" l; }) (OBus_property.make ~notify_mode @@ -74,6 +76,17 @@ let jack krobot = *) (* +-----------------------------------------------------------------+ + | Infrared | + +-----------------------------------------------------------------+ *) + +open Krobot_interfaces.Fr_krobot_Device_Infrared + +let infrared_states krobot = + OBus_property.map_r + (fun (i1, i2) -> (Int32.to_int i1, Int32.to_int i2)) + (OBus_property.make ~notify_mode p_States (device krobot "Infrared")) + +(* +-----------------------------------------------------------------+ | Power | +-----------------------------------------------------------------+ *) diff --git a/info/control/lib-krobot/krobot.mli b/info/control/lib-krobot/krobot.mli index 7bff545..ef3f09e 100644 --- a/info/control/lib-krobot/krobot.mli +++ b/info/control/lib-krobot/krobot.mli @@ -42,11 +42,16 @@ type devices_status = { dev_motor : bool; dev_ax12 : bool; dev_lcd : bool; + dev_infrared : bool; } val devices_status : t -> devices_status OBus_property.r (** List of services with their status *) +(** {6 Infrared} *) + +val infrared_states : t -> (int * int) OBus_property.r + (** {6 Power} *) val set_buzzer_state : t -> bool -> unit Lwt.t diff --git a/info/control/myocamlbuild.ml b/info/control/myocamlbuild.ml index 6519df2..deb5c13 100644 --- a/info/control/myocamlbuild.ml +++ b/info/control/myocamlbuild.ml @@ -83,6 +83,7 @@ let targets = List.filter_opt (function (true, target) -> Some target | (false, (have_lwt_unix && have_obus, "tests/stop_and_restart.best"); (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"); ] (* +-----------------------------------------------------------------+ diff --git a/info/control/protocol/krobot.obus b/info/control/protocol/krobot.obus index 12ca50c..6258f09 100644 --- a/info/control/protocol/krobot.obus +++ b/info/control/protocol/krobot.obus @@ -19,6 +19,10 @@ interface "fr.krobot.Device.Power" { method SetBuzzerState : (state : boolean) -> () } +interface "fr.krobot.Device.Infrared" { + property.r States : (int32 * int32) structure +} + interface "fr.krobot.Device.Gate" { method Enable : () -> () (** Enable the motor of the gate *) diff --git a/info/control/tests/scan_infrared.ml b/info/control/tests/scan_infrared.ml new file mode 100644 index 0000000..574d130 --- /dev/null +++ b/info/control/tests/scan_infrared.ml @@ -0,0 +1,39 @@ +(* + * scan_infrared.ml + * ---------------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +open Lwt + +let rec print krobot infrared = + lwt pos = Krobot.unsafe_call Commands.AX12.get_position krobot (1, 100) in + let i1, i2 = React.S.value infrared in + lwt () = Lwt_io.printlf "position: %3d, i1 = %4d, i2 = %4d" pos i1 i2 in + lwt () = Lwt_unix.sleep 0.2 in + print krobot infrared + +let delay = 1.5 + +let action pos = { + Types.aa_id = 1; + Types.aa_position = pos; + Types.aa_velocity = 200; +} + +lwt () = + lwt krobot = Krobot.create () in + let rec loop1 () = + lwt () = Krobot.set_ax12 krobot [action 250] in + lwt () = Lwt_unix.sleep delay in + loop2 () + and loop2 () = + lwt () = Krobot.set_ax12 krobot [action 750] in + lwt () = Lwt_unix.sleep delay in + loop1 () + in + lwt infrared = OBus_property.monitor (Krobot.infrared_states krobot) in + join [loop1 (); print krobot infrared] hooks/post-receive -- krobot |