|
From: Jérémie D. <Ba...@us...> - 2010-02-10 20:47:40
|
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 51ecd70a79d4b6d4cfffc41676e4c9dc21a3fba3 (commit)
via 0381389a694f94d2a3ef498cc56f8f6c6a1c8bd5 (commit)
from 6c3fce1be59b3862417f78688e4bf3368f15b9ad (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 51ecd70a79d4b6d4cfffc41676e4c9dc21a3fba3
Author: Jérémie Dimino <je...@di...>
Date: Wed Feb 10 21:47:03 2010 +0100
add modules common/Config and common/Util
commit 0381389a694f94d2a3ef498cc56f8f6c6a1c8bd5
Author: Jérémie Dimino <je...@di...>
Date: Wed Feb 10 21:34:32 2010 +0100
[controller] save/restore terminal state
-----------------------------------------------------------------------
Changes:
diff --git a/PC_Mainboard/clients/_tags b/PC_Mainboard/clients/_tags
index 8582d38..c23ac4f 100644
--- a/PC_Mainboard/clients/_tags
+++ b/PC_Mainboard/clients/_tags
@@ -6,6 +6,7 @@
# Needed by the rest of the source
"lib-krobot": include
+"common": include
# lib-krobot uses obus
<**/*>: pkg_obus
diff --git a/PC_Mainboard/clients/common/config.ml b/PC_Mainboard/clients/common/config.ml
new file mode 100644
index 0000000..ac92ae7
--- /dev/null
+++ b/PC_Mainboard/clients/common/config.ml
@@ -0,0 +1,11 @@
+(*
+ * config.ml
+ * ---------
+ * Copyright : (c) 2010, Jeremie Dimino <je...@di...>
+ * Licence : BSD3
+ *
+ * This file is a part of [kro]bot.
+ *)
+
+let back_sensors = [3; 6; 7; 10]
+let front_sensors = [0; 1; 2; 4; 5; 8; 9; 11; 12; 13; 14; 15]
diff --git a/PC_Mainboard/clients/common/config.mli b/PC_Mainboard/clients/common/config.mli
new file mode 100644
index 0000000..ee9d807
--- /dev/null
+++ b/PC_Mainboard/clients/common/config.mli
@@ -0,0 +1,16 @@
+(*
+ * config.mli
+ * ----------
+ * Copyright : (c) 2010, Jeremie Dimino <je...@di...>
+ * Licence : BSD3
+ *
+ * This file is a part of [kro]bot.
+ *)
+
+(** Krobot parameters *)
+
+val front_sensors : int list
+ (** List of front sensors *)
+
+val back_sensors : int list
+ (** List of back sensors *)
diff --git a/PC_Mainboard/clients/common/util.ml b/PC_Mainboard/clients/common/util.ml
new file mode 100644
index 0000000..3edd854
--- /dev/null
+++ b/PC_Mainboard/clients/common/util.ml
@@ -0,0 +1,24 @@
+(*
+ * util.ml
+ * -------
+ * Copyright : (c) 2010, Jeremie Dimino <je...@di...>
+ * Licence : BSD3
+ *
+ * This file is a part of [kro]bot.
+ *)
+
+let front_colide sensors =
+ if Array.length sensors <> 16 then invalid_arg "Until.front_colide";
+ let rec loop = function
+ | 16 -> false
+ | n -> (sensors.(n) && List.mem n Config.front_sensors) || loop (n - 1)
+ in
+ loop 0
+
+let back_colide sensors =
+ if Array.length sensors <> 16 then invalid_arg "Until.back_colide";
+ let rec loop = function
+ | 16 -> false
+ | n -> (sensors.(n) && List.mem n Config.back_sensors) || loop (n - 1)
+ in
+ loop 0
diff --git a/PC_Mainboard/clients/common/util.mli b/PC_Mainboard/clients/common/util.mli
new file mode 100644
index 0000000..c34b8dc
--- /dev/null
+++ b/PC_Mainboard/clients/common/util.mli
@@ -0,0 +1,18 @@
+(*
+ * util.mli
+ * --------
+ * Copyright : (c) 2010, Jeremie Dimino <je...@di...>
+ * Licence : BSD3
+ *
+ * This file is a part of [kro]bot.
+ *)
+
+(** Utilities *)
+
+val front_colide : bool array -> bool
+ (** [front_colide sensors] returns whether on of the front sensors
+ is activated *)
+
+val back_colide : bool array -> bool
+ (** [front_colide sensors] returns whether on of the back sensors is
+ activated *)
diff --git a/PC_Mainboard/clients/security/hard_stop.ml b/PC_Mainboard/clients/security/hard_stop.ml
index d03c1f5..124230c 100644
--- a/PC_Mainboard/clients/security/hard_stop.ml
+++ b/PC_Mainboard/clients/security/hard_stop.ml
@@ -11,8 +11,6 @@
open Lwt
-let back_sensors = [3; 6; 7; 10]
-
(* Duration of an inhibition: *)
let duration = 1.0
@@ -28,17 +26,8 @@ let state_forward = ref OK
let state_backward = ref OK
let handle_colide krobot sensors =
- let colide_front = ref false and colide_back = ref false in
- for i = 0 to 15 do
- if sensors.(i) then begin
- if List.mem i back_sensors then
- colide_back := true
- else
- colide_front := true
- end
- done;
join [
- (if !colide_front then begin
+ (if Util.front_colide sensors then begin
lwt () = Krobot.inhibit_forward krobot duration in
if !state_forward = OK then begin
state_forward := Stopped;
@@ -49,7 +38,7 @@ let handle_colide krobot sensors =
state_forward := OK;
return ()
end);
- (if !colide_back then begin
+ (if Util.back_colide sensors then begin
lwt () = Krobot.inhibit_backward krobot duration in
if !state_backward = OK then begin
state_backward := Stopped;
diff --git a/PC_Mainboard/clients/tools/controller.ml b/PC_Mainboard/clients/tools/controller.ml
index d10ff37..3e36d5d 100644
--- a/PC_Mainboard/clients/tools/controller.ml
+++ b/PC_Mainboard/clients/tools/controller.ml
@@ -290,6 +290,7 @@ let rec copy_logs ic =
copy_logs ic
lwt () =
+ lwt () = save_state () in
lwt () = hide_cursor () in
try_lwt
let fdr, fdw = Unix.pipe () in
@@ -322,4 +323,4 @@ lwt () =
ignore signal;
Lwt_term.with_raw_mode (fun () -> loop krobot [])
finally
- show_cursor ()
+ restore_state ()
hooks/post-receive
--
krobot
|