From: Jérémie D. <Ba...@us...> - 2010-02-18 22:44: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 6f556df4ed198f82f795fbd18b86cf51e9275015 (commit) from 473355d363bbc31784528a6238acd0a3baad451e (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 6f556df4ed198f82f795fbd18b86cf51e9275015 Author: Jérémie Dimino <je...@di...> Date: Thu Feb 18 23:40:10 2010 +0100 Add commands for calibration ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/init_position.ml b/PC_Mainboard/clients/init_position.ml index 2217b76..4683c51 100644 --- a/PC_Mainboard/clients/init_position.ml +++ b/PC_Mainboard/clients/init_position.ml @@ -12,13 +12,13 @@ open Lwt let move_backward_slowly krobot = - Log#notice "moving backward"; + lwt () = Log#notice "moving backward" in Krobot.move krobot ~dist:(-1000) ~speed:100 ~acc:100 >>= function | `OK -> - Log#error "where am i ???"; + lwt () = Log#error "where am i ???" in exit 1 | `Stopped -> - Log#notice "backward colisiton dectected"; + lwt () = Log#notice "backward colisiton dectected" in return () lwt () = @@ -26,17 +26,17 @@ lwt () = lwt () = move_backward_slowly krobot in - Log#notice "going to initial position on first axis"; + lwt () = Log#notice "going to initial position on first axis" in lwt _ = Krobot.move krobot ~dist:Config.initial_position ~speed:400 ~acc:800 in - Log#notice "turning"; + lwt () = Log#notice "turning" in lwt _ = Krobot.turn krobot ~angle:(-90) ~speed:400 ~acc:800 in lwt () = move_backward_slowly krobot in - Log#notice "going to initial position on second axis"; + lwt () = Log#notice "going to initial position on second axis" in lwt _ = Krobot.move krobot ~dist:Config.initial_position ~speed:400 ~acc:800 in - Log#notice "turning"; + lwt () = Log#notice "turning" in lwt _ = Krobot.turn krobot ~angle:45 ~speed:400 ~acc:800 in return () diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index 1d147a3..a25c932 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -45,6 +45,12 @@ let commands = [ args = [("card", Arg_keyword ["interface"; "sensor"; "motor"])] }; { name = "get-calibration"; args = [] }; + { name = "calibration-start"; + args = [("range-finder", Arg_int); ("skip-meas", Arg_keyword ["true"; "false"])] }; + { name = "calibration-stop"; + args = [] }; + { name = "calibration-continue"; + args = [] }; ] let set_of_list l = List.fold_left (fun set x -> TextSet.add x set) TextSet.empty l @@ -167,6 +173,16 @@ let exec krobot line = in Log#notice "%s" (Buffer.contents buffer); return () + | "calibration-start" -> + Krobot.calibration_start krobot (arg_int "range-finder" 0) + (match arg_string "skip-meas" "false" with + | "true" -> true + | "false" -> false + | _ -> raise (Failure "invalid boolean value")) + | "calibration-continue" -> + Krobot.calibration_continue krobot + | "calibration-stop" -> + Krobot.calibration_stop krobot | _ -> Log#error "unknown command %S" action; return () diff --git a/PC_Mainboard/driver/commands.ml b/PC_Mainboard/driver/commands.ml index 44ce69d..97337c7 100644 --- a/PC_Mainboard/driver/commands.ml +++ b/PC_Mainboard/driver/commands.ml @@ -75,6 +75,23 @@ struct RW.set_uint8 data 1 num; lwt data = Card.send_request card Protocol.cmd_get data in return (Array.init 8 (fun i -> RW.get_uint8 data i)) + + let calibration_start card num skip_meas = + let data = Card.make_buffer () in + RW.set_uint8 data 0 Protocol.cal_start; + RW.set_uint8 data 1 num; + RW.set_uint8 data 2 (if skip_meas then 1 else 0); + Card.send_command card Protocol.cmd_calibrate data + + let calibration_continue card = + let data = Card.make_buffer () in + RW.set_uint8 data 0 Protocol.cal_continue; + Card.send_command card Protocol.cmd_calibrate data + + let calibration_stop card = + let data = Card.make_buffer () in + RW.set_uint8 data 0 Protocol.cal_stop; + Card.send_command card Protocol.cmd_calibrate data end module Motor = diff --git a/PC_Mainboard/driver/commands.mli b/PC_Mainboard/driver/commands.mli index 1b7ff04..43fc243 100644 --- a/PC_Mainboard/driver/commands.mli +++ b/PC_Mainboard/driver/commands.mli @@ -31,6 +31,9 @@ end module Range_finders : sig val get : Card.t -> int array Lwt.t val get_calibration : Card.t -> int -> int array Lwt.t + val calibration_start : Card.t -> int -> bool -> unit Lwt.t + val calibration_continue : Card.t -> unit Lwt.t + val calibration_stop : Card.t -> unit Lwt.t end module Motor : sig diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index c9563e4..37379f1 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -152,6 +152,13 @@ struct OL_method GetCalibration : int -> int array = fun dev num -> Commands.Range_finders.get_calibration dev.card num + OL_method CalibrationStart : int -> bool -> unit = fun dev num skip_meas -> + Commands.Range_finders.calibration_start dev.card num skip_meas + OL_method CalibrationStop : unit = fun dev -> + Commands.Range_finders.calibration_stop dev.card + OL_method CalibrationContinue : unit = fun dev -> + Commands.Range_finders.calibration_continue dev.card + let rec loop dev = lwt data = Commands.Range_finders.get dev.card in if data <> dev.data then begin diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 8d2ec2e..fd4a1a1 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -88,7 +88,7 @@ let get_bus () = match try Some(Sys.getenv "KROBOT") with Not_found -> None with | Some command -> begin try_lwt - Log#info "connecting to the krobot with command %S" command; + lwt () = Log#info "connecting to the krobot with command %S" command in let process = Lwt_process.open_process (Lwt_process.shell command) in let transport = OBus_transport.make @@ -101,15 +101,15 @@ let get_bus () = lwt () = OBus_bus.register_connection connection in return connection with exn -> - Log#exn exn "failed to create remote transport"; + lwt () = Log#exn exn "failed to create remote transport" in fail exn end | None -> try_lwt - Log#info "connecting to the krobot with the local krobot bus"; + lwt () = Log#info "connecting to the krobot with the local krobot bus" in Lazy.force bus with exn -> - Log#exn exn "failed to connect to the local krobot bus"; + lwt () = Log#exn exn "failed to connect to the local krobot bus" in fail exn let create ?peer () = @@ -163,6 +163,9 @@ let jack krobot = include MakeDevice(struct let name = "RangeFinders" end) OP_method GetCalibration : int -> int array +OP_method CalibrationStart : int -> bool -> unit +OP_method CalibrationStop : unit +OP_method CalibrationContinue : unit (* +-----------------------------------------------------------------+ | AX12 | diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index 86e6b08..cb468bb 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -55,6 +55,10 @@ val get_calibration : t -> int -> int array Lwt.t (** [get_calibration krobot num] returns the calibration of the given range finder. *) +val calibration_start : t -> int -> bool -> unit Lwt.t +val calibration_continue : t -> unit Lwt.t +val calibration_stop : t -> unit Lwt.t + (** {6 Manipulation of AX12s} *) val ax12_goto : t -> id : int -> pos : int -> speed : int -> unit Lwt.t hooks/post-receive -- krobot |