From: Jérémie D. <Ba...@us...> - 2010-02-24 21:26: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 ec6a88b803f8747e048f74bd305d67e32be01ac7 (commit) from 0a529d96f005d2befe3919348127e415a4bbd8bc (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 ec6a88b803f8747e048f74bd305d67e32be01ac7 Author: Jérémie Dimino <je...@di...> Date: Wed Feb 24 22:23:07 2010 +0100 Add a command to retreive the driver motors state ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index ec111c8..614e73c 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -202,6 +202,10 @@ let () = and velocity motor = int ~default:400 ("velocity" ^ motor) and acceleration motor = int ~default:800 ("acceleration" ^ motor) in + register "motors-state" f0 + (fun logger krobot -> + lwt state = Krobot.motors_state krobot in + logger [text "motors state: "; text state]); register "stop-motors" (f1 stop_mode) (fun logger krobot mode -> Krobot.stop_motors krobot ~mode); diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 1ccb0b4..1bc7bc8 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -257,6 +257,28 @@ struct include OBus.MakeInterface(struct let name = "fr.krobot.Device.Motors" end) + let string_of_direction = function + | `Forward -> "forward" + | `Backward -> "backward" + + OL_method GetState : string = fun dev -> + return (match dev.state with + | Static -> + "static" + | Trajectory traj -> + Printf.sprintf "trajectory: trajectory=%s stopped=%B" + (match traj.trajectory with + | `Forward -> "forward" + | `Backward -> "backward" + | `Left -> "left" + | `Right -> "right" + | `Goto -> "goto") + traj.stopped + | Manual(_, settings_l, settings_r) -> + Printf.sprintf "manual: left={ direction=%s; velocity=%d; acceleration=%d } right={ direction=%s; velocity=%d; acceleration=%d }" + (string_of_direction settings_l.direction) settings_l.velocity settings_l.acceleration + (string_of_direction settings_r.direction) settings_r.velocity settings_r.acceleration) + (* +---------------------------------------------------------------+ | High-level movement | +---------------------------------------------------------------+ *) diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index bec637f..60d4cd4 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -189,6 +189,7 @@ OP_method StopMotors : mode : Types.stop_mode -> unit OP_method SetVelocities : velocities : int * int -> accelerations : int * int -> duration : float -> unit OP_method InhibitForward : float -> unit OP_method InhibitBackward : float -> unit +OP_method GetState as motors_state : string (* +-----------------------------------------------------------------+ | Cards | diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index ea2e27a..0dbb1c6 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -70,6 +70,9 @@ val set_ax12 : t -> Types.ax12_action list -> unit Lwt.t (** {6 Motors} *) +val motors_state : t -> string Lwt.t + (** Return a string describing the current state of motors *) + val turn : t -> angle : int -> velocity : int -> acceleration : int -> Types.move_result Lwt.t val move : t -> distance : int -> velocity : int -> acceleration : int -> Types.move_result Lwt.t val goto : t -> hooks/post-receive -- krobot |