From: Jérémie D. <Ba...@us...> - 2011-03-31 13:02:45
|
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 3d188dae29a66f3d1e491bd210699469799dfd2f (commit) from ef8216ee6b78ce3a36bcedd5eca2f6305ff65bf1 (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 3d188dae29a66f3d1e491bd210699469799dfd2f Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 15:01:37 2011 +0200 [info] change the type of Motor_status messages ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index fe1dc3c..16db1d2 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -22,7 +22,7 @@ type t = | Encoder_position_direction_3_4 of int * direction * int * direction | Encoder_position_speed_3 of float * float | Encoder_position_speed_4 of float * float - | Motor_status of bool + | Motor_status of bool * bool * bool * bool | Motor_move of float * float * float | Motor_turn of float * float * float | Motor_stop @@ -53,10 +53,10 @@ let to_string = function sprintf "Encoder_position_speed_4(%f, %f)" pos speed - | Motor_status moving -> + | Motor_status(m1, m2, m3, m4) -> sprintf - "Motor_status(%B)" - moving + "Motor_status(%B, %B, %B, %B)" + m1 m2 m3 m4 | Motor_move(dist, speed, acc) -> sprintf "Motor_move(%f, %f, %f)" @@ -119,9 +119,14 @@ let encode = function ~remote:false ~format:F29bits ~data - | Motor_status moving -> + | Motor_status(m1, m2, m3, m4) -> let data = String.create 1 in - put_uint8 data 0 (if moving then 1 else 0); + let x = 0 in + let x = if m1 then x lor 1 else x in + let x = if m2 then x lor 2 else x in + let x = if m3 then x lor 4 else x in + let x = if m4 then x lor 8 else x in + put_uint8 data 0 x; frame ~identifier:103 ~kind:Data @@ -228,7 +233,11 @@ let decode frame = (get_float32 frame.data 0, get_float32 frame.data 4) | 103 -> - Motor_status(get_uint8 frame.data 0 <> 0) + let x = get_uint8 frame.data 0 in + Motor_status(x land 1 <> 0, + x land 2 <> 0, + x land 4 <> 0, + x land 8 <> 0) | 104 -> Odometry (float (get_sint16 frame.data 0) /. 1000., diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index 5c80ce7..5d83d7e 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -20,8 +20,8 @@ type t = (** The position and speed of encoder 3. *) | Encoder_position_speed_4 of float * float (** The position and speed of encoder 4. *) - | Motor_status of bool - (** [true] iff a movement is in progress. *) + | Motor_status of bool * bool * bool * bool + (** Status of the 4 motors. *) | Motor_move of float * float * float (** [Motor_move(distance, speed, acceleration)] command to make the robot to move. diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index beaa8ec..0c1b484 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -225,7 +225,8 @@ lwt () = sim.command <- Idle; return () | Req_motor_status -> - Krobot_message.send bus (Unix.gettimeofday (), Motor_status(sim.command <> Idle)) + let moving = sim.command <> Idle in + Krobot_message.send bus (Unix.gettimeofday (), Motor_status(false, false, moving, moving)) | Set_odometry(x, y, theta) -> sim.state <- { x; y; theta }; return () diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index d6ebd28..ea76cc9 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -524,12 +524,12 @@ module Board = struct board.ui#entry_theta#set_text (string_of_float theta); queue_draw board end - | Motor_status true -> - board.moving <- true; - board.ui#entry_moving#set_text "yes" - | Motor_status false -> - board.moving <- false; - board.ui#entry_moving#set_text "no" + | Motor_status(m1, m2, m3, m4) -> + board.moving <- m3 || m4; + board.ui#entry_moving1#set_text (if m1 then "yes" else "no"); + board.ui#entry_moving2#set_text (if m2 then "yes" else "no"); + board.ui#entry_moving3#set_text (if m3 then "yes" else "no"); + board.ui#entry_moving4#set_text (if m4 then "yes" else "no") | _ -> ()) (Krobot_message.recv bus) diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index df63329..61d06f6 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -494,19 +494,6 @@ </widget> </child> <child> - <widget class="GtkEntry" id="entry_moving"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="invisible_char">•</property> - <property name="text" translatable="yes">no</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - </packing> - </child> - <child> <widget class="GtkHBox" id="hbox3"> <property name="visible">True</property> <child> @@ -638,6 +625,67 @@ <property name="bottom_attach">4</property> </packing> </child> + <child> + <widget class="GtkHBox" id="hbox11"> + <property name="visible">True</property> + <child> + <widget class="GtkEntry" id="entry_moving1"> + <property name="width_request">1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">no</property> + </widget> + <packing> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="entry_moving2"> + <property name="width_request">1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">no</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="entry_moving3"> + <property name="width_request">1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">no</property> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="entry_moving4"> + <property name="width_request">1</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + <property name="text" translatable="yes">no</property> + </widget> + <packing> + <property name="position">3</property> + </packing> + </child> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> hooks/post-receive -- krobot |