From: Jérémie D. <Ba...@us...> - 2010-05-03 22:29:26
|
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 66dedfca5354b3f86c64a228aed599a524ab2ff4 (commit) via 20b5a26a977291905b9653372ab4f2ab6ae44619 (commit) from a6065f0298911af84185793f11f82ef31b3ce992 (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 66dedfca5354b3f86c64a228aed599a524ab2ff4 Author: Jérémie Dimino <je...@di...> Date: Tue May 4 00:28:10 2010 +0200 high-level commands for the gate commit 20b5a26a977291905b9653372ab4f2ab6ae44619 Author: Kro[bot] <krobot@wally.(none)> Date: Mon May 3 21:33:54 2010 +0000 commands for the gate ----------------------------------------------------------------------- Changes: diff --git a/info/control/clients/script.ml b/info/control/clients/script.ml index f96ea83..a537b04 100644 --- a/info/control/clients/script.ml +++ b/info/control/clients/script.ml @@ -505,7 +505,30 @@ let () = Krobot.claws_disable krobot); register ~path:["claws"] "take" f0 (fun logger krobot -> - Krobot.claws_take krobot) + Krobot.claws_take krobot); + + (* +---------------------------------------------------------------+ + | Gate | + +---------------------------------------------------------------+ *) + + register ~path:["gate"] "enable" f0 + (fun logger krobot -> + Krobot.Gate.enable krobot); + register ~path:["gate"] "disable" f0 + (fun logger krobot -> + Krobot.Gate.disable krobot); + register ~path:["gate"] "close" f0 + (fun logger krobot -> + Krobot.Gate.close krobot); + register ~path:["gate"] "release" f0 + (fun logger krobot -> + Krobot.Gate.release krobot); + register ~path:["gate"] "hold-closed" f0 + (fun logger krobot -> + Krobot.Gate.hold_closed krobot); + register ~path:["gate"] "stop" f0 + (fun logger krobot -> + Krobot.Gate.stop krobot) (* +-----------------------------------------------------------------+ | Unsafe commands | @@ -577,8 +600,13 @@ let make_command cmd = { fun args logger krobot -> let args = List.map2 - (fun (name, str) typ -> arg_of_string typ str) - args + (fun name typ -> + match try Some(List.assoc name args) with Not_found -> None with + | Some value -> + arg_of_string typ value + | None -> + Printf.ksprintf failwith "missing %S argument" name) + (Value.arg_names cmd.Commands.send) (Value.C.type_sequence (Value.arg_types cmd.Commands.send)) in lwt result = Krobot.unsafe_call cmd krobot args in diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index 67cb2d7..7c24272 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"]; + card_interface, ["Servo"; "Compass"; "AX12"; "LCD"; "Gate"]; card_monitoring, ["Power"]; card_sensor, ["LogicSensors"; "RangeFinders"]; card_motor, ["Motors"]; @@ -459,6 +459,71 @@ struct end (* +-----------------------------------------------------------------+ + | Gate | + +-----------------------------------------------------------------+ *) + +module Gate = +struct + include Service(struct let name = "Gate" end) + + open Krobot_interfaces.Fr_krobot_Device_Gate + + let enable () = + USBCard.call Commands.Gate.enable (get_card card) (`Both) + + let disable () = + USBCard.call Commands.Gate.disable (get_card card) (`Both) + + let close () = + USBCard.call Commands.Gate.move (get_card card) (`Both, true, 200, 80) + + let release () = + USBCard.call Commands.Gate.move (get_card card) (`Both, false, 200, 100) + + let hold_closed () = + USBCard.call Commands.Gate.move (get_card card) (`Both, true, 200, 1 lsl 29) + + let stop () = + USBCard.call Commands.Gate.move (get_card card) (`Both, true, 10, 10) + + let () = + OBus_object.add_interface obus + (make ~notify_mode + { + m_Enable = ( + fun ctx obj () -> + lwt result = enable obj in + OBus_method.return ctx result + ); + m_Disable = ( + fun ctx obj () -> + lwt result = disable obj in + OBus_method.return ctx result + ); + m_Close = ( + fun ctx obj () -> + lwt result = close obj in + OBus_method.return ctx result + ); + m_Release = ( + fun ctx obj () -> + lwt result = release obj in + OBus_method.return ctx result + ); + m_HoldClosed = ( + fun ctx obj () -> + lwt result = hold_closed obj in + OBus_method.return ctx result + ); + m_Stop = ( + fun ctx obj () -> + lwt result = stop obj in + OBus_method.return ctx result + ); + }) +end + +(* +-----------------------------------------------------------------+ | Motors | +-----------------------------------------------------------------+ *) @@ -1129,6 +1194,7 @@ lwt () = OBus_object.export bus Logic_sensors.obus; OBus_object.export bus Range_finders.obus; OBus_object.export bus Motors.obus; + OBus_object.export bus Gate.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 9f05c13..e41006e 100644 --- a/info/control/lib-krobot/krobot.ml +++ b/info/control/lib-krobot/krobot.ml @@ -72,6 +72,34 @@ let team krobot = let jack krobot = React.S.map (fun ls -> ls.(15)) krobot.logic_sensors *) + +(* +-----------------------------------------------------------------+ + | Gate | + +-----------------------------------------------------------------+ *) + +module Gate = +struct + open Krobot_interfaces.Fr_krobot_Device_Gate + + let enable krobot = + OBus_method.call m_Enable (device krobot "Gate") () + + let disable krobot = + OBus_method.call m_Disable (device krobot "Gate") () + + let close krobot = + OBus_method.call m_Close (device krobot "Gate") () + + let release krobot = + OBus_method.call m_Release (device krobot "Gate") () + + let hold_closed krobot = + OBus_method.call m_HoldClosed (device krobot "Gate") () + + let stop krobot = + OBus_method.call m_Stop (device krobot "Gate") () +end + (* +-----------------------------------------------------------------+ | Compass | +-----------------------------------------------------------------+ *) diff --git a/info/control/lib-krobot/krobot.mli b/info/control/lib-krobot/krobot.mli index 2c096b2..70157cd 100644 --- a/info/control/lib-krobot/krobot.mli +++ b/info/control/lib-krobot/krobot.mli @@ -47,6 +47,28 @@ type devices_status = { val devices_status : t -> devices_status OBus_property.r (** List of services with their status *) +(** {6 Gate} *) + +module Gate : sig + val enable : t -> unit Lwt.t + (** Enable the motor of the gate *) + + val disable : t -> unit Lwt.t + (** Disable the motor of the gate *) + + val close : t -> unit Lwt.t + (** Close the gate *) + + val release : t -> unit Lwt.t + (** Open the gate *) + + val hold_closed : t -> unit Lwt.t + (** Close the gate and keep it that way *) + + val stop : t -> unit Lwt.t + (** Stop holding the gate *) +end + (** {6 LCD} *) val set_lcd : t -> string list -> unit Lwt.t diff --git a/info/control/protocol/commands.ml b/info/control/protocol/commands.ml index 11438e8..cef550b 100644 --- a/info/control/protocol/commands.ml +++ b/info/control/protocol/commands.ml @@ -942,5 +942,55 @@ struct } end +module Gate = +struct + let () = make_interface "Gate" + + let motor : [ `Left | `Both | `Right ] single = + enum Uint8 + [("left", `Left, PcInterface.motor_left); + ("both", `Both, PcInterface.motor_both); + ("right", `Right, PcInterface.motor_right)] + + let enable = + register { + name = "Enable"; + response = false; + command = PcInterface.cmd_motor; + request = Some PcInterface.motor_enable; + send = (arg1 + ("motor", motor)); + recv = arg0; + section = ""; + } + + let disable = + register { + name = "Disable"; + response = false; + command = PcInterface.cmd_motor; + request = Some PcInterface.motor_disable; + send = (arg1 + ("motor", motor)); + recv = arg0; + section = ""; + } + + let move = + register { + name = "Move"; + response = false; + command = PcInterface.cmd_motor; + request = Some PcInterface.motor_move; + send = (arg4 + ("motor", motor) + ("sens", boolean) + ("velocity", uint8) + ("duration", uint32)); + recv = arg0; + section = ""; + } +end + (* Remove references *) let commands = List.map (fun (name, members) -> (name, !members)) !commands diff --git a/info/control/protocol/krobot.obus b/info/control/protocol/krobot.obus index 45b5e03..e10f3f3 100644 --- a/info/control/protocol/krobot.obus +++ b/info/control/protocol/krobot.obus @@ -15,6 +15,26 @@ interface have changed. *) +interface "fr.krobot.Device.Gate" { + method Enable : () -> () + (** Enable the motor of the gate *) + + method Disable : () -> () + (** Disable the motor of the gate *) + + method Close : () -> () + (** Close the gate *) + + method Release : () -> () + (** Open the gate *) + + method HoldClosed : () -> () + (** Close the gate and keep it that way *) + + method Stop : () -> () + (** Stop holding the gate *) +} + interface "fr.krobot.Device.Compass" { property.r Value : int32 (** Current value of the compass *) hooks/post-receive -- krobot |