From: Jérémie D. <Ba...@us...> - 2010-02-23 23:25:12
|
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 a56ae2921c0bad51ebc5c2cd11f1d9ba336c67d5 (commit) via 3192e559c2ab36e98d3b408a015a95d24f6f2cd0 (commit) via 694a02719b4b016a8c206177f9d6d70e00ddee6d (commit) via 4435faf7b86a66387821cbeecbb930e3c575ef67 (commit) via 5e643c4777ad4c8746695c8c566e06e6056e79fa (commit) via b4e019644eb1a56de3a006e2136fb99e9c9517db (commit) from fa42027035da13c7ecdd2a9eebda5f869db6bb63 (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 a56ae2921c0bad51ebc5c2cd11f1d9ba336c67d5 Author: Jérémie Dimino <je...@di...> Date: Wed Feb 24 00:22:47 2010 +0100 [interface] add the get_current_speed request commit 3192e559c2ab36e98d3b408a015a95d24f6f2cd0 Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 23:58:44 2010 +0100 [driver] fix inhibition for manual mode when velocity is 0 commit 694a02719b4b016a8c206177f9d6d70e00ddee6d Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 23:34:56 2010 +0100 [driver] do not stop the motors on velocity=0 commit 4435faf7b86a66387821cbeecbb930e3c575ef67 Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 23:14:54 2010 +0100 [generators] fix get-firmware-build and get-board-info commit 5e643c4777ad4c8746695c8c566e06e6056e79fa Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 23:06:25 2010 +0100 [generators] typo commit b4e019644eb1a56de3a006e2136fb99e9c9517db Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 22:24:01 2010 +0100 High-level command to manipulate ax12s ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/joy_control.ml b/PC_Mainboard/clients/joy_control.ml index f0dcd05..a31a0b7 100644 --- a/PC_Mainboard/clients/joy_control.ml +++ b/PC_Mainboard/clients/joy_control.ml @@ -139,6 +139,7 @@ let try_call action f = return () let rec set_velocities krobot velocities = + lwt () = Log.info_f "set-velocities: left=%d right=%d" (fst velocities) (snd velocities) in lwt () = try_call "set-velocities" (fun () -> diff --git a/PC_Mainboard/common/types.ml b/PC_Mainboard/common/types.ml index 07199cb..3f970ca 100644 --- a/PC_Mainboard/common/types.ml +++ b/PC_Mainboard/common/types.ml @@ -61,3 +61,8 @@ type direction = [ `Forward | `Backward ] let obus_direction = OBus_type.mapping obus_int [(`Forward, 0); (`Backward, 1)] +type ax12_action = { + aa_id : int; + aa_position : int; + aa_velocity : int; +} with obus diff --git a/PC_Mainboard/common/types.mli b/PC_Mainboard/common/types.mli index ec1598d..6fa04c8 100644 --- a/PC_Mainboard/common/types.mli +++ b/PC_Mainboard/common/types.mli @@ -45,3 +45,10 @@ type ax12_stats = { ax12_cw_angle_limit : int; ax12_ccw_angle_limit : int; } with obus(sequence) + +(** Action on an AX12: *) +type ax12_action = { + aa_id : int; + aa_position : int; + aa_velocity : int; +} with obus(sequence) diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index aa0b6f4..effb1d6 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -12,6 +12,7 @@ module Log = Lwt_log.Make(struct let section = "driver" end) open OBus_pervasives +open Types open Lwt (* +-----------------------------------------------------------------+ @@ -80,6 +81,20 @@ struct include OBus.MakeInterface(struct let name = "fr.krobot.Device.AX12" end) + OL_method SetAX12 : Types.ax12_action structure list -> unit = fun dev actions -> + lwt () = + Lwt_list.iter_p + (fun action -> + USB_commands.AX12.goto + dev.card + ~id:action.aa_id + ~position:action.aa_position + ~velocity:action.aa_velocity + ~mode:`Action) + actions + in + USB_commands.AX12.action dev.card ~id:0xfe + let make card path = return { obus = OBus_object.make path; @@ -369,29 +384,26 @@ struct let fake_direction_l, direction_l, velocity_l = if velocity_l < 0 then (`Backward, `Backward, -velocity_l) else (`Forward, `Forward, velocity_l) in let fake_direction_r, direction_r, velocity_r = if velocity_r < 0 then (`Forward, `Backward, -velocity_r) else (`Backward, `Forward, velocity_r) in let date = Unix.gettimeofday () in - if ((direction_l = `Forward || direction_r = `Forward) && date < dev.inhibit_forward_until) - || ((direction_l = `Backward || direction_r = `Backward) && date < dev.inhibit_backward_until) then - fail (Failure "inhibited move") + if (((direction_l = `Forward && velocity_l > 0) || (direction_r = `Forward && velocity_r > 0)) && date < dev.inhibit_forward_until) + || (((direction_l = `Backward && velocity_l > 0) || (direction_r = `Backward && velocity_r > 0)) && date < dev.inhibit_backward_until) then + fail (Failure "inhibited move") else begin - if velocity_l = 0 && velocity_r = 0 then begin - stop_motors dev `Smooth - end else begin + if velocity_l <> 0 || velocity_r <> 0 then dev.state <- Manual(Lwt_unix.sleep duration >> stop_motors dev `Smooth, { velocity = velocity_l; acceleration = acceleration_l; direction = direction_l }, { velocity = velocity_r; acceleration = acceleration_r; direction = direction_r }); - lwt () = - if acceleration_l <> settings_l.acceleration then - USB_commands.Motors.traj_new_velocity dev.card `Left velocity_l acceleration_l fake_direction_l - else - USB_commands.Motors.traj_change_velocity dev.card `Left velocity_l fake_direction_l - and () = - if acceleration_r <> settings_r.acceleration then - USB_commands.Motors.traj_new_velocity dev.card `Right velocity_r acceleration_r fake_direction_r - else - USB_commands.Motors.traj_change_velocity dev.card `Right velocity_r fake_direction_r - in - USB_commands.Motors.traj_start dev.card `Both - end + lwt () = + if acceleration_l <> settings_l.acceleration then + USB_commands.Motors.traj_new_velocity dev.card `Left velocity_l acceleration_l fake_direction_l + else + USB_commands.Motors.traj_change_velocity dev.card `Left velocity_l fake_direction_l + and () = + if acceleration_r <> settings_r.acceleration then + USB_commands.Motors.traj_new_velocity dev.card `Right velocity_r acceleration_r fake_direction_r + else + USB_commands.Motors.traj_change_velocity dev.card `Right velocity_r fake_direction_r + in + USB_commands.Motors.traj_start dev.card `Both end let set_velocities dev velocities accelerations duration = diff --git a/PC_Mainboard/generators/gen_script_commands.ml b/PC_Mainboard/generators/gen_script_commands.ml index fd82083..020bf5d 100644 --- a/PC_Mainboard/generators/gen_script_commands.ml +++ b/PC_Mainboard/generators/gen_script_commands.ml @@ -88,7 +88,7 @@ let () = printf " let __type_card name = keyword name [(\"interface\", `Interface); (\"sensor\", `Sensor); (\"motor\", `Motor)] in\n"; let card_type = typ "card" in List.iter - (print "\"unsafe\"" "Card.") + (print "\"unsafe\"; \"card\"" "Card.") (List.map (function | Request req -> Request{ req with req_args = Arg("card", card_type) :: req.req_args } diff --git a/PC_Mainboard/interface/interface.ml b/PC_Mainboard/interface/interface.ml index e00fdee..8d042dc 100644 --- a/PC_Mainboard/interface/interface.ml +++ b/PC_Mainboard/interface/interface.ml @@ -202,12 +202,14 @@ let typ name = let card = [ request ~name:"get-firmware-build" - ~code:PcInterface.get_firmware_build + ~code:PcInterface.cmd_get + ~args:[Cst(uint8, PcInterface.get_firmware_build)] ~repl:[Arg("date", string)] (); request ~name:"get-board-info" - ~code:PcInterface.get_board_info + ~code:PcInterface.cmd_get + ~args:[Cst(uint8, PcInterface.get_board_info)] ~repl:[Arg("info", string)] (); command @@ -525,5 +527,12 @@ let interfaces = [ ~args:[Cst(uint8, PcInterface.motor_disable); Arg("motor", typ "motor")] (); + request + ~name:"get-velocities" + ~code:PcInterface.cmd_get + ~args:[Cst(uint8, PcInterface.get_current_speed)] + ~repl:[Arg("right", sint32); + Arg("left", sint32)] + (); ]); ] diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index df76ee4..1b21ace 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -172,6 +172,14 @@ OP_method CalibrationStop : unit OP_method CalibrationContinue : unit (* +-----------------------------------------------------------------+ + | AX12 | + +-----------------------------------------------------------------+ *) + +include MakeDevice(struct let name = "AX12" end) + +OP_method SetAX12 : Types.ax12_action structure list -> unit + +(* +-----------------------------------------------------------------+ | Motors | +-----------------------------------------------------------------+ *) diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index b926f60..ea2e27a 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -62,6 +62,12 @@ val calibration_start : t -> int -> bool -> unit Lwt.t val calibration_continue : t -> unit Lwt.t val calibration_stop : t -> unit Lwt.t +(** {6 AX12s} *) + +val set_ax12 : t -> Types.ax12_action list -> unit Lwt.t + (** [set_ax12 krobot actions] move all given ax12 at the same + time. *) + (** {6 Motors} *) val turn : t -> angle : int -> velocity : int -> acceleration : int -> Types.move_result Lwt.t hooks/post-receive -- krobot |