From: Jérémie D. <Ba...@us...> - 2010-04-23 08:53:21
|
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 8b3e9b66e2076f44754a5283696bc17f3288f6d1 (commit) from ad5e0b49e34128237c74cb551a2f3243387d9a3f (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 8b3e9b66e2076f44754a5283696bc17f3288f6d1 Author: Jérémie Dimino <dim@gaia.(none)> Date: Fri Apr 23 10:51:53 2010 +0200 Use record instead of labelled arguments for D-Bus interface creation This improve error messages ----------------------------------------------------------------------- Changes: diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index 70fbde6..d8614ac 100644 --- a/info/control/driver/driver.ml +++ b/info/control/driver/driver.ml @@ -59,6 +59,8 @@ struct value : int React.signal; } + open Krobot_interfaces.Fr_krobot_Device_Compass + let make card path = lwt value = make_signal ~update_delay:(Config.update_delay *. 2.) (fun card -> snd =|< USBCard.call Commands.Compass.get card ()) card in let dev = { @@ -67,8 +69,9 @@ struct ~interfaces:[Export_unsafe.interface "compass" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Compass.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map Int32.of_int dev.value) - ()] + { + p_Value = (fun dev -> React.S.map Int32.of_int dev.value); + }] path; card = card; value = value; @@ -88,6 +91,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_LCD + let set_lcd dev lines = if List.length lines > 4 || List.exists (fun line -> String.length line > 20) lines then invalid_arg "SetLCD" @@ -114,10 +119,11 @@ struct ~interfaces:[Export_unsafe.interface "LCD" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_LCD.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_SetLCD:(fun ctx -> set_lcd) - ~m_BacklightOn:(fun ctx obj () -> backlight_on obj) - ~m_BacklightOff:(fun ctx obj () -> backlight_off obj) - ()] + { + m_SetLCD = (fun ctx -> set_lcd); + m_BacklightOn = (fun ctx obj () -> backlight_on obj); + m_BacklightOff = (fun ctx obj () -> backlight_off obj); + }] path; card = card; } in @@ -136,6 +142,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_Servo + let claws_enable dev = USBCard.call Commands.Servo.set_config dev.card (0b10100, 0) @@ -158,12 +166,13 @@ struct ~interfaces:[Export_unsafe.interface "servo" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Servo.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_ClawsEnable:(fun ctx obj () -> claws_enable obj) - ~m_ClawsDisable:(fun ctx obj () -> claws_disable obj) - ~m_ClawsOpen:(fun ctx obj () -> claws_open obj) - ~m_ClawsClose:(fun ctx obj () -> claws_close obj) - ~m_ClawsTake:(fun ctx obj () -> claws_take obj) - ()] + { + m_ClawsEnable = (fun ctx obj () -> claws_enable obj); + m_ClawsDisable = (fun ctx obj () -> claws_disable obj); + m_ClawsOpen = (fun ctx obj () -> claws_open obj); + m_ClawsClose = (fun ctx obj () -> claws_close obj); + m_ClawsTake = (fun ctx obj () -> claws_take obj); + }] path; card = card; } in @@ -182,6 +191,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_AX12 + let grip_up_position = 880 let grip_down_position = 580 let ax12_default_velocity = 50 @@ -255,7 +266,8 @@ struct ~interfaces:[Export_unsafe.interface "AX12" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_AX12.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_SetAX12:(fun ctx obj positions -> + { + m_SetAX12 = (fun ctx obj positions -> let positions = List.map (fun (x1, x2, x3) -> @@ -264,13 +276,13 @@ struct aa_velocity = Int32.to_int x3 }) positions in - set_ax12 obj positions) - ~m_GripUp:(fun ctx obj () -> grip_up obj) - ~m_GripDown:(fun ctx obj () -> grip_down obj) - ~m_GripOpen:(fun ctx obj () -> grip_open obj) - ~m_GripClose:(fun ctx obj () -> grip_close obj) - ~m_GripRelease:(fun ctx obj () -> grip_release obj) - ()] + set_ax12 obj positions); + m_GripUp = (fun ctx obj () -> grip_up obj); + m_GripDown = (fun ctx obj () -> grip_down obj); + m_GripOpen = (fun ctx obj () -> grip_open obj); + m_GripClose = (fun ctx obj () -> grip_close obj); + m_GripRelease = (fun ctx obj () -> grip_release obj); + }] path; card = card; } @@ -291,6 +303,8 @@ struct value : bool array React.signal; } + open Krobot_interfaces.Fr_krobot_Device_LogicSensors + let make card path = lwt value = make_signal (fun card -> USBCard.call Commands.Logic_sensors.get_state card ()) card in let dev = { @@ -299,8 +313,9 @@ struct ~interfaces:[Export_unsafe.interface "logic-sensors" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_LogicSensors.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map Array.to_list dev.value) - ()] + { + p_Value = (fun dev -> React.S.map Array.to_list dev.value); + }] path; card = card; value = value; @@ -321,6 +336,8 @@ struct value : int array React.signal; } + open Krobot_interfaces.Fr_krobot_Device_RangeFinders + let get_calibration dev id = USBCard.call Commands.Range_finders.get_calibration dev.card id @@ -341,16 +358,17 @@ struct ~interfaces:[Export_unsafe.interface "range-finders" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_RangeFinders.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map (fun a -> List.map Int32.of_int (Array.to_list a)) dev.value) - ~m_GetCalibration:(fun ctx obj id -> - lwt result = get_calibration obj (Int32.to_int id) in - return (List.map Int32.of_int (Array.to_list result))) - ~m_CalibrationStart:(fun ctx obj (id, skip_measure) -> - let id = Int32.to_int id in - calibration_start obj id skip_measure) - ~m_CalibrationStop:(fun ctx obj () -> calibration_stop obj) - ~m_CalibrationContinue:(fun ctx obj () -> calibration_continue obj) - ()] + { + p_Value = (fun dev -> React.S.map (fun a -> List.map Int32.of_int (Array.to_list a)) dev.value); + m_GetCalibration = (fun ctx obj id -> + lwt result = get_calibration obj (Int32.to_int id) in + return (List.map Int32.of_int (Array.to_list result))); + m_CalibrationStart = (fun ctx obj (id, skip_measure) -> + let id = Int32.to_int id in + calibration_start obj id skip_measure); + m_CalibrationStop = (fun ctx obj () -> calibration_stop obj); + m_CalibrationContinue = (fun ctx obj () -> calibration_continue obj); + }] path; card = card; value = value; @@ -365,6 +383,8 @@ end module Motors = struct + open Krobot_interfaces.Fr_krobot_Device_Motors + type trajectory = { trajectory : [ `Forward | `Backward | `Left | `Right | `Goto ]; mutable stopped : bool; @@ -665,39 +685,40 @@ struct ~interfaces:[Export_unsafe.interface "motors" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Motors.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_Turn:(fun ctx obj (angle, velocity, acceleration) -> - let angle = Int32.to_int angle in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - turn obj angle velocity acceleration >|= int32_of_move_result) - ~m_Move:(fun ctx obj (distance, velocity, acceleration) -> - let distance = Int32.to_int distance in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - move obj distance velocity acceleration >|= int32_of_move_result) - ~m_Goto:(fun ctx obj (x, y, velocity, acceleration, mode, bypass_distance) -> - let x = Int32.to_int x in - let y = Int32.to_int y in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - let mode = goto_mode_of_int32 mode in - let bypass_distance = Int32.to_int bypass_distance in - goto obj x y velocity acceleration mode bypass_distance >|= int32_of_move_result) - ~m_StopMotors:(fun ctx obj mode -> - let mode = stop_mode_of_int32 mode in - stop_motors obj mode) - ~m_SetVelocities:(fun ctx obj (velocity_l, acceleration_l, velocity_r, acceleration_r, duration) -> - let velocity_l = Int32.to_int velocity_l in - let acceleration_l = Int32.to_int acceleration_l in - let velocity_r = Int32.to_int velocity_r in - let acceleration_r = Int32.to_int acceleration_r in - set_velocities obj (velocity_l, velocity_r) (acceleration_l, acceleration_r) duration) - ~p_InhibitForwardUntil:((fun obj -> Var.signal obj.inhibit_forward_until), - (fun ctx -> set_inhibit_forward_until)) - ~p_InhibitBackwardUntil:((fun obj -> Var.signal obj.inhibit_backward_until), - (fun ctx -> set_inhibit_backward_until)) - ~p_State:(fun obj -> state obj) - ()] + { + m_Turn = (fun ctx obj (angle, velocity, acceleration) -> + let angle = Int32.to_int angle in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + turn obj angle velocity acceleration >|= int32_of_move_result); + m_Move = (fun ctx obj (distance, velocity, acceleration) -> + let distance = Int32.to_int distance in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + move obj distance velocity acceleration >|= int32_of_move_result); + m_Goto = (fun ctx obj (x, y, velocity, acceleration, mode, bypass_distance) -> + let x = Int32.to_int x in + let y = Int32.to_int y in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + let mode = goto_mode_of_int32 mode in + let bypass_distance = Int32.to_int bypass_distance in + goto obj x y velocity acceleration mode bypass_distance >|= int32_of_move_result); + m_StopMotors = (fun ctx obj mode -> + let mode = stop_mode_of_int32 mode in + stop_motors obj mode); + m_SetVelocities = (fun ctx obj (velocity_l, acceleration_l, velocity_r, acceleration_r, duration) -> + let velocity_l = Int32.to_int velocity_l in + let acceleration_l = Int32.to_int acceleration_l in + let velocity_r = Int32.to_int velocity_r in + let acceleration_r = Int32.to_int acceleration_r in + set_velocities obj (velocity_l, velocity_r) (acceleration_l, acceleration_r) duration); + p_InhibitForwardUntil = ((fun obj -> Var.signal obj.inhibit_forward_until), + (fun ctx -> set_inhibit_forward_until)); + p_InhibitBackwardUntil = ((fun obj -> Var.signal obj.inhibit_backward_until), + (fun ctx -> set_inhibit_backward_until)); + p_State = (fun obj -> state obj); + }] path; card = card; inhibit_forward_until = Var.create 0.0; @@ -727,6 +748,8 @@ let card_motor, set_card_motor = React.S.create None module Manager = struct + open Krobot_interfaces.Fr_krobot_Manager + let close card = match React.S.value card with | None -> return () @@ -759,9 +782,10 @@ struct OBus_object.make ~interfaces:[Krobot_interfaces.Fr_krobot_Manager.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_CardStates:(fun ctx obj () -> card_states obj) - ~m_Shutdown:(fun ctx obj () -> shutdown ctx obj) - ()] + { + m_CardStates = (fun ctx obj () -> card_states obj); + m_Shutdown = (fun ctx obj () -> shutdown ctx obj); + }] ["fr"; "krobot"; "Manager"] in OBus_object.attach manager (); @@ -774,6 +798,8 @@ end module Card = struct + open Krobot_interfaces.Fr_krobot_Card + type t = { card : USBCard.t option React.signal; obus : t OBus_object.t; @@ -813,14 +839,15 @@ struct ~interfaces:[Export_unsafe.interface "card" get_card; Krobot_interfaces.Fr_krobot_Card.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Name:(fun obj -> React.S.const name) - ~p_State:(fun obj -> React.S.map int32_of_card_state obj.state) - ~m_GetFirmwareBuild:(fun ctx obj () -> get_firmware_build obj) - ~m_GetBoardInfo:(fun ctx obj () -> get_board_info obj) - ~m_Bootloader:(fun ctx obj () -> bootloader obj) - ~m_Reset:(fun ctx obj () -> reset obj) - ~m_Test:(fun ctx obj () -> test obj) - ()] + { + p_Name = (fun obj -> React.S.const name); + p_State = (fun obj -> React.S.map int32_of_card_state obj.state); + m_GetFirmwareBuild = (fun ctx obj () -> get_firmware_build obj); + m_GetBoardInfo = (fun ctx obj () -> get_board_info obj); + m_Bootloader = (fun ctx obj () -> bootloader obj); + m_Reset = (fun ctx obj () -> reset obj); + m_Test = (fun ctx obj () -> test obj); + }] path; card = card; name = name; hooks/post-receive -- krobot |