From: Pierre C. <Ba...@us...> - 2012-10-26 22:27:30
|
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 cf9f9165a120527867e0bc0815a5a609f5a2e645 (commit) via c315ed882e3d90289684f4bef4b76ff92244451b (commit) from 29443c43d4f4f00011fa3e0b3c8e07dbae034732 (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 cf9f9165a120527867e0bc0815a5a609f5a2e645 Author: Pierre Chambart <pie...@oc...> Date: Sat Oct 27 00:26:41 2012 +0200 Fix small bug in odometry reinitialisation commit c315ed882e3d90289684f4bef4b76ff92244451b Author: Pierre Chambart <pie...@oc...> Date: Sat Oct 27 00:25:10 2012 +0200 Adds a small example to run in the toplevel ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/examples/krobot_rolling.ml b/info/control2011/examples/krobot_rolling.ml new file mode 100644 index 0000000..c502593 --- /dev/null +++ b/info/control2011/examples/krobot_rolling.ml @@ -0,0 +1,112 @@ +#use "topfind" +#require "krobot";; +open Krobot_bus;; +open Krobot_message;; + +let moving = ref false +let roting = ref false + +(* le hub et driver doivent être lancés *) +let bus = Lwt_unix.run (Krobot_bus.get ()) +let send m = Lwt_unix.run (Krobot_message.send bus (Unix.gettimeofday (), m)) + +let handle_message (timestamp, message) = + match message with + | CAN(_, frame) -> begin + match decode frame with + + | Motor_status(m,t,_,_) -> + moving := m; + roting := t + + | _ -> + () + end + | _ -> + () + +(* a n'executer qu'une fois *) +let () = Lwt_react.E.keep (Lwt_react.E.map handle_message (Krobot_bus.recv bus)) + +let move distance speed acceleration = + send (Motor_move(distance,speed,acceleration)) +(** [Motor_move(distance, speed, acceleration)] command to make + the robot to move. + - [distance] is in m + - [speed] is in m/s + - [acceleration] is in m/s^2 +*) +let turn angle speed acceleration = + send (Motor_turn(angle,speed,acceleration)) + (** [Motor_turn(angle, speed, acceleration)] command to make the + robot to turn. + - [angle] is in rad + - [speed] is in rad/s + - [acceleration] is in rad/s^2 + *) + +let motor_stop lin_acc rot_acc = send (Motor_stop(lin_acc, rot_acc)) + (** [Motor_stop(lin_acc, rot_acc)] command to stop following the + current Bezier Spline and the queued ones. + - [lin_acc] in m/s^2 + - [rot_acc] in rad/s^2 + *) + +let wait t = Lwt_unix.run (lwt () = Lwt_unix.sleep 0. in Lwt_unix.sleep t) +(* en secondes *) + +let wait_ref_false r = + while !r do + wait 0.01; + done + +let beacon_speed s = send (Motor_command (2,s)) + + +let pi = 4. *. atan 1. + +let fait_un_truc () = + wait 2.; + Printf.printf "go\n%!"; + move 0.5 0.2 0.5; + wait_ref_false moving; + turn pi (pi/.2.) (pi/.2.); + wait_ref_false roting; + move 0.2 0.2 0.5 + +let () = move 2. 0.2 0.5 +let () = turn (pi/.2.) (pi/.2. /. 4.) (pi/.2. /. 4. /. 1.) +let () = send (Set_odometry( 0.1, 0.2, pi)) + +let () = send (Drive_activation false) +let () = send (Drive_activation true) +let () = send (Drive_torque_limit 100) +let () = send (Drive_torque_limit 3600) +let () = send (Torque_limit(4,5)) +let () = send (Torque_limit(8,5)) + +let () = move 1. 0.2 0.5 + +let () = move (-.1.) 0.2 0.5 + +let () = turn (20.*.pi) pi 0.5 + +let () = turn (-. 20.*.pi) pi 0.5 + +let () = motor_stop 0.5 0.5 + +(*lancer: + let () = fait_un_truc () +*) + +(* commande de la vm / planner *) +open Krobot_geom + +let send_bus m = Lwt_unix.run (Krobot_bus.send bus (Unix.gettimeofday (), m)) +let stop () = send_bus Strategy_stop +let clear () = send_bus (Trajectory_set_vertices []) +(* nettoie la trajectoire enregistree *) +let set_vertice x y = send_bus (Trajectory_set_vertices [{x;y}]) +(* enregistre la trajectoire *) +let go () = send_bus Trajectory_go + diff --git a/info/control2011/src/tools/krobot_vm.ml b/info/control2011/src/tools/krobot_vm.ml index a2b7534..7df6b4c 100644 --- a/info/control2011/src/tools/krobot_vm.ml +++ b/info/control2011/src/tools/krobot_vm.ml @@ -603,7 +603,7 @@ let rec exec robot actions = | `Blue, _ | `Auto, `Blue -> let { Krobot_geom.x; y }, angle = Krobot_config.blue_initial_position in [Krobot_message.Set_odometry( x, y, pi); - Krobot_message.Set_odometry( x, y, pi )])) + Set_odometry_indep( x, y, pi )])) | Load face :: rest -> exec robot (Node (None,[ Lift_down face; hooks/post-receive -- krobot |