From: Jérémie D. <Ba...@us...> - 2011-03-31 20:04:58
|
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 eb90593156e38fbbfaa7e6573d3f12c65e2d3a5d (commit) via 70fa41645cedd6cfb4814deff7f298908395818c (commit) via 453a2c70ceb9276c7a597ee1471c0419318b67c7 (commit) from 4b62957c82d4ee890ccd36c31370350a07b72deb (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 eb90593156e38fbbfaa7e6573d3f12c65e2d3a5d Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 22:01:32 2011 +0200 [krobot_viewer] reorganisation of the UI commit 70fa41645cedd6cfb4814deff7f298908395818c Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 21:46:28 2011 +0200 [krobot_viewer] display logs in the UI commit 453a2c70ceb9276c7a597ee1471c0419318b67c7 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 21:27:13 2011 +0200 [krobot_viewer] do not move outside of the board ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index ea76cc9..6b3dd20 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -466,34 +466,38 @@ module Board = struct let rec loop () = match board.points with | (x, y) :: rest -> - (* Turn the robot. *) - let alpha = math_mod_float (atan2 (y -. board.state.y) (x -. board.state.x) -. board.state.theta) (2. *. pi) in - lwt () = Lwt_log.info_f "turning by %f radiants" alpha in - lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), - Motor_turn(alpha, - board.ui#rotation_speed#adjustment#value, - board.ui#rotation_acceleration#adjustment#value)) in - lwt () = wait_done board in - - (* Move the robot. *) - let sqr x = x *. x in - let dist = sqrt (sqr (x -. board.state.x) +. sqr (y -. board.state.y)) in - lwt () = Lwt_log.info_f "moving by %f meters" dist in - lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), - Motor_move(dist, - board.ui#moving_speed#adjustment#value, - board.ui#moving_acceleration#adjustment#value)) in - lwt () = wait_done board in - - (* Remove the point. *) - (match board.points with - | _ :: l -> board.points <- l - | [] -> ()); - - (* Redraw everything without the last point. *) - queue_draw board; - - loop () + let radius = sqrt (2. *. robot_size *. robot_size) in + if x >= radius && x <= world_width -. radius && y >= radius && y <= world_height -. radius then begin + (* Turn the robot. *) + let alpha = math_mod_float (atan2 (y -. board.state.y) (x -. board.state.x) -. board.state.theta) (2. *. pi) in + lwt () = Lwt_log.info_f "turning by %f radiants" alpha in + lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), + Motor_turn(alpha, + board.ui#rotation_speed#adjustment#value, + board.ui#rotation_acceleration#adjustment#value)) in + lwt () = wait_done board in + + (* Move the robot. *) + let sqr x = x *. x in + let dist = sqrt (sqr (x -. board.state.x) +. sqr (y -. board.state.y)) in + lwt () = Lwt_log.info_f "moving by %f meters" dist in + lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), + Motor_move(dist, + board.ui#moving_speed#adjustment#value, + board.ui#moving_acceleration#adjustment#value)) in + lwt () = wait_done board in + + (* Remove the point. *) + (match board.points with + | _ :: l -> board.points <- l + | [] -> ()); + + (* Redraw everything without the last point. *) + queue_draw board; + + loop () + end else + Lwt_log.warning_f "can not move to (%f, %f)" x y | [] -> return () in @@ -559,6 +563,21 @@ lwt () = ignore (ui#window#connect#destroy ~callback:(wakeup wakener)); ui#window#show (); + Lwt_log.default := + Lwt_log.broadcast [ + !Lwt_log.default; + Lwt_log.make + ~output:(fun section level lines -> + List.iter + (fun line -> + ui#logs#buffer#insert + (Printf.sprintf "%s: %s\n" (Lwt_log.Section.name section) line)) + lines; + ui#scrolled_logs#vadjustment#set_value ui#scrolled_logs#vadjustment#upper; + return ()) + ~close:return + ]; + let lcd = LCD.create ui in ignore (ui#lcd#event#connect#expose (fun ev -> LCD.draw lcd; true)); diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index 61d06f6..56ec218 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -189,87 +189,119 @@ </packing> </child> <child> - <widget class="GtkButton" id="button_clear"> - <property name="label" translatable="yes">Clear trajectory</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkButton" id="button_smooth"> - <property name="label" translatable="yes">Simplify trajectory</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <widget class="GtkHBox" id="hbox2"> + <widget class="GtkTable" id="table2"> <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">2</property> <child> - <widget class="GtkLabel" id="label1"> + <widget class="GtkButton" id="button_clear"> + <property name="label" translatable="yes">Clear trajectory</property> <property name="visible">True</property> - <property name="label" translatable="yes">Tolerance:</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </widget> + </child> + <child> + <widget class="GtkButton" id="button_smooth"> + <property name="label" translatable="yes">Simplify trajectory</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> </widget> <packing> - <property name="expand">False</property> - <property name="position">0</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> </packing> </child> <child> - <widget class="GtkHScale" id="tolerance"> + <widget class="GtkButton" id="button_go"> + <property name="label" translatable="yes">Go!</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">0.10000000000000001 0 1 0.10000000000000001 0.20000000000000001 0.5</property> - <property name="draw_value">False</property> + <property name="receives_default">True</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="button_stop"> + <property name="label" translatable="yes">Stop</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="button_start_red"> + <property name="label" translatable="yes">Goto red initial position</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <widget class="GtkButton" id="button_start_blue"> + <property name="label" translatable="yes">Goto blue initial position</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> </widget> <packing> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> </packing> </child> </widget> <packing> <property name="expand">False</property> - <property name="position">3</property> + <property name="position">1</property> </packing> </child> <child> - <widget class="GtkButton" id="button_go"> - <property name="label" translatable="yes">Go!</property> + <widget class="GtkHBox" id="hbox13"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> </widget> <packing> <property name="expand">False</property> - <property name="position">4</property> + <property name="position">2</property> </packing> </child> <child> - <widget class="GtkButton" id="button_stop"> - <property name="label" translatable="yes">Stop</property> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> </widget> <packing> <property name="expand">False</property> - <property name="position">5</property> + <property name="position">3</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox12"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">4</property> </packing> </child> <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">8</property> + <property name="n_rows">9</property> <property name="n_columns">2</property> <child> <widget class="GtkSpinButton" id="moving_speed"> @@ -283,8 +315,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -300,8 +332,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -317,8 +349,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">6</property> - <property name="bottom_attach">7</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -334,8 +366,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">7</property> - <property name="bottom_attach">8</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -365,8 +397,8 @@ </child> </widget> <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -397,8 +429,8 @@ </child> </widget> <packing> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -429,8 +461,8 @@ </child> </widget> <packing> - <property name="top_attach">6</property> - <property name="bottom_attach">7</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -461,8 +493,8 @@ </child> </widget> <packing> - <property name="top_attach">7</property> - <property name="bottom_attach">8</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -492,6 +524,10 @@ </packing> </child> </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> </child> <child> <widget class="GtkHBox" id="hbox3"> @@ -519,8 +555,8 @@ </child> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> </packing> </child> <child> @@ -549,8 +585,8 @@ </child> </widget> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> </packing> </child> <child> @@ -579,8 +615,8 @@ </child> </widget> <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> </packing> </child> <child> @@ -593,8 +629,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> </packing> </child> <child> @@ -607,8 +643,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> </packing> </child> <child> @@ -621,8 +657,8 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> </packing> </child> <child> @@ -684,48 +720,89 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> </packing> </child> + <child> + <widget class="GtkHScale" id="tolerance"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">0.10000000000000001 0 1 0.10000000000000001 0.20000000000000001 0.5</property> + <property name="draw_value">False</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox15"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Tolerance: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment9"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> </widget> <packing> <property name="expand">False</property> - <property name="position">6</property> + <property name="position">5</property> </packing> </child> <child> - <widget class="GtkButton" id="button_start_red"> - <property name="label" translatable="yes">Goto red initial position</property> + <widget class="GtkHBox" id="hbox14"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> </widget> <packing> <property name="expand">False</property> - <property name="position">7</property> + <property name="position">6</property> </packing> </child> <child> - <widget class="GtkButton" id="button_start_blue"> - <property name="label" translatable="yes">Goto blue initial position</property> + <widget class="GtkHSeparator" id="hseparator1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> </widget> <packing> <property name="expand">False</property> - <property name="position">8</property> + <property name="position">7</property> </packing> </child> <child> - <widget class="GtkViewport" id="viewport1"> + <widget class="GtkScrolledWindow" id="scrolled_logs"> <property name="visible">True</property> - <property name="resize_mode">queue</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> - <placeholder/> + <widget class="GtkTextView" id="logs"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="cursor_visible">False</property> + </widget> </child> </widget> <packing> - <property name="position">9</property> + <property name="position">8</property> </packing> </child> </widget> hooks/post-receive -- krobot |