From: Pierre C. <Ba...@us...> - 2012-05-15 15:35:24
|
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 a66675c38188c8ce812898d3d4865d53294c7be6 (commit) via ea47bc225093a0f6c9c0534c4177d74036f11966 (commit) from 387e765be280cde4559fa39b47ae6650e728b813 (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 a66675c38188c8ce812898d3d4865d53294c7be6 Author: chicco <cha...@cr...> Date: Tue May 15 17:34:06 2012 +0200 [control] krobot_vm set the led according to the team, some packets doc commit ea47bc225093a0f6c9c0534c4177d74036f11966 Author: chicco <cha...@cr...> Date: Tue May 15 15:45:55 2012 +0200 [krobot_viewer] reduce line size ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index a071772..752e937 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -23,11 +23,18 @@ type t = | Beacon_lowlevel_position of float * float * int (** The position of the beacon as internally stored (for calibration) *) | Switch1_status of bool * bool * bool * bool * bool * bool * bool * bool - (** The status of the first 8 switches *) + (** The status of the first 8 switches + 1 : start + 2 : team + 3 : emergency stop *) | Switch2_status of bool * bool * bool * bool * bool * bool * bool * bool (** The status of the other 8 switches *) | Switch_request of int * bool - (** A request to switch something on/off *) + (** A request to switch something on/off + 4 : buzzer + 5 : yellow led + 6 : red led + 7 : green led *) | Adc1_values of int * int * int * int (** The values of the first 4 ADCs *) | Adc2_values of int * int * int * int diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 92af2d6..c7453b7 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -78,11 +78,11 @@ let set_color ctx color = let r, g, b = match color with | Black -> (0., 0., 0.) | White -> (255., 255., 255.) - | Green -> (36., 145., 64.) - | Red -> (199., 23., 18.) - | Blue -> (0., 59., 128.) - | Yellow -> (252., 189., 31.) - | Purple -> (128., 0., 128.) + | Green -> (36., 200., 64.) + | Red -> (220., 23., 18.) + | Blue -> (20., 80., 170.) + | Yellow -> (232., 232., 0.) + | Purple -> (180., 0., 128.) | Brown -> (175., 89., 67.) in Cairo.set_source_rgb ctx (r /. 255.) (g /. 255.) (b /. 255.) @@ -124,21 +124,27 @@ let draw viewer = (* Draw beacon supports *) Cairo.rectangle ctx (-0.102) (-0.102) 0.08 0.08; + set_color ctx Purple; Cairo.fill ctx; Cairo.rectangle ctx (-0.102) (world_height /. 2. -. 0.04) 0.08 0.08; + set_color ctx Red; Cairo.fill ctx; Cairo.rectangle ctx (-0.102) (world_height +. 0.022) 0.08 0.08; + set_color ctx Purple; Cairo.fill ctx; Cairo.rectangle ctx (world_width +. 0.022) (-0.102) 0.08 0.08; + set_color ctx Red; Cairo.fill ctx; Cairo.rectangle ctx (world_width +. 0.022) (world_height /. 2. -. 0.04) 0.08 0.08; + set_color ctx Purple; Cairo.fill ctx; Cairo.rectangle ctx (world_width +. 0.022) (world_height +. 0.022) 0.08 0.08; + set_color ctx Red; Cairo.fill ctx; (* Draw the viewer background *) @@ -169,6 +175,7 @@ let draw viewer = set_color ctx Black; Cairo.set_line_width ctx (5. /. scale); Cairo.stroke ctx; + Cairo.set_line_width ctx (1. /. scale); (* draw the homes *) Cairo.move_to ctx 0. 0.; @@ -228,6 +235,30 @@ let draw viewer = set_color ctx Green; Cairo.fill ctx; + Cairo.rectangle ctx (0.64 +. 0.477 -. 0.125) (1. -. 0.125) 0.25 0.25; + set_color ctx Brown; + Cairo.fill ctx; + + Cairo.rectangle ctx (world_width -. (0.64 +. 0.477 +. 0.125)) (1. -. 0.125) 0.25 0.25; + set_color ctx Brown; + Cairo.fill ctx; + + Cairo.rectangle ctx 0.54 (-.0.1) 0.2 0.1; + set_color ctx Purple; + Cairo.fill ctx; + + Cairo.rectangle ctx (0.54 +. 0.47) (-.0.1) 0.2 0.1; + set_color ctx Red; + Cairo.fill ctx; + + Cairo.rectangle ctx (world_width -. 0.74) (-.0.1) 0.2 0.1; + set_color ctx Red; + Cairo.fill ctx; + + Cairo.rectangle ctx (world_width -. (0.74 +. 0.47)) (-.0.1) 0.2 0.1; + set_color ctx Purple; + Cairo.fill ctx; + (* Draw objects *) List.iter (fun { x; y } -> diff --git a/info/control2011/src/tools/krobot_vm.ml b/info/control2011/src/tools/krobot_vm.ml index 9a67034..32d541a 100644 --- a/info/control2011/src/tools/krobot_vm.ml +++ b/info/control2011/src/tools/krobot_vm.ml @@ -79,6 +79,9 @@ type robot = { mutable team : [ `Red | `Blue ]; (* The state of the team selector. *) + mutable emergency_stop : bool; + (* The state of the emergency button. *) + ax12_front_low_left : ax12; ax12_front_low_right : ax12; ax12_front_high_left : ax12; @@ -94,6 +97,20 @@ type robot = { | Message handling | +-----------------------------------------------------------------+ *) +let update_team_led robot = + let m1,m2 = + if robot.team = `Red then + Switch_request(6,true), Switch_request(7,false) + else + Switch_request(6,false), Switch_request(7,true) + in + lwt () = Krobot_message.send robot.bus (Unix.gettimeofday (),m1) in + Krobot_message.send robot.bus (Unix.gettimeofday (), m2) + +let clear_team_led robot = + lwt () = Krobot_message.send robot.bus (Unix.gettimeofday (), Switch_request(6,false)) in + Krobot_message.send robot.bus (Unix.gettimeofday (), Switch_request(7,false)) + let handle_message robot (timestamp, message) = match message with | CAN(_, frame) -> begin @@ -118,8 +135,11 @@ let handle_message robot (timestamp, message) = end else robot.beacon <- None - | Switch1_status(b, _, _, _, _, _, _, _) -> - robot.jack <- not b + | Switch1_status(jack, team, emergency, _, _, _, _, _) -> + robot.jack <- not jack; + robot.team <- if team then `Red else `Blue; + robot.emergency_stop <- emergency; + ignore (update_team_led robot) | Ax12_State(id, position, speed, torque) -> begin let set ax12 = @@ -481,6 +501,7 @@ lwt () = beacon = None; date_seen_beacon = 0.; team = `Red; + emergency_stop = false; ax12_front_low_left = { ax12_position = 0; ax12_speed = 0; ax12_torque = 0 }; ax12_front_low_right = { ax12_position = 0; ax12_speed = 0; ax12_torque = 0 }; ax12_front_high_left = { ax12_position = 0; ax12_speed = 0; ax12_torque = 0 }; @@ -491,6 +512,8 @@ lwt () = ax12_back_high_right = { ax12_position = 0; ax12_speed = 0; ax12_torque = 0 }; } in + lwt () = clear_team_led robot in + (* Handle krobot message. *) E.keep (E.map (handle_message robot) (Krobot_bus.recv bus)); hooks/post-receive -- krobot |