You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(50) |
Feb
(137) |
Mar
(84) |
Apr
(36) |
May
(100) |
Jun
(5) |
Jul
|
Aug
(4) |
Sep
(13) |
Oct
(1) |
Nov
(4) |
Dec
(22) |
2011 |
Jan
(4) |
Feb
(9) |
Mar
(113) |
Apr
(76) |
May
(31) |
Jun
(19) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(4) |
Feb
|
Mar
(2) |
Apr
(6) |
May
(19) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(22) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
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 |
From: Xavier L. <Ba...@us...> - 2011-03-31 12:59:36
|
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 ef8216ee6b78ce3a36bcedd5eca2f6305ff65bf1 (commit) from 08f9457bae8f067a43784a49e4271a7b7c1a8963 (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 ef8216ee6b78ce3a36bcedd5eca2f6305ff65bf1 Author: Xavier Lagorce <Xav...@cr...> Date: Thu Mar 31 14:56:17 2011 +0200 [Controller_Motor_STM32] New version of trajectory controller This is a start for the new version of the trajectory controller. For the moment, it has the same functionnality as the old one but is a lot more generic (can control any motor independently). More is comming. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c index f3e9e55..ff3ffa8 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c @@ -49,6 +49,10 @@ typedef struct { uint16_t acceleration __attribute__((__packed__)); // Acceleration in 1/100 degrees/s^2 } turn_msg_t; +typedef struct { + uint8_t stop; // stop everything +} stop_msg_t; + // Union to manipulate CAN messages' data easily typedef union { encoder_msg_t data; @@ -80,6 +84,11 @@ typedef union { uint32_t data32[2]; } turn_can_msg_t; +typedef union { + stop_msg_t data; + uint32_t data32[2]; +} stop_can_msg_t; + // Can messages IDs #define CAN_MSG_ENCODERS34 100 // encoder_can_msg_t #define CAN_MSG_MOTOR3 101 // motor_can_msg_t @@ -88,6 +97,8 @@ typedef union { #define CAN_MSG_ODOMETRY 104 // odometry_can_msg_t #define CAN_MSG_MOVE 201 // move_can_msg_t #define CAN_MSG_TURN 202 // turn_can_msg_t +#define CAN_MSG_ODOMETRY_SET 203 // odometry_can_msg_t +#define CAN_MSG_STOP 204 // stop_can_msg_t // Process for communication static void NORETURN canMonitor_process(void); @@ -165,8 +176,10 @@ static void NORETURN canMonitor_process(void) { msg_odo.data.x = (int16_t)(odometry.x * 1000.0); msg_odo.data.y = (int16_t)(odometry.y * 1000.0); odometry.theta = fmodf(odometry.theta, 360.0); - if (odometry.theta > 180.) + if (odometry.theta > 180.0) odometry.theta -= 360.0; + if (odometry.theta < -180.0) + odometry.theta += 360.0; msg_odo.data.theta = (int16_t)(odometry.theta * 100.0); txm.data32[0] = msg_odo.data32[0]; @@ -184,10 +197,15 @@ static void NORETURN canMonitorListen_process(void) { can_rx_frame frame; bool received = false; can_tx_frame txm; + robot_state_t odometry; status_can_msg_t status_msg; move_can_msg_t move_msg; turn_can_msg_t turn_msg; + odometry_can_msg_t odometry_msg; + stop_can_msg_t stop_msg; + + tc_robot_t robot; // Initialize constant parameters of TX frame txm.dlc = 8; @@ -195,6 +213,12 @@ static void NORETURN canMonitorListen_process(void) { txm.ide = 1; txm.sid = 0; + // Initialize robot representation + robot.left_wheel = MOTOR3; + robot.right_wheel = MOTOR4; + robot.wheel_radius = 0.049245; + robot.shaft_width = 0.259; + while (1) { received = can_receive(CAND1, &frame, ms_to_ticks(100)); if (received) { @@ -202,7 +226,7 @@ static void NORETURN canMonitorListen_process(void) { // Handle requests switch (frame.eid) { case CAN_MSG_STATUS: - status_msg.data.is_moving = !tc_is_finished(); + status_msg.data.is_moving = tc_is_working(MOTOR1 | MOTOR2 | MOTOR3 | MOTOR4); txm.data32[0] = status_msg.data32[0]; txm.data32[1] = status_msg.data32[1]; txm.eid = CAN_MSG_STATUS; @@ -215,14 +239,30 @@ static void NORETURN canMonitorListen_process(void) { case CAN_MSG_MOVE: move_msg.data32[0] = frame.data32[0]; move_msg.data32[1] = frame.data32[1]; - if (tc_is_finished()) - tc_move(move_msg.data.distance / 1000.0, move_msg.data.speed / 1000.0, move_msg.data.acceleration / 1000.0); + if (!tc_is_working(MOTOR3 | MOTOR4)) + tc_move(&robot, move_msg.data.distance / 1000.0, move_msg.data.speed / 1000.0, move_msg.data.acceleration / 1000.0); break; case CAN_MSG_TURN: turn_msg.data32[0] = frame.data32[0]; turn_msg.data32[1] = frame.data32[1]; - if (tc_is_finished()) - tc_turn(turn_msg.data.angle / 100.0, turn_msg.data.speed / 100.0, turn_msg.data.acceleration / 100.0); + if (!tc_is_working(MOTOR3 | MOTOR4)) + tc_turn(&robot, turn_msg.data.angle / 100.0, turn_msg.data.speed / 100.0, turn_msg.data.acceleration / 100.0); + break; + case CAN_MSG_STOP: + stop_msg.data32[0] = frame.data32[0]; + stop_msg.data32[1] = frame.data32[1]; + if (stop_msg.data.stop == 1) { + tc_delete_controller(MOTOR3); + tc_delete_controller(MOTOR4); + } + break; + case CAN_MSG_ODOMETRY_SET: + odometry_msg.data32[0] = frame.data32[0]; + odometry_msg.data32[1] = frame.data32[1]; + odometry.x = ((float)odometry_msg.data.x) / 1000.0; + odometry.y = ((float)odometry_msg.data.y) / 1000.0; + odometry.theta = ((float)odometry_msg.data.theta) / 100.0; + odo_setState(&odometry); break; } } diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c index 75c88cf..a60c52e 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/main.c @@ -18,12 +18,12 @@ #include "command_generator.h" #include "trajectory_controller.h" -command_generator_t genR, genL; - -PROC_DEFINE_STACK(stack_op, KERN_MINSTACKSIZE * 8); +PROC_DEFINE_STACK(stack_ind, KERN_MINSTACKSIZE * 2); static void init(void) { + trajectory_controller_params_t params; + IRQ_ENABLE; /* Initialize debugging module (allow kprintf(), etc.) */ @@ -44,7 +44,23 @@ static void init(void) canMonitorInit(); // Start control of drive motors - init_trajectory_controller(); + tc_init(); + // Common parameters + params.encoder_gain = -360.0/2000.0/15.0; + params.G0 = 0.833; + params.tau = 0.015; + params.k[0] = -68.0325; + params.k[1] = -1.0205; + params.l = -params.k[0]; + params.l0[0] = 0.0236; + params.l0[1] = 3.9715; + params.T = 0.005; + // Initialize left motor + params.encoder = ENCODER3; + tc_new_controller(MOTOR3, ¶ms); + // Initialize right motor + params.encoder = ENCODER4; + tc_new_controller(MOTOR4, ¶ms); // Start odometry odometryInit(1e-3, 0.049245, 0.259, -2.0*M_PI/2000.0/15.0); @@ -64,30 +80,15 @@ static void init(void) } } -static void NORETURN demo_process(void) +static void NORETURN ind_process(void) { - while (1) { - // Light a LED on an unused motor to indicate we should be doing something - // with the motors very soon - LED1_ON(); - timer_delay(1000); - - // Move the robot ! - tc_move(2., 1., 1.); - - // Wait until the movement is finished - while (!tc_is_finished()) - timer_delay(1000); - - // Stop motor controllers to be able to freely move the robot - mc_delete_controller(MOTOR3); - mc_delete_controller(MOTOR4); - - // Doing nothing more, so shutdown the LED - LED1_OFF(); - - // Cleanly stop the demo process - proc_exit(); + while(1) { + if (tc_is_working(MOTOR3 | MOTOR4)) { + LED1_ON(); + } else { + LED1_OFF(); + } + timer_delay(500); } } @@ -96,7 +97,7 @@ int main(void) init(); /* Create a new child process */ - //proc_new(demo_process, NULL, sizeof(stack_op), stack_op); + proc_new(ind_process, NULL, sizeof(stack_ind), stack_ind); /* * The main process is kept to periodically report the stack diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c index 407af94..6186796 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c @@ -13,208 +13,210 @@ #define TRAPEZOID_STATE_ACC 1 #define TRAPEZOID_STATE_CONST 2 #define TRAPEZOID_STATE_DEC 3 -#define TRAPEZOID_STATE_TRIANGLE 4 #define SIGN(val) ((val) >= 0 ? 1 : -1) #define SELECT_THRESHOLD(dir) ((dir) == 1 ? GEN_CALLBACK_SUP : GEN_CALLBACK_INF) #define SELECT_THRESHOLD_DEC(dir) ((dir) == 1 ? GEN_CALLBACK_INF : GEN_CALLBACK_SUP) -void trapezoid_callback(command_generator_t *generator); - typedef struct { float angle, speed, acceleration, init_val; int8_t dir; uint8_t state, is_triangle; -} ramp_automaton_t; +} tc_automaton_t; + +typedef struct { + uint8_t enabled; // Is this controller enabled + uint8_t working; // Is this controller doing something ? + command_generator_t position; // Position generator (RAMP2) + command_generator_t speed; // Speed generator (RAMP) + tc_automaton_t aut; // Automaton to control movement +} trajectory_controller_t; + + +void trapezoid_callback(command_generator_t *generator); +void acc_stop_callback(command_generator_t *generator); -command_generator_t right_wheel, left_wheel, right_wheel_speed, left_wheel_speed; -ramp_automaton_t right_trap, left_trap; +trajectory_controller_t controllers[4]; -uint8_t controller_state; +static inline uint8_t get_motor_index(uint8_t motor_id) { + uint8_t motor_ind; + + for (motor_ind = 0; (motor_id >> (motor_ind+1)) != 0; motor_ind++) ; + + return motor_ind; +} void trapezoid_callback(command_generator_t *generator) { - ramp_automaton_t *automaton; - command_generator_t *trap, *trap_speed; - - // Select the correct trapezoid depending on which callback triggered - if (generator == &right_wheel || generator == &right_wheel_speed) { - automaton = &right_trap; - trap = &right_wheel; - trap_speed = &right_wheel_speed; - } else if (generator == &left_wheel || generator == &left_wheel_speed) { - automaton = &left_trap; - trap = &left_wheel; - trap_speed = &left_wheel_speed; - } else { + trajectory_controller_t *cont = NULL; + uint8_t i; + + // Select the correct controller depending on chich callbacl triggered + for (i=0; i < 4; i++) { + if (generator == &(controllers[i].position) + || generator == &(controllers[i].speed) ) { + cont = &controllers[i]; + break; + } + } + // Exit if we have not found any... + if (cont == NULL) { + // Disable the callback to prevent repeated useless triggering + remove_callback(generator); return; } - // Unregistering callbacks on the current ramp - remove_callback(trap); - remove_callback(trap_speed); + // Unregistering callbacks of the current phase + remove_callback(&cont->position); + remove_callback(&cont->speed); // Automaton evolution - switch (automaton->state) { + switch (cont->aut.state) { case TRAPEZOID_STATE_STOP: // The automaton is already stopped, this shouldn't happen break; case TRAPEZOID_STATE_ACC: // Speed is inceasing, we have to go to the constant speed phase of the movement - adjust_speed(trap_speed, 0.); - adjust_value(trap_speed, automaton->speed); - add_callback(trap, SELECT_THRESHOLD(automaton->dir), automaton->angle - automaton->speed*automaton->speed/automaton->acceleration/2., trapezoid_callback); - automaton->state = TRAPEZOID_STATE_CONST; - break; - case TRAPEZOID_STATE_TRIANGLE: - // Special case of triangle profile, we have to slow down at the end of the acceleration phase - adjust_speed(trap_speed, -automaton->acceleration); - adjust_value(trap_speed, automaton->speed); - add_callback(trap, SELECT_THRESHOLD(automaton->dir), automaton->angle, trapezoid_callback); - add_callback(trap_speed, SELECT_THRESHOLD_DEC(automaton->dir), 0.1*automaton->speed, trapezoid_callback); - automaton->state = TRAPEZOID_STATE_DEC; + adjust_speed(&cont->speed, 0.); + adjust_value(&cont->speed, cont->aut.speed); + add_callback(&cont->position, SELECT_THRESHOLD(cont->aut.dir), cont->aut.angle - cont->aut.speed*cont->aut.speed/cont->aut.acceleration/2., trapezoid_callback); + cont->aut.state = TRAPEZOID_STATE_CONST; break; case TRAPEZOID_STATE_CONST: // End of the constant speed phase, we have to slow down - adjust_speed(trap_speed, -automaton->acceleration); - add_callback(trap, SELECT_THRESHOLD(automaton->dir), automaton->angle, trapezoid_callback); - add_callback(trap_speed, SELECT_THRESHOLD_DEC(automaton->dir), 0.1*automaton->speed, trapezoid_callback); - automaton->state = TRAPEZOID_STATE_DEC; + adjust_speed(&cont->speed, -cont->aut.acceleration); + adjust_value(&cont->speed, cont->aut.speed); + add_callback(&cont->position, SELECT_THRESHOLD(cont->aut.dir), cont->aut.angle, trapezoid_callback); + add_callback(&cont->speed, SELECT_THRESHOLD_DEC(cont->aut.dir), 0.01*cont->aut.speed, trapezoid_callback); + cont->aut.state = TRAPEZOID_STATE_DEC; break; case TRAPEZOID_STATE_DEC: // End of the movement, stop the motor - adjust_speed(trap_speed, 0.); - adjust_value(trap_speed, 0.); - //adjust_value(trap, automaton->angle); - automaton->state = TRAPEZOID_STATE_STOP; - if (tc_is_finished()) - LED1_OFF(); + adjust_speed(&cont->speed, 0.); + adjust_value(&cont->speed, 0.); + cont->aut.state = TRAPEZOID_STATE_STOP; + cont->working = 0; break; } } -void init_trajectory_controller(void) { - float k[] = {-68.0325, -1.0205}; - float l0[] = {0.0236, 3.9715}; - - // Create generator for position and speed manipulation - new_ramp_generator(&right_wheel_speed, 0., 0.); - new_ramp_generator(&left_wheel_speed, 0., 0.); - new_ramp2_generator(&right_wheel, 0., &right_wheel_speed); - new_ramp2_generator(&left_wheel, 0., &left_wheel_speed); +void acc_stop_callback(command_generator_t *generator) { + trajectory_controller_t *cont = NULL; + uint8_t i; + + // Select the correct controller depending on chich callbacl triggered + for (i=0; i < 4; i++) { + if (generator == &(controllers[i].position) + || generator == &(controllers[i].speed) ) { + cont = &controllers[i]; + break; + } + } + // Exit if we have not found any... + if (cont == NULL) { + // Disable the callback to prevent repeated useless triggering + remove_callback(generator); + return; + } - // Start control of drive motors - mc_new_controller(MOTOR3, ENCODER3, -360.0/2000.0/15.0, 0.833, 0.015, 0.005, k, -k[0], l0, &left_wheel); - mc_new_controller(MOTOR4, ENCODER4, -360.0/2000.0/15.0, 0.833, 0.015, 0.005, k, -k[0], l0, &right_wheel); + // Unregistering associated callbacks + remove_callback(&cont->position); + remove_callback(&cont->speed); - // Start the generator - start_generator(&right_wheel); - start_generator(&left_wheel); - start_generator(&right_wheel_speed); - start_generator(&left_wheel_speed); - - // Initial state of automatons - right_trap.state = TRAPEZOID_STATE_STOP; - left_trap.state = TRAPEZOID_STATE_STOP; + // Stopping acceleration + adjust_speed(&cont->speed, 0.); + cont->working = 0; } -uint8_t tc_is_finished(void) { - // Is there currently a trapezoidal command running ? - if (right_trap.state == TRAPEZOID_STATE_STOP && left_trap.state == TRAPEZOID_STATE_STOP) - return 1; +void tc_init(void) { + uint8_t i; - // One automaton is running, last planified action should be in progress - return 0; -} + // All Trajectory controllers are disabled + for (i=0; i < 4; i++) { + controllers[i].enabled = 0; + } -void tc_move(float distance, float speed, float acceleration) { - float acc_dist, t_acc, t_end; + // Initialize motor controller system + motorControllerInit(); +} - // Verify parameters - if (distance == 0 || speed <= 0 || acceleration <= 0) - return; +void tc_new_controller(uint8_t motor, trajectory_controller_params_t *params) { + trajectory_controller_t *cont; - // Compute some common parameters - // For the right motor - right_trap.init_val = get_output_value(&right_wheel); - right_trap.dir = SIGN(distance); - right_trap.angle = right_trap.init_val + distance / WHEEL_R * 180 / M_PI; - right_trap.acceleration = right_trap.dir * acceleration / WHEEL_R * 180 / M_PI; - // For the left motor - left_trap.init_val = get_output_value(&left_wheel); - left_trap.dir = SIGN(distance); - left_trap.angle = left_trap.init_val + distance / WHEEL_R * 180 / M_PI; - left_trap.acceleration = left_trap.dir * acceleration / WHEEL_R * 180 / M_PI; + // Get corresponding controller + cont = &controllers[get_motor_index(motor)]; - // Is the trapezoidal speed profile posible ? - t_acc = speed / acceleration; - t_end = (speed * speed + fabsf(distance) * acceleration) / (speed * acceleration); + // Do nothing if the controller already exists + if (cont->enabled == 1) + return; - if (t_end > (2. * t_acc)) { - // A trapezoidal speed profile is possible - right_trap.is_triangle = 0; - left_trap.is_triangle = 0; + // Create generators for position and speed manipulation + new_ramp_generator(&cont->speed, 0., 0.); + new_ramp2_generator(&cont->position, 0., &cont->speed); + + // Start control of drive motor + mc_new_controller(motor, + params->encoder, + params->encoder_gain, + params->G0, + params->tau, + params->T, + params->k, + -params->k[0], + params->l0, + &cont->position); - // Compute trapezoid parameters for right motor - right_trap.speed = right_trap.dir * speed / WHEEL_R * 180 / M_PI; - right_trap.state = TRAPEZOID_STATE_ACC; + // Start the generator + start_generator(&cont->position); + start_generator(&cont->speed); - // Compute trapezoid parameters for left motor - left_trap.speed = left_trap.dir * speed / WHEEL_R * 180 / M_PI; - left_trap.state = TRAPEZOID_STATE_ACC; + // Initial state + cont->aut.state = TRAPEZOID_STATE_STOP; + cont->working = 0; + cont->enabled = 1; +} - // This is the distance during which the robot will accelerate - acc_dist = SIGN(distance) * speed * speed / acceleration / 2.0 / WHEEL_R * 180.0 / M_PI; +void tc_delete_controller(uint8_t motor) { + trajectory_controller_t *cont; - // Set accelerations for the trapezoid's first phase and associated callbacks - adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + acc_dist, trapezoid_callback); - add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); - adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val + acc_dist, trapezoid_callback); - add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); - } else { - // A trapezoidal speed profile is not possible with the given acceleration, let's go for a triangle - right_trap.is_triangle = 1; - left_trap.is_triangle = 1; + cont = &controllers[get_motor_index(motor)]; - // Compute triangle parameters for right motor - right_trap.speed = right_trap.dir * sqrt(distance / WHEEL_R * 180 / M_PI * right_trap.acceleration); - right_trap.state = TRAPEZOID_STATE_TRIANGLE; + if (cont->enabled == 1) { + mc_delete_controller(motor); + cont->working = 0; + cont->enabled = 0; + } +} - // Compute triangle parameters for left motor - left_trap.speed = left_trap.dir * sqrt(distance / WHEEL_R * 180 / M_PI * left_trap.acceleration); - left_trap.state = TRAPEZOID_STATE_TRIANGLE; +uint8_t tc_is_working(uint8_t motors) { + uint8_t state = 0, i; - // Set accelerations for the triangle's first phase and associated callbacks - adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + distance / 2.0 / WHEEL_R * 180 / M_PI, trapezoid_callback); - add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); - adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val + distance / 2.0 / WHEEL_R * 180 / M_PI, trapezoid_callback); - add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); + // For each motor in motor, test if the corresponding controller is working + for (i=0; i < 4; i++) { + if ( ((motors & (1<<i)) != 0) && controllers[i].working == 1) + state |= 1 << i; } - LED1_ON(); + return state; } -void tc_turn(float angle, float speed, float acceleration) { - float acc_angle, t_acc, t_end; +void tc_goto(uint8_t motor, float angle, float speed, float acceleration) { + float acc_dist, t_acc, t_end; + trajectory_controller_t *cont; // Verify parameters if (angle == 0 || speed <= 0 || acceleration <= 0) return; + // Get the controller and verifies it is enabled + cont = &controllers[get_motor_index(motor)]; + if (!cont->enabled) + return; + // Compute some common parameters - // For the right motor - right_trap.init_val = get_output_value(&right_wheel); - right_trap.dir = SIGN(angle); - right_trap.angle = right_trap.init_val + angle * STRUCT_B / 2.0 / WHEEL_R; - right_trap.acceleration = right_trap.dir * acceleration * STRUCT_B / 2.0 / WHEEL_R; - // For the left motor - left_trap.init_val = get_output_value(&left_wheel); - left_trap.dir = -right_trap.dir; - left_trap.angle = left_trap.init_val - angle * STRUCT_B / 2.0 / WHEEL_R; - left_trap.acceleration = left_trap.dir * acceleration * STRUCT_B / 2.0 / WHEEL_R; + cont->aut.init_val = get_output_value(&cont->position); + cont->aut.dir = SIGN(angle); + cont->aut.angle = cont->aut.init_val + angle; + cont->aut.acceleration = cont->aut.dir * acceleration; // Is the trapezoidal speed profile posible ? t_acc = speed / acceleration; @@ -222,49 +224,74 @@ void tc_turn(float angle, float speed, float acceleration) { if (t_end > (2. * t_acc)) { // A trapezoidal speed profile is possible - right_trap.is_triangle = 0; - left_trap.is_triangle = 0; + cont->aut.is_triangle = 0; - // Compute trapezoid parameters for right motor - right_trap.speed = right_trap.dir * speed * STRUCT_B / 2.0 / WHEEL_R; - right_trap.state = TRAPEZOID_STATE_ACC; + // Compute trapezoid parameters + cont->aut.speed = cont->aut.dir * speed; + cont->aut.state = TRAPEZOID_STATE_ACC; - // Compute trapezoid parameters for left motor - left_trap.speed = left_trap.dir * speed * STRUCT_B / 2.0 / WHEEL_R; - left_trap.state = TRAPEZOID_STATE_ACC; - - // This is the angle during which the robot will accelerate - acc_angle = SIGN(angle) * speed * speed / acceleration / 2.0 * STRUCT_B / 2.0 / WHEEL_R; + // This is the distance during which the robot will accelerate + acc_dist = cont->aut.dir * speed * speed / acceleration; // Set accelerations for the trapezoid's first phase and associated callbacks - adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + acc_angle, trapezoid_callback); - add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); - adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val - acc_angle, trapezoid_callback); - add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); + adjust_speed(&cont->speed, cont->aut.acceleration); + add_callback(&cont->position, SELECT_THRESHOLD(cont->aut.dir), cont->aut.init_val + acc_dist, trapezoid_callback); + add_callback(&cont->speed, SELECT_THRESHOLD(cont->aut.dir), cont->aut.speed, trapezoid_callback); } else { // A trapezoidal speed profile is not possible with the given acceleration, let's go for a triangle - right_trap.is_triangle = 1; - left_trap.is_triangle = 1; + cont->aut.is_triangle = 1; - // Compute triangle parameters for right motor - right_trap.speed = right_trap.dir * sqrt(angle * STRUCT_B / 2.0 / WHEEL_R * right_trap.acceleration); - right_trap.state = TRAPEZOID_STATE_TRIANGLE; - - // Compute triangle parameters for left motor - left_trap.speed = left_trap.dir * sqrt(- angle * STRUCT_B / 2.0 / WHEEL_R * left_trap.acceleration); - left_trap.state = TRAPEZOID_STATE_TRIANGLE; + // Compute triangle parameters + cont->aut.speed = cont->aut.dir * sqrt(angle * cont->aut.acceleration); + cont->aut.state = TRAPEZOID_STATE_CONST; // Set accelerations for the triangle's first phase and associated callbacks - adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + angle / 2.0 * STRUCT_B / 2.0 / WHEEL_R, trapezoid_callback); - add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); - adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val - angle / 2.0 * STRUCT_B / 2.0 / WHEEL_R, trapezoid_callback); - add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); + adjust_speed(&cont->speed, cont->aut.acceleration); + add_callback(&cont->position, SELECT_THRESHOLD(cont->aut.dir), cont->aut.init_val + angle / 2.0, trapezoid_callback); + add_callback(&cont->speed, SELECT_THRESHOLD(cont->aut.dir), cont->aut.speed, trapezoid_callback); } - LED1_ON(); + cont->working = 1; +} + +void tc_move(tc_robot_t *robot, float distance, float speed, float acceleration) { + float dis_s, spe_s, acc_s; + + // Let's pause the wheel's speed generators to synchronize movement start + pause_generator(&controllers[get_motor_index(robot->left_wheel)].speed); + pause_generator(&controllers[get_motor_index(robot->right_wheel)].speed); + + // Compute parameters + dis_s = distance / robot->wheel_radius * 180.0 / M_PI; + spe_s = speed / robot->wheel_radius * 180.0 / M_PI; + acc_s = acceleration / robot->wheel_radius * 180.0 / M_PI; + + // Planify movements + tc_goto(robot->left_wheel, dis_s, spe_s, acc_s); + tc_goto(robot->right_wheel, dis_s, spe_s, acc_s); + + // Go + start_generator(&controllers[get_motor_index(robot->left_wheel)].speed); + start_generator(&controllers[get_motor_index(robot->right_wheel)].speed); } +void tc_turn(tc_robot_t *robot, float angle, float speed, float acceleration) { + float angle_s, spe_s, acc_s; + + // Let's pause the wheel's speed generators to synchronize movement start + pause_generator(&controllers[get_motor_index(robot->left_wheel)].speed); + pause_generator(&controllers[get_motor_index(robot->right_wheel)].speed); + + // Compute parameters + angle_s = angle * robot->shaft_width / 2.0 / robot->wheel_radius; + spe_s = speed * robot->shaft_width / 2.0 / robot->wheel_radius; + acc_s = acceleration * robot->shaft_width / 2.0 / robot->wheel_radius; + + // Planify movements + tc_goto(robot->left_wheel, -angle_s, spe_s, acc_s); + tc_goto(robot->right_wheel, angle_s, spe_s, acc_s); + + // Go + start_generator(&controllers[get_motor_index(robot->left_wheel)].speed); + start_generator(&controllers[get_motor_index(robot->right_wheel)].speed); +} diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h index 0e494e8..77b73e9 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.h @@ -10,42 +10,76 @@ #ifndef __TRAJECTORY_CONTROLLER_H #define __TRAJECTORY_CONTROLLER_H -// Robot parameters -#define WHEEL_R 0.049245 -#define STRUCT_B 0.259 - #include "motor_controller.h" #include "command_generator.h" #include <math.h> -/* Initialize the trajectory controller +typedef struct { + uint8_t encoder; // Encoder ID to measure motor position from + float encoder_gain; // Gain to convert encoder value unit to reference unit + float G0; // DC motor static gain + float tau; // DC motor time constant + float k[2]; // State control gain + float l; // Reference factoring gain + float l0[2]; // State observer gain + float T; // Sampling period of the controller in seconds +} trajectory_controller_params_t; + +typedef struct { + uint8_t left_wheel; // Left wheel motor ID + uint8_t right_wheel; // Right wheel motor ID + float wheel_radius; // Radius of the wheels + float shaft_width; // Width of the propulsion shaft +} tc_robot_t; + +/* Initialize the trajectory controller system + * + */ +void tc_init(void); + +/* Initialize a new trajectory controller with given parameters + * + * This function will initialize a new trajectory controller and the + * necessary motor controller and generators. + */ +void tc_new_controller(uint8_t motor, trajectory_controller_params_t *params); + +/* Deletes a given trajectory controller * - * This function will initialize the trajectory controller and the - * necessary motor controller. */ -void init_trajectory_controller(void); +void tc_delete_controller(uint8_t motor); -/* Indicates if the last planified action is finished +/* Indicates if the last planified action on 'motors' is finished * - * Returns 1 if the last planified action is finished, 0 if it is not. + * Returns the logical OR of working controllers among the ones specified in motors */ -uint8_t tc_is_finished(void); +uint8_t tc_is_working(uint8_t motors); -/* Move along a line +/* Moves of a given distance + * - distance : distance to move of, can be positive (forward) or negative + * (backward). The units corresponds to the given scaling factor + * during initialization. + * - speed : moving speed (in meters per second) should be positive. + * - acceleration : in meters per second per second, should be positive. + */ +void tc_goto(uint8_t motor, float angle, float speed, float acceleration); + +/* Moves along a line + * - robot : pointer to a structure describing the robot configuration * - distance : distance to move of (in meters), can be positive (forward) * or negative (backward). * - speed : moving speed (in meters per second) should be positive. * - acceleration : in meters per second per second, should be positive. */ -void tc_move(float distance, float speed, float acceleration); - +void tc_move(tc_robot_t *robot, float distance, float speed, float acceleration); -/* Turn around the propulsion shaft center +/* Turns around the propulsion shaft center + * - robot : pointer to a structure describing the robot configuration * - angle : angle to turn of (in degrees), can be positive (CCW) * or negative (CW). * - speed : turning speed (in degrees per second) should be positive. * - acceleration : in degrees per second per second, should be positive. */ -void tc_turn(float angle, float speed, float acceleration); +void tc_turn(tc_robot_t *robot, float angle, float speed, float acceleration); #endif /* __TRAJECTORY_CONTROLLER_H */ hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-31 12:29:23
|
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 08f9457bae8f067a43784a49e4271a7b7c1a8963 (commit) via 20489cf95c9174859dea5fdb9e9e2a65f06ac9ba (commit) via 51a8d6e5e71f3224b5592e4db5f9f174c7b55108 (commit) from f7aa980b1984ec97e06982b24182553a41a30b33 (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 08f9457bae8f067a43784a49e4271a7b7c1a8963 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 14:26:27 2011 +0200 [krobot_viewer] cancel the goto thread on stop commit 20489cf95c9174859dea5fdb9e9e2a65f06ac9ba Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 14:18:49 2011 +0200 [krobot_viewer] clear the trajectory on stop This way the robot won't try to continue it. commit 51a8d6e5e71f3224b5592e4db5f9f174c7b55108 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 14:17:59 2011 +0200 [krobot_viewer] do not fail if we clear the trajectory while moving ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 2834f20..d6ebd28 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -486,7 +486,9 @@ module Board = struct lwt () = wait_done board in (* Remove the point. *) - board.points <- List.tl board.points; + (match board.points with + | _ :: l -> board.points <- l + | [] -> ()); (* Redraw everything without the last point. *) queue_draw board; @@ -587,15 +589,22 @@ lwt () = Board.smooth board; false)); + let thread_go = ref (return ()) in ignore (ui#button_go#event#connect#button_release (fun ev -> if GdkEvent.Button.button ev = 1 then ignore_result ( ui#button_go#misc#set_sensitive false; - lwt () = Board.go board in - ui#button_go#misc#set_sensitive true; - return () + try_lwt + thread_go := Board.go board; + !thread_go + with + | Canceled -> + return () + finally + ui#button_go#misc#set_sensitive true; + return () ); false)); @@ -624,10 +633,13 @@ lwt () = ignore (ui#button_stop#event#connect#button_release (fun ev -> - if GdkEvent.Button.button ev = 1 then + if GdkEvent.Button.button ev = 1 then begin + Board.clear board; + cancel !thread_go; ignore_result ( Krobot_message.send bus (Unix.gettimeofday (), Motor_stop) - ); + ) + end; false)); pick [ hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-31 12:13: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 f7aa980b1984ec97e06982b24182553a41a30b33 (commit) from eab5614a83d28245df080d44ea6b1464a83d2173 (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 f7aa980b1984ec97e06982b24182553a41a30b33 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 14:12:36 2011 +0200 [krobot_viewer] use the corrent wheels axe center ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_config.ml b/info/control2011/src/lib/krobot_config.ml index 05e699d..acb9ff9 100644 --- a/info/control2011/src/lib/krobot_config.ml +++ b/info/control2011/src/lib/krobot_config.ml @@ -12,3 +12,4 @@ let world_width = 3. let robot_size = 0.3 let wheels_diameter = 0.098 let wheels_distance = 0.259 +let wheels_position = 0.045 diff --git a/info/control2011/src/lib/krobot_config.mli b/info/control2011/src/lib/krobot_config.mli index 7876fdd..bf336d5 100644 --- a/info/control2011/src/lib/krobot_config.mli +++ b/info/control2011/src/lib/krobot_config.mli @@ -23,3 +23,7 @@ val wheels_diameter : float val wheels_distance : float (** The distance between the two wheels. *) + +val wheels_position : float + (** The distance between the axe of the wheels and the back of the + robot. *) diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 66e4b73..2834f20 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -363,16 +363,17 @@ module Board = struct (* Draw the robot *) Cairo.translate ctx board.state.x board.state.y; Cairo.rotate ctx board.state.theta; - Cairo.rectangle ctx (-. robot_size /. 2.) (-. robot_size /. 2.) robot_size robot_size; + Cairo.rectangle ctx (-. wheels_position) (-. robot_size /. 2.) robot_size robot_size; set_color ctx White; Cairo.fill ctx; (* Draw an arrow on the robot *) - Cairo.move_to ctx (-. robot_size /. 4.) 0.; - Cairo.line_to ctx (robot_size /. 4.) 0.; - Cairo.line_to ctx 0. (-. robot_size /. 4.); - Cairo.line_to ctx 0. (robot_size /. 4.); - Cairo.line_to ctx (robot_size /. 4.) 0.; + let d = robot_size /. 2. -. wheels_position in + Cairo.move_to ctx (d -. robot_size /. 4.) 0.; + Cairo.line_to ctx (d +. robot_size /. 4.) 0.; + Cairo.line_to ctx d (-. robot_size /. 4.); + Cairo.line_to ctx d (robot_size /. 4.); + Cairo.line_to ctx (d +. robot_size /. 4.) 0.; set_color ctx Black; Cairo.stroke ctx; @@ -605,7 +606,7 @@ lwt () = ignore_result ( Krobot_message.send bus (Unix.gettimeofday (), - Set_odometry(0.2, 1.9, -0.5 *. pi)) + Set_odometry(0.2, 1.9 +. Krobot_config.robot_size /. 2. -. Krobot_config.wheels_position, -0.5 *. pi)) ); false)); @@ -616,7 +617,7 @@ lwt () = ignore_result ( Krobot_message.send bus (Unix.gettimeofday (), - Set_odometry(Krobot_config.world_width -. 0.2, 1.9, -0.5 *. pi)) + Set_odometry(Krobot_config.world_width -. 0.2, 1.9 +. Krobot_config.robot_size /. 2. -. Krobot_config.wheels_position, -0.5 *. pi)) ); false)); hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-31 00:01:01
|
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 eab5614a83d28245df080d44ea6b1464a83d2173 (commit) from 79295c819ab4b49f0b1397d1b5f7ff12f755a410 (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 eab5614a83d28245df080d44ea6b1464a83d2173 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 02:00:28 2011 +0200 [krobot_viewer] show the robot current position ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 0cc0e56..66e4b73 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -516,6 +516,9 @@ module Board = struct let state = { x; y; theta = angle; } in if state <> board.state then begin board.state <- state; + board.ui#entry_x#set_text (string_of_float x); + board.ui#entry_y#set_text (string_of_float y); + board.ui#entry_theta#set_text (string_of_float theta); queue_draw board end | Motor_status true -> diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index f63e673..df63329 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -269,7 +269,7 @@ <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">5</property> + <property name="n_rows">8</property> <property name="n_columns">2</property> <child> <widget class="GtkSpinButton" id="moving_speed"> @@ -283,8 +283,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">4</property> + <property name="bottom_attach">5</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -300,8 +300,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">5</property> + <property name="bottom_attach">6</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -317,8 +317,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">6</property> + <property name="bottom_attach">7</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -334,8 +334,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">7</property> + <property name="bottom_attach">8</property> <property name="y_options">GTK_FILL</property> </packing> </child> @@ -365,8 +365,8 @@ </child> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> @@ -397,8 +397,8 @@ </child> </widget> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</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> @@ -429,8 +429,8 @@ </child> </widget> <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</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> @@ -461,8 +461,8 @@ </child> </widget> <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</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> @@ -506,6 +506,138 @@ <property name="right_attach">2</property> </packing> </child> + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">x: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment6"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox9"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="label" translatable="yes">y: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment7"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox10"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="label" translatable="yes">theta: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment8"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="entry_x"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</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="GtkEntry" id="entry_y"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + </widget> + <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> + </packing> + </child> + <child> + <widget class="GtkEntry" id="entry_theta"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="invisible_char">•</property> + </widget> + <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> + </packing> + </child> </widget> <packing> <property name="expand">False</property> hooks/post-receive -- krobot |
From: Nicolas D. <Ba...@us...> - 2011-03-30 22:50: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 79295c819ab4b49f0b1397d1b5f7ff12f755a410 (commit) from 42761a095b9fe25b724642b4252134dc57aae150 (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 79295c819ab4b49f0b1397d1b5f7ff12f755a410 Author: Nicolas Dandrimont <Nic...@cr...> Date: Thu Mar 31 00:49:01 2011 +0200 [krobot_viewer] Wait a little longer before checking for status We could have been checking for status before the system got a new value. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index ebb1969..0cc0e56 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -453,6 +453,7 @@ module Board = struct let wait_done board = lwt () = Lwt_log.info "waiting for the robot to stop moving" in + lwt () = Lwt_unix.sleep 0.3 in lwt () = while_lwt board.moving do Lwt_unix.sleep 0.2 hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 22:06:03
|
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 42761a095b9fe25b724642b4252134dc57aae150 (commit) from 8da6a52789fe20e2768f07d5e0fa4e3ea623f90e (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 42761a095b9fe25b724642b4252134dc57aae150 Author: Jérémie Dimino <je...@di...> Date: Thu Mar 31 00:05:32 2011 +0200 [krobot_dump] display better timestamps ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_dump.ml b/info/control2011/src/tools/krobot_dump.ml index c8c9f39..2aeca8a 100644 --- a/info/control2011/src/tools/krobot_dump.ml +++ b/info/control2011/src/tools/krobot_dump.ml @@ -24,6 +24,33 @@ let usage = "\ Usage: krobot-dump [options] options are:" +let date_string time = + let tm = Unix.localtime time in + let month_string = + match tm.Unix.tm_mon with + | 0 -> "Jan" + | 1 -> "Feb" + | 2 -> "Mar" + | 3 -> "Apr" + | 4 -> "May" + | 5 -> "Jun" + | 6 -> "Jul" + | 7 -> "Aug" + | 8 -> "Sep" + | 9 -> "Oct" + | 10 -> "Nov" + | 11 -> "Dec" + | _ -> Printf.ksprintf failwith "Lwt_log.ascdate: invalid month, %d" tm.Unix.tm_mon + in + Printf.sprintf + "%s %2d %02d:%02d:%02d.%s" + month_string + tm.Unix.tm_mday + tm.Unix.tm_hour + tm.Unix.tm_min + tm.Unix.tm_sec + (String.sub (Printf.sprintf "%.4f" (fst (modf time))) 2 4) + lwt () = Arg.parse options ignore usage; @@ -33,16 +60,16 @@ lwt () = (E.map_s (fun (timestamp, frame) -> let msg = Krobot_message.decode frame in - lwt () = Lwt_io.printf "%f" timestamp in + lwt () = Lwt_io.print (date_string timestamp)in lwt () = if !decoded then - Lwt_io.printf ", %s" (Krobot_message.to_string msg) + Lwt_io.printf ": %s" (Krobot_message.to_string msg) else return () in lwt () = if !raw then - Lwt_io.printf ", %s" (Krobot_can.string_of_frame frame) + Lwt_io.printf ": %s" (Krobot_can.string_of_frame frame) else return () in hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 21:35:32
|
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 8da6a52789fe20e2768f07d5e0fa4e3ea623f90e (commit) from 2e1b70ec4a201c20fe5cb1ee3aa0274c90f880be (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 8da6a52789fe20e2768f07d5e0fa4e3ea623f90e Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 23:35:00 2011 +0200 [krobot_viewer] add timestamps to logs ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 30dcaf2..ebb1969 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -535,6 +535,13 @@ end +-----------------------------------------------------------------+ *) lwt () = + Lwt_log.default := + Lwt_log.channel + ~template:"$(date).$(milliseconds) $(name): $(section): $(message)" + ~close_mode:`Keep + ~channel:Lwt_io.stderr + (); + lwt bus = Krobot_bus.get () in ignore (GMain.init ()); Lwt_glib.install (); hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 21:28:39
|
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 2e1b70ec4a201c20fe5cb1ee3aa0274c90f880be (commit) from 32438eb8c7678e35dfb26bde88d77c0a73c63596 (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 2e1b70ec4a201c20fe5cb1ee3aa0274c90f880be Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 23:28:10 2011 +0200 [krobot_viewer] more logs ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index a3d7a79..30dcaf2 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -451,12 +451,14 @@ module Board = struct board.points <- List.map (fun i -> points.(i)) result; queue_draw board - let rec wait_done board = - lwt () = Lwt_unix.sleep 0.2 in - if board.moving then - wait_done board - else - return () + let wait_done board = + lwt () = Lwt_log.info "waiting for the robot to stop moving" in + lwt () = + while_lwt board.moving do + Lwt_unix.sleep 0.2 + done + in + Lwt_log.info "trajectory done" let go board = let rec loop () = @@ -464,6 +466,7 @@ module Board = struct | (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, @@ -473,6 +476,7 @@ module Board = struct (* 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, hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 21:05:34
|
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 32438eb8c7678e35dfb26bde88d77c0a73c63596 (commit) from e7c92edc9c0d24e0ad519fc88ab61c355109b9cc (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 32438eb8c7678e35dfb26bde88d77c0a73c63596 Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 23:05:02 2011 +0200 [info] better errors on invalid frame ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index 08e4402..fe1dc3c 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -193,7 +193,18 @@ let encode = function | Decoding | +-----------------------------------------------------------------+ *) +exception Invalid_frame of Krobot_can.frame + +let () = + Printexc.register_printer + (function + | Invalid_frame frame -> + Some(Printf.sprintf "Invalid_frame%s" (Krobot_can.string_of_frame frame)) + | _ -> + None) + let decode frame = + try if frame.remote then match frame.identifier with | 103 -> @@ -242,6 +253,8 @@ let decode frame = Motor_stop | _ -> Unknown frame + with Invalid_argument _ -> + raise (Invalid_frame frame) (* +-----------------------------------------------------------------+ | Sending/receiving messages | diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index 298572d..5c80ce7 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -54,6 +54,9 @@ type t = val to_string : t -> string (** Returns the string representation of the given message. *) +exception Invalid_frame of Krobot_can.frame + (** Exception raised when an invalid frame is encountered. *) + val encode : t -> Krobot_can.frame (** Encode the given message into a CAN frame. *) hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 20:46:04
|
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 e7c92edc9c0d24e0ad519fc88ab61c355109b9cc (commit) via 3762e030dcc2ee5fcc4bcefbbac84dcfcc8381c4 (commit) via 8cbe2604c014064abcab2c9a65b5942b7e4ae3b8 (commit) via 92a5e4be9ce33bfce7a33372d479545465d9815c (commit) from 09a86b1ab86b522c506e66519d27257f77a7d02b (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 e7c92edc9c0d24e0ad519fc88ab61c355109b9cc Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 22:45:29 2011 +0200 [krobot_viewer] fix the slowing problem commit 3762e030dcc2ee5fcc4bcefbbac84dcfcc8381c4 Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 22:41:49 2011 +0200 [info] fix frame id for motor_stop and set_odometry commit 8cbe2604c014064abcab2c9a65b5942b7e4ae3b8 Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 22:08:41 2011 +0200 [krobot_viewer] no threads needed commit 92a5e4be9ce33bfce7a33372d479545465d9815c Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 21:59:57 2011 +0200 [krobot_viewer] wait longer before passing to the next command ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 450a1bc..1292204 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -135,7 +135,7 @@ Executable "krobot-viewer" Install$: flag(gtk) CompiledObject: best MainIs: krobot_viewer.ml - BuildDepends: krobot, lwt.syntax, cairo.lablgtk2, lwt.glib, threads, lablgtk2.glade + BuildDepends: krobot, lwt.syntax, cairo.lablgtk2, lwt.glib, lablgtk2.glade Executable "krobot-simulator" Path: src/tools diff --git a/info/control2011/_tags b/info/control2011/_tags index 20baf17..2f57243 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: 255c5daac028047b8fd81335cc7a3a1d) +# DO NOT EDIT (digest: 9d40de9cfde679815e27aa44dbe6939f) # Library krobot-interfaces "src/interfaces": include "src/interfaces/krobot-interfaces.cmxs": use_krobot-interfaces @@ -56,7 +56,6 @@ # Executable krobot-viewer <src/tools/krobot_viewer.{native,byte}>: use_krobot <src/tools/krobot_viewer.{native,byte}>: use_krobot-interfaces -<src/tools/krobot_viewer.{native,byte}>: pkg_threads <src/tools/krobot_viewer.{native,byte}>: pkg_obus <src/tools/krobot_viewer.{native,byte}>: pkg_lwt.unix <src/tools/krobot_viewer.{native,byte}>: pkg_lwt.syntax diff --git a/info/control2011/myocamlbuild.ml b/info/control2011/myocamlbuild.ml index 58c15ed..08cc900 100644 --- a/info/control2011/myocamlbuild.ml +++ b/info/control2011/myocamlbuild.ml @@ -1,7 +1,7 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 7b180d572761c507057af7fdf11b0222) *) +(* DO NOT EDIT (digest: 570b31c8f48685aca9662d28e560f425) *) module OASISGettext = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISGettext.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" let ns_ str = str @@ -24,7 +24,7 @@ module OASISGettext = struct end module OASISExpr = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExpr.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" @@ -115,7 +115,7 @@ end module BaseEnvLight = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnvLight.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" module MapString = Map.Make(String) @@ -212,7 +212,7 @@ end module MyOCamlbuildFindlib = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" +# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" (** OCamlbuild extension, copied from * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild @@ -320,7 +320,7 @@ module MyOCamlbuildFindlib = struct end module MyOCamlbuildBase = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" +# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" (** Base functions for writing myocamlbuild.ml @author Sylvain Le Gall @@ -335,7 +335,7 @@ module MyOCamlbuildBase = struct type name = string type tag = string -# 55 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" +# 55 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" type t = { diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 3f22dfe..48d05a0 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,14 +1,14 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: e7a994aa7e43385f1fc743e7a7663a49) *) +(* DO NOT EDIT (digest: 60affd9777295d3612011711e6241ee4) *) (* Regenerated by OASIS v0.2.0 Visit http://oasis.forge.ocamlcore.org for more information and documentation about functions used in this file. *) module OASISGettext = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISGettext.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" let ns_ str = str @@ -31,7 +31,7 @@ module OASISGettext = struct end module OASISContext = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISContext.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISContext.ml" open OASISGettext @@ -90,7 +90,7 @@ module OASISContext = struct end module OASISUtils = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISUtils.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISUtils.ml" module MapString = Map.Make(String) @@ -242,7 +242,7 @@ module OASISUtils = struct end module PropList = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/PropList.ml" +# 21 "/home/dim/sources/oasis/src/oasis/PropList.ml" open OASISGettext @@ -277,7 +277,7 @@ module PropList = struct let clear t = Hashtbl.clear t -# 59 "/home/krobot/ocaml-stuff/oasis/src/oasis/PropList.ml" +# 59 "/home/dim/sources/oasis/src/oasis/PropList.ml" end module Schema = @@ -518,7 +518,7 @@ module PropList = struct end module OASISMessage = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISMessage.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISMessage.ml" open OASISGettext @@ -567,7 +567,7 @@ module OASISMessage = struct end module OASISVersion = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISVersion.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISVersion.ml" open OASISGettext @@ -751,7 +751,7 @@ module OASISVersion = struct end module OASISLicense = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISLicense.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISLicense.ml" (** License for _oasis fields @author Sylvain Le Gall @@ -784,7 +784,7 @@ module OASISLicense = struct end module OASISExpr = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExpr.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" @@ -874,7 +874,7 @@ module OASISExpr = struct end module OASISTypes = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTypes.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" @@ -951,7 +951,7 @@ module OASISTypes = struct type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list -# 102 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTypes.ml" +# 102 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" type 'a conditional = 'a OASISExpr.choices @@ -1105,7 +1105,7 @@ module OASISTypes = struct end module OASISUnixPath = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISUnixPath.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISUnixPath.ml" type unix_filename = string type unix_dirname = string @@ -1184,7 +1184,7 @@ module OASISUnixPath = struct end module OASISSection = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISSection.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISSection.ml" (** Manipulate section @author Sylvain Le Gall @@ -1246,12 +1246,12 @@ module OASISSection = struct end module OASISBuildSection = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISBuildSection.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISBuildSection.ml" end module OASISExecutable = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExecutable.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISExecutable.ml" open OASISTypes @@ -1282,7 +1282,7 @@ module OASISExecutable = struct end module OASISLibrary = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISLibrary.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISLibrary.ml" open OASISTypes open OASISUtils @@ -1573,33 +1573,33 @@ module OASISLibrary = struct end module OASISFlag = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISFlag.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISFlag.ml" end module OASISPackage = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISPackage.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISPackage.ml" end module OASISSourceRepository = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISSourceRepository.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISSourceRepository.ml" end module OASISTest = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTest.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISTest.ml" end module OASISDocument = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISDocument.ml" +# 21 "/home/dim/sources/oasis/src/oasis/OASISDocument.ml" end module BaseEnvLight = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnvLight.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" module MapString = Map.Make(String) @@ -1696,7 +1696,7 @@ end module BaseContext = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseContext.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseContext.ml" open OASISContext @@ -1707,7 +1707,7 @@ module BaseContext = struct end module BaseMessage = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseMessage.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseMessage.ml" (** Message to user, overrid for Base @author Sylvain Le Gall @@ -1728,7 +1728,7 @@ module BaseMessage = struct end module BaseFilePath = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFilePath.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseFilePath.ml" open Filename @@ -1760,7 +1760,7 @@ module BaseFilePath = struct end module BaseEnv = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnv.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseEnv.ml" open OASISTypes open OASISGettext @@ -2219,7 +2219,7 @@ module BaseEnv = struct end module BaseExec = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseExec.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseExec.ml" open OASISGettext open OASISUtils @@ -2279,7 +2279,7 @@ module BaseExec = struct end module BaseFileUtil = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFileUtil.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseFileUtil.ml" open OASISGettext @@ -2457,7 +2457,7 @@ module BaseFileUtil = struct end module BaseArgExt = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseArgExt.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseArgExt.ml" open OASISUtils open OASISGettext @@ -2485,7 +2485,7 @@ module BaseArgExt = struct end module BaseCheck = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseCheck.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseCheck.ml" open BaseEnv open BaseMessage @@ -2611,7 +2611,7 @@ module BaseCheck = struct end module BaseOCamlcConfig = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseOCamlcConfig.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseOCamlcConfig.ml" open BaseEnv @@ -2713,7 +2713,7 @@ module BaseOCamlcConfig = struct end module BaseStandardVar = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseStandardVar.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseStandardVar.ml" open OASISGettext @@ -2973,7 +2973,7 @@ module BaseStandardVar = struct end module BaseFileAB = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFileAB.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseFileAB.ml" open BaseEnv open OASISGettext @@ -3021,7 +3021,7 @@ module BaseFileAB = struct end module BaseLog = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseLog.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseLog.ml" open OASISUtils @@ -3140,7 +3140,7 @@ module BaseLog = struct end module BaseBuilt = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseBuilt.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseBuilt.ml" open OASISTypes open OASISGettext @@ -3287,7 +3287,7 @@ module BaseBuilt = struct end module BaseCustom = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseCustom.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseCustom.ml" open BaseEnv open BaseMessage @@ -3337,7 +3337,7 @@ module BaseCustom = struct end module BaseDynVar = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDynVar.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseDynVar.ml" open OASISTypes @@ -3381,7 +3381,7 @@ module BaseDynVar = struct end module BaseTest = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseTest.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseTest.ml" open BaseEnv open BaseMessage @@ -3463,7 +3463,7 @@ module BaseTest = struct end module BaseDoc = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDoc.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseDoc.ml" open BaseEnv open BaseMessage @@ -3493,7 +3493,7 @@ module BaseDoc = struct end module BaseSetup = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseSetup.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseSetup.ml" open BaseEnv open BaseMessage @@ -3911,7 +3911,7 @@ module BaseSetup = struct end module BaseDev = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDev.ml" +# 21 "/home/dim/sources/oasis/src/base/BaseDev.ml" @@ -3969,7 +3969,7 @@ end module InternalConfigurePlugin = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/internal/InternalConfigurePlugin.ml" +# 21 "/home/dim/sources/oasis/src/plugins/internal/InternalConfigurePlugin.ml" (** Configure using internal scheme @author Sylvain Le Gall @@ -4185,7 +4185,7 @@ module InternalConfigurePlugin = struct end module InternalInstallPlugin = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/internal/InternalInstallPlugin.ml" +# 21 "/home/dim/sources/oasis/src/plugins/internal/InternalInstallPlugin.ml" (** Install using internal scheme @author Sylvain Le Gall @@ -4584,7 +4584,7 @@ end module OCamlbuildCommon = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildCommon.ml" +# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildCommon.ml" (** Functions common to OCamlbuild build and doc plugin *) @@ -4684,7 +4684,7 @@ module OCamlbuildCommon = struct end module OCamlbuildPlugin = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" +# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" (** Build using ocamlbuild @author Sylvain Le Gall @@ -4928,7 +4928,7 @@ module OCamlbuildPlugin = struct end module OCamlbuildDocPlugin = struct -# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" +# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" (* Create documentation using ocamlbuild .odocl files @author Sylvain Le Gall @@ -5307,7 +5307,6 @@ let setup_t = FindlibPackage ("lwt.syntax", None); FindlibPackage ("cairo.lablgtk2", None); FindlibPackage ("lwt.glib", None); - FindlibPackage ("threads", None); FindlibPackage ("lablgtk2.glade", None) ]; bs_build_tools = [ExternalTool "ocamlbuild"]; diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index a68a8b3..08e4402 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -139,17 +139,6 @@ let encode = function ~remote:false ~format:F29bits ~data - | Set_odometry(x, y, theta) -> - let data = String.create 6 in - put_sint16 data 0 (truncate (x *. 1000.)); - put_sint16 data 2 (truncate (y *. 1000.)); - put_sint16 data 4 (truncate (theta /. pi *. 18000.)); - frame - ~identifier:105 - ~kind:Data - ~remote:false - ~format:F29bits - ~data | Motor_move(dist, speed, acc) -> let data = String.create 8 in put_sint32 data 0 (truncate (dist *. 1000.)); @@ -172,13 +161,24 @@ let encode = function ~remote:false ~format:F29bits ~data - | Motor_stop -> + | Set_odometry(x, y, theta) -> + let data = String.create 6 in + put_sint16 data 0 (truncate (x *. 1000.)); + put_sint16 data 2 (truncate (y *. 1000.)); + put_sint16 data 4 (truncate (theta /. pi *. 18000.)); frame ~identifier:203 ~kind:Data ~remote:false ~format:F29bits - ~data:"" + ~data + | Motor_stop -> + frame + ~identifier:204 + ~kind:Data + ~remote:false + ~format:F29bits + ~data:"\x01" | Req_motor_status -> frame ~identifier:103 @@ -223,11 +223,6 @@ let decode frame = (float (get_sint16 frame.data 0) /. 1000., float (get_sint16 frame.data 2) /. 1000., float (get_sint16 frame.data 4) *. pi /. 18000.) - | 105 -> - Set_odometry - (float (get_sint16 frame.data 0) /. 1000., - float (get_sint16 frame.data 2) /. 1000., - float (get_sint16 frame.data 4) *. pi /. 18000.) | 201 -> Motor_move (float (get_sint32 frame.data 0) /. 1000., @@ -239,6 +234,11 @@ let decode frame = float (get_uint16 frame.data 4) *. pi /. 18000., float (get_uint16 frame.data 6) *. pi /. 18000.) | 203 -> + Set_odometry + (float (get_sint16 frame.data 0) /. 1000., + float (get_sint16 frame.data 2) /. 1000., + float (get_sint16 frame.data 4) *. pi /. 18000.) + | 204 -> Motor_stop | _ -> Unknown frame @@ -249,33 +249,3 @@ let decode frame = let send bus (timestamp, msg) = Krobot_can.send bus (timestamp, encode msg) let recv bus = E.map (fun (timestamp, frame) -> (timestamp, decode frame)) (Krobot_can.recv bus) - -(* +-----------------------------------------------------------------+ - | Calls | - +-----------------------------------------------------------------+ *) - -let wait_timeout = 0.1 - -let send_and_recv bus req f = - let t = - E.next - (E.fmap - (fun (ts, frame) -> - match f frame with - | Some x -> Some(`Value(ts, x)) - | None -> None) - (recv bus)) - in - let rec loop () = - lwt () = send bus (Unix.gettimeofday (), req) in - match_lwt choose [t; Lwt_unix.sleep wait_timeout >|= fun () -> `Timeout] with - | `Value x -> return x - | `Timeout -> loop () - in - loop () - -let motor_status bus = - send_and_recv bus Req_motor_status - (function - | Motor_status status -> Some status - | _ -> None) diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index d1cb523..298572d 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -66,9 +66,3 @@ val send : Krobot_bus.t -> (float * t) -> unit Lwt.t val recv : Krobot_bus.t -> (float * t) React.event (** [recv bus] is the event which receive messages. *) - -(** {6 Calls} *) - -(** The following functions send a request and wait for the result. *) - -val motor_status : Krobot_bus.t -> (float * bool) Lwt.t diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 2665d0f..a3d7a79 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -192,6 +192,7 @@ module Board = struct mutable state : state; mutable points : (float * float) list; mutable event : unit event; + mutable moving : bool; } type color = @@ -451,9 +452,8 @@ module Board = struct queue_draw board let rec wait_done board = - lwt () = Lwt_unix.sleep 0.05 in - lwt ts, moving = Krobot_message.motor_status board.bus in - if moving then + lwt () = Lwt_unix.sleep 0.2 in + if board.moving then wait_done board else return () @@ -498,6 +498,7 @@ module Board = struct state = { x = 0.2; y = 1.9; theta = -0.5 *. pi }; points = []; event = E.never; + moving = false; } in (* Move the robot on the board when we receive odometry informations. *) @@ -513,8 +514,10 @@ module Board = struct 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" | _ -> ()) @@ -611,8 +614,11 @@ lwt () = ); false)); - (* Ask for the status of the motor in order to display the correct - status initially. *) - lwt () = Krobot_message.send bus (Unix.gettimeofday (), Req_motor_status) in - - waiter + pick [ + waiter; + (* Sends motor status request continously. *) + while_lwt true do + lwt () = Krobot_message.send bus (Unix.gettimeofday (), Req_motor_status) in + Lwt_unix.sleep 0.2 + done; + ] hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-30 19:52:53
|
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 09a86b1ab86b522c506e66519d27257f77a7d02b (commit) via 142d0e7c7e61cdb9b001c7485f52ff1c1abb3456 (commit) via 611e5acb6ef9d0220194bc51318667b8caebd01a (commit) from 6745d46fc81891fd948daf587b9397fd8cb5dee4 (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 09a86b1ab86b522c506e66519d27257f77a7d02b Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 21:49:10 2011 +0200 [info] fix the simulation Use the real time delta instead of the wanted one. commit 142d0e7c7e61cdb9b001c7485f52ff1c1abb3456 Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 21:36:30 2011 +0200 [info] add messages for stopping the motors commit 611e5acb6ef9d0220194bc51318667b8caebd01a Author: Jérémie Dimino <je...@di...> Date: Wed Mar 30 21:03:58 2011 +0200 [info] implement the set-odometry CAN packet ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index aff2580..a68a8b3 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -25,7 +25,9 @@ type t = | Motor_status of bool | Motor_move of float * float * float | Motor_turn of float * float * float + | Motor_stop | Odometry of float * float * float + | Set_odometry of float * float * float | Req_motor_status | Unknown of frame @@ -63,10 +65,16 @@ let to_string = function sprintf "Motor_turn(%f, %f, %f)" angle speed acc + | Motor_stop -> + "Motor_stop" | Odometry(x, y, theta) -> sprintf "Odometry(%f, %f, %f)" x y theta + | Set_odometry(x, y, theta) -> + sprintf + "Set_odometry(%f, %f, %f)" + x y theta | Req_motor_status -> "Req_motor_status" | Unknown frame -> @@ -131,6 +139,17 @@ let encode = function ~remote:false ~format:F29bits ~data + | Set_odometry(x, y, theta) -> + let data = String.create 6 in + put_sint16 data 0 (truncate (x *. 1000.)); + put_sint16 data 2 (truncate (y *. 1000.)); + put_sint16 data 4 (truncate (theta /. pi *. 18000.)); + frame + ~identifier:105 + ~kind:Data + ~remote:false + ~format:F29bits + ~data | Motor_move(dist, speed, acc) -> let data = String.create 8 in put_sint32 data 0 (truncate (dist *. 1000.)); @@ -153,6 +172,13 @@ let encode = function ~remote:false ~format:F29bits ~data + | Motor_stop -> + frame + ~identifier:203 + ~kind:Data + ~remote:false + ~format:F29bits + ~data:"" | Req_motor_status -> frame ~identifier:103 @@ -197,6 +223,11 @@ let decode frame = (float (get_sint16 frame.data 0) /. 1000., float (get_sint16 frame.data 2) /. 1000., float (get_sint16 frame.data 4) *. pi /. 18000.) + | 105 -> + Set_odometry + (float (get_sint16 frame.data 0) /. 1000., + float (get_sint16 frame.data 2) /. 1000., + float (get_sint16 frame.data 4) *. pi /. 18000.) | 201 -> Motor_move (float (get_sint32 frame.data 0) /. 1000., @@ -207,6 +238,8 @@ let decode frame = (float (get_sint32 frame.data 0) *. pi /. 18000., float (get_uint16 frame.data 4) *. pi /. 18000., float (get_uint16 frame.data 6) *. pi /. 18000.) + | 203 -> + Motor_stop | _ -> Unknown frame diff --git a/info/control2011/src/lib/krobot_message.mli b/info/control2011/src/lib/krobot_message.mli index e48cc4c..d1cb523 100644 --- a/info/control2011/src/lib/krobot_message.mli +++ b/info/control2011/src/lib/krobot_message.mli @@ -36,9 +36,14 @@ type t = - [speed] is in rad/s - [acceleration] is in rad/s^2 *) + | Motor_stop + (** Stops the motors. *) | Odometry of float * float * float (** [Odometry(x, y, theta)] the position of the robot on the table. *) + | Set_odometry of float * float * float + (** [set_odometry(x, y, theta)] sets the parameters of the + odometry to the given ones. *) | Req_motor_status (** Request the status of the motors. *) diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index 806c364..beaa8ec 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -72,7 +72,7 @@ type simulator = { | Simulation | +-----------------------------------------------------------------+ *) -let sim_step = 0.01 +let sim_step = 1e-3 let velocities sim = match sim.command with @@ -221,14 +221,22 @@ lwt () = lwt () = Lwt_log.info_f "received: turn(%f, %f, %f)" angle speed acc in turn sim angle speed acc; return () + | Motor_stop -> + sim.command <- Idle; + return () | Req_motor_status -> Krobot_message.send bus (Unix.gettimeofday (), Motor_status(sim.command <> Idle)) + | Set_odometry(x, y, theta) -> + sim.state <- { x; y; theta }; + return () | _ -> return ()) (Krobot_message.recv bus)); while_lwt true do - sim.time <- Unix.gettimeofday (); + let time = Unix.gettimeofday () in + let delta = time -. sim.time in + sim.time <- time; (* Put the robot into idle if the last command is terminated. *) if sim.time > sim.command_end then sim.command <- Idle; @@ -243,13 +251,13 @@ lwt () = and dy = u1 *. (sin sim.state.theta) and dtheta = u2 in sim.state <- { - x = sim.state.x +. dx *. sim_step; - y = sim.state.y +. dy *. sim_step; - theta = math_mod_float (sim.state.theta +. dtheta *. sim_step) (2. *. pi); + x = sim.state.x +. dx *. delta; + y = sim.state.y +. dy *. delta; + theta = math_mod_float (sim.state.theta +. dtheta *. delta) (2. *. pi); }; sim.internal_state <- { - theta_l = sim.internal_state.theta_l +. sim_step *. (u1 *. 4. +. u2 *. wheels_distance) /. (2. *. wheels_diameter); - theta_r = sim.internal_state.theta_r +. sim_step *. (u1 *. 4. -. u2 *. wheels_distance) /. (2. *. wheels_diameter); + theta_l = sim.internal_state.theta_l +. delta *. (u1 *. 4. +. u2 *. wheels_distance) /. (2. *. wheels_diameter); + theta_r = sim.internal_state.theta_r +. delta *. (u1 *. 4. -. u2 *. wheels_distance) /. (2. *. wheels_diameter); }; Lwt_unix.sleep sim_step diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index fa853cd..2665d0f 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -38,6 +38,8 @@ let utf8 code = end else invalid_arg "utf8" +let pi = 4. *. atan 1. + let math_mod_float a b = let b2 = b /. 2. in let modf = mod_float a b in @@ -211,8 +213,6 @@ module Board = struct in Cairo.set_source_rgb ctx (r /. 255.) (g /. 255.) (b /. 255.) - let pi = 4. *. atan 1. - let optimal_size width height = if width /. height >= (world_width +. 0.204) /. (world_height +. 0.204) then ((world_width +. 0.204) /. (world_height +. 0.204) *. height, height) @@ -580,6 +580,37 @@ lwt () = ); false)); + ignore + (ui#button_start_red#event#connect#button_release + (fun ev -> + if GdkEvent.Button.button ev = 1 then + ignore_result ( + Krobot_message.send bus + (Unix.gettimeofday (), + Set_odometry(0.2, 1.9, -0.5 *. pi)) + ); + false)); + + ignore + (ui#button_start_blue#event#connect#button_release + (fun ev -> + if GdkEvent.Button.button ev = 1 then + ignore_result ( + Krobot_message.send bus + (Unix.gettimeofday (), + Set_odometry(Krobot_config.world_width -. 0.2, 1.9, -0.5 *. pi)) + ); + false)); + + ignore + (ui#button_stop#event#connect#button_release + (fun ev -> + if GdkEvent.Button.button ev = 1 then + ignore_result ( + Krobot_message.send bus (Unix.gettimeofday (), Motor_stop) + ); + false)); + (* Ask for the status of the motor in order to display the correct status initially. *) lwt () = Krobot_message.send bus (Unix.gettimeofday (), Req_motor_status) in diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index 19227fb..f63e673 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -255,6 +255,18 @@ </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="expand">False</property> + <property name="position">5</property> + </packing> + </child> + <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> <property name="n_rows">5</property> @@ -497,7 +509,31 @@ </widget> <packing> <property name="expand">False</property> - <property name="position">5</property> + <property name="position">6</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="expand">False</property> + <property name="position">7</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="expand">False</property> + <property name="position">8</property> </packing> </child> <child> @@ -509,7 +545,7 @@ </child> </widget> <packing> - <property name="position">6</property> + <property name="position">9</property> </packing> </child> </widget> hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2011-03-30 13:52:47
|
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 6745d46fc81891fd948daf587b9397fd8cb5dee4 (commit) via bc4e2c2e79146ce8fa9f83fac2e392f1e19d1f89 (commit) from 4c596ea2f6a485e48aa77c844d9f0e3e6fa0eb98 (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 6745d46fc81891fd948daf587b9397fd8cb5dee4 Author: Xavier Lagorce <Xav...@cr...> Date: Wed Mar 30 15:52:02 2011 +0200 [Controller_Motor_STM32] Corrected parameters computation for speed profiles commit bc4e2c2e79146ce8fa9f83fac2e392f1e19d1f89 Author: Xavier Lagorce <Xav...@cr...> Date: Wed Mar 30 15:43:03 2011 +0200 [Controller_Motor_STM32] Do not use explicit brake when command is zero Using explicit brake changes the command configuration of the bridge and after this, inputting a non zero command doesn't changed back the configuration to a proper state. A command of zero should have the same behavior as explicit braking. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor.c index 3aefcbf..16bec21 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor.c @@ -175,11 +175,6 @@ void motorSetSpeed(uint8_t motor, int32_t speed) { uint8_t ind = 0; - if (speed == 0) { - motorStop(motor, MOTOR_BRAKE); - return; - } - if (speed >= MAX_PWM) { speed = MAX_PWM; ind = 1; @@ -191,7 +186,7 @@ void motorSetSpeed(uint8_t motor, int32_t speed) { } if (motor & MOTOR1) { - if(speed > 0) { + if(speed >= 0) { if (currentSpeedSign[0] != 1) { currentSpeedSign[0] = 1; stm32_gpioPinWrite(((struct stm32_gpio *)GPIOC_BASE), BV(4), 1); @@ -220,7 +215,7 @@ void motorSetSpeed(uint8_t motor, int32_t speed) { } } if (motor & MOTOR2) { - if(speed > 0) { + if(speed >= 0) { if (currentSpeedSign[1] != 1) { currentSpeedSign[1] = 1; stm32_gpioPinWrite(((struct stm32_gpio *)GPIOB_BASE), BV(1), 1); @@ -249,7 +244,7 @@ void motorSetSpeed(uint8_t motor, int32_t speed) { } } if (motor & MOTOR3) { - if(speed > 0) { + if(speed >= 0) { if (currentSpeedSign[2] != 1) { currentSpeedSign[2] = 1; stm32_gpioPinWrite(((struct stm32_gpio *)GPIOC_BASE), BV(10), 1); @@ -278,7 +273,7 @@ void motorSetSpeed(uint8_t motor, int32_t speed) { } } if (motor & MOTOR4) { - if(speed > 0) { + if(speed >= 0) { if (currentSpeedSign[3] != 1) { currentSpeedSign[3] = 1; stm32_gpioPinWrite(((struct stm32_gpio *)GPIOB_BASE), BV(5), 1); diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c index f09051b..407af94 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/trajectory_controller.c @@ -122,7 +122,7 @@ uint8_t tc_is_finished(void) { if (right_trap.state == TRAPEZOID_STATE_STOP && left_trap.state == TRAPEZOID_STATE_STOP) return 1; - // No running process, last planified action should be finished + // One automaton is running, last planified action should be in progress return 0; } @@ -147,7 +147,7 @@ void tc_move(float distance, float speed, float acceleration) { // Is the trapezoidal speed profile posible ? t_acc = speed / acceleration; - t_end = (speed * speed + distance * acceleration) / (speed * acceleration); + t_end = (speed * speed + fabsf(distance) * acceleration) / (speed * acceleration); if (t_end > (2. * t_acc)) { // A trapezoidal speed profile is possible @@ -162,7 +162,7 @@ void tc_move(float distance, float speed, float acceleration) { left_trap.speed = left_trap.dir * speed / WHEEL_R * 180 / M_PI; left_trap.state = TRAPEZOID_STATE_ACC; - // This is distance during which the robot will accelerate + // This is the distance during which the robot will accelerate acc_dist = SIGN(distance) * speed * speed / acceleration / 2.0 / WHEEL_R * 180.0 / M_PI; // Set accelerations for the trapezoid's first phase and associated callbacks @@ -178,19 +178,19 @@ void tc_move(float distance, float speed, float acceleration) { left_trap.is_triangle = 1; // Compute triangle parameters for right motor - right_trap.speed = right_trap.dir * sqrt(right_trap.angle * right_trap.acceleration); + right_trap.speed = right_trap.dir * sqrt(distance / WHEEL_R * 180 / M_PI * right_trap.acceleration); right_trap.state = TRAPEZOID_STATE_TRIANGLE; // Compute triangle parameters for left motor - left_trap.speed = left_trap.dir * sqrt(left_trap.angle * left_trap.acceleration); + left_trap.speed = left_trap.dir * sqrt(distance / WHEEL_R * 180 / M_PI * left_trap.acceleration); left_trap.state = TRAPEZOID_STATE_TRIANGLE; // Set accelerations for the triangle's first phase and associated callbacks adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + right_trap.angle/2.0, trapezoid_callback); + add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + distance / 2.0 / WHEEL_R * 180 / M_PI, trapezoid_callback); add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val + left_trap.angle/2.0, trapezoid_callback); + add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val + distance / 2.0 / WHEEL_R * 180 / M_PI, trapezoid_callback); add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); } @@ -218,7 +218,7 @@ void tc_turn(float angle, float speed, float acceleration) { // Is the trapezoidal speed profile posible ? t_acc = speed / acceleration; - t_end = (speed * speed + angle * acceleration) / (speed * acceleration); + t_end = (speed * speed + fabsf(angle) * acceleration) / (speed * acceleration); if (t_end > (2. * t_acc)) { // A trapezoidal speed profile is possible @@ -249,19 +249,19 @@ void tc_turn(float angle, float speed, float acceleration) { left_trap.is_triangle = 1; // Compute triangle parameters for right motor - right_trap.speed = right_trap.dir * sqrt(right_trap.angle * right_trap.acceleration); + right_trap.speed = right_trap.dir * sqrt(angle * STRUCT_B / 2.0 / WHEEL_R * right_trap.acceleration); right_trap.state = TRAPEZOID_STATE_TRIANGLE; // Compute triangle parameters for left motor - left_trap.speed = left_trap.dir * sqrt(left_trap.angle * left_trap.acceleration); + left_trap.speed = left_trap.dir * sqrt(- angle * STRUCT_B / 2.0 / WHEEL_R * left_trap.acceleration); left_trap.state = TRAPEZOID_STATE_TRIANGLE; // Set accelerations for the triangle's first phase and associated callbacks adjust_speed(&right_wheel_speed, right_trap.acceleration); - add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + right_trap.angle/2.0, trapezoid_callback); + add_callback(&right_wheel, SELECT_THRESHOLD(right_trap.dir), right_trap.init_val + angle / 2.0 * STRUCT_B / 2.0 / WHEEL_R, trapezoid_callback); add_callback(&right_wheel_speed, SELECT_THRESHOLD(right_trap.dir), right_trap.speed, trapezoid_callback); adjust_speed(&left_wheel_speed, left_trap.acceleration); - add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val + left_trap.angle/2.0, trapezoid_callback); + add_callback(&left_wheel, SELECT_THRESHOLD(left_trap.dir), left_trap.init_val - angle / 2.0 * STRUCT_B / 2.0 / WHEEL_R, trapezoid_callback); add_callback(&left_wheel_speed, SELECT_THRESHOLD(left_trap.dir), left_trap.speed, trapezoid_callback); } hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2011-03-30 11:51:00
|
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 4c596ea2f6a485e48aa77c844d9f0e3e6fa0eb98 (commit) from 3a221d16b0169ed682375c20c9db8e823395abd7 (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 4c596ea2f6a485e48aa77c844d9f0e3e6fa0eb98 Author: Xavier Lagorce <Xav...@cr...> Date: Wed Mar 30 13:50:20 2011 +0200 [Controller Motor STM32] Corrected typos in command_generator ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/command_generator.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/command_generator.c index 6542070..4d07057 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/command_generator.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/command_generator.c @@ -119,9 +119,9 @@ float get_output_value(command_generator_t *generator) { case GEN_RAMP2: cur_time = ticks_to_us(timer_clock()); speed = get_output_value(generator->ramp2.speed); - dt = (cur_time - generator->ramp.last_time)*1e-6; + dt = (cur_time - generator->ramp2.last_time)*1e-6; generator->type.last_output += dt*speed; - generator->ramp.last_time = cur_time; + generator->ramp2.last_time = cur_time; break; } hooks/post-receive -- krobot |
From: Nicolas D. <Ba...@us...> - 2011-03-30 00:11:48
|
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 3a221d16b0169ed682375c20c9db8e823395abd7 (commit) from 242d6620b5cf7a384b73f928d48d36b4417645b2 (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 3a221d16b0169ed682375c20c9db8e823395abd7 Author: Nicolas Dandrimont <Nic...@cr...> Date: Wed Mar 30 02:07:07 2011 +0200 [USB_CAN/Firmware] Explicitly set serial baudrate ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/USB_CAN/Firmware/usb_can/main.c b/elec/boards/USB_CAN/Firmware/usb_can/main.c index 40de93d..646b9d9 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/main.c +++ b/elec/boards/USB_CAN/Firmware/usb_can/main.c @@ -41,6 +41,7 @@ #include "usb_can.h" #define MAX_CMD_SIZE 64 +#define SERIAL_BAUDRATE 1000000 PROC_DEFINE_STACK(stack_ser_recv, KERN_MINSTACKSIZE * 4); PROC_DEFINE_STACK(stack_can_recv, KERN_MINSTACKSIZE * 4); @@ -82,6 +83,7 @@ static void init(void) /* Initialize Serial driver */ ser_init(&ser, SER_UART3); + ser_setbaudrate(&ser, SERIAL_BAUDRATE); /* Initialize USB-CAN logic */ usb_can_init(&usbcan, CAND1, &ser); hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 21:50:40
|
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 242d6620b5cf7a384b73f928d48d36b4417645b2 (commit) from 65a3c60237406303ecfc2efd5ae63e399d10d09b (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 242d6620b5cf7a384b73f928d48d36b4417645b2 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 23:49:12 2011 +0200 [krobot_viewer] rename the smooth button to "simplify" ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index 9a4123b..19227fb 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -202,7 +202,7 @@ </child> <child> <widget class="GtkButton" id="button_smooth"> - <property name="label" translatable="yes">Smooth trajectory</property> + <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> hooks/post-receive -- krobot |
From: Nicolas D. <Ba...@us...> - 2011-03-29 21:50:15
|
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 65a3c60237406303ecfc2efd5ae63e399d10d09b (commit) via 7aa55dd0d34b44ce45913414c760604d434ae503 (commit) via 4fa085f2f3a9ec372adaf1879e9eaac4c4e62c71 (commit) from f899b5a05ceb8f1181ca877a1cdf16a9dae90a6a (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 65a3c60237406303ecfc2efd5ae63e399d10d09b Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 29 23:47:50 2011 +0200 [USB_CAN/Firmware] Rationnalize serial writes commit 7aa55dd0d34b44ce45913414c760604d434ae503 Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 29 23:47:20 2011 +0200 [USB_CAN/Firmware] Add a semaphore to avoid serial tx interference commit 4fa085f2f3a9ec372adaf1879e9eaac4c4e62c71 Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 29 23:45:02 2011 +0200 [USB_CAN/Firmware] Use LED1 for tx, LED2 for rx, LED3 for power ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/USB_CAN/Firmware/usb_can/main.c b/elec/boards/USB_CAN/Firmware/usb_can/main.c index 278d29d..40de93d 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/main.c +++ b/elec/boards/USB_CAN/Firmware/usb_can/main.c @@ -116,21 +116,27 @@ static void NORETURN can_receive_process(void) { can_rx_frame frame; int retval; bool received = false; + bool i = false; for (;;) { received = can_receive(usbcan.can, &frame, ms_to_ticks(100)); if (received) { + i = !i; retval = usb_can_emit(&usbcan, &frame); + if (i) + LED2_ON(); + else + LED2_OFF(); } } } static void NORETURN blinky_process(void) { for (;;) { - LED2_ON(); + LED3_ON(); timer_delay(500); - LED2_OFF(); + LED3_OFF(); timer_delay(500); } } diff --git a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c index 07564ec..fc43170 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c +++ b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c @@ -58,6 +58,7 @@ void usb_can_init(usb_can *usbcan, can_driver *can, struct Serial *ser) { usbcan->is_open = false; usbcan->timestamped = false; usbcan->get_timestamp = get_timestamp; + sem_init(&usbcan->sem_receive); } @@ -100,14 +101,16 @@ int usb_can_execute_command(usb_can *usbcan, char *command) { frame.data32[0] = 0; frame.data32[1] = 0; + sem_obtain(&usbcan->sem_receive); + switch (command[0]) { case 'V': /* Version number */ - kfile_write(&usbcan->ser->fd, "V0402\r", 6); + kfile_write(&usbcan->ser->fd, "V0402\r", strlen("V0402\r")); break; case 'N': /* Serial number */ - kfile_write(&usbcan->ser->fd, "NKROB\r", 6); + kfile_write(&usbcan->ser->fd, "NKROB\r", strlen("NKROB\r")); break; case 'O': /* Open CAN Channel */ @@ -168,10 +171,11 @@ int usb_can_execute_command(usb_can *usbcan, char *command) { if (send) { ret = can_transmit(usbcan->can, &frame, ms_to_ticks(10)); if (ret) - kfile_write(&usbcan->ser->fd, frame.ide ? "\r" : "\r", 1); + kfile_write(&usbcan->ser->fd, "\r", 1); else kfile_write(&usbcan->ser->fd, "\a", 1); } + sem_release(&usbcan->sem_receive); return 0; } @@ -182,6 +186,10 @@ int usb_can_emit(usb_can *usbcan, can_rx_frame *frame) { int i = 0, j = 0; uint16_t timestamp; + // Do not interfere with the send ACK + if (!sem_attempt(&usbcan->sem_receive)) + return 0; + buffer[0] = frame->rtr ? 'r' : 't'; // Extended identifier : uppercase identifier @@ -213,5 +221,6 @@ int usb_can_emit(usb_can *usbcan, can_rx_frame *frame) { kfile_write(&usbcan->ser->fd, buffer, i); + sem_release(&usbcan->sem_receive); return 0; } diff --git a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h index 800e4a5..d24c859 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h +++ b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h @@ -25,7 +25,9 @@ #define USB_CAN_H #include <stdio.h> +#include <string.h> +#include <kern/sem.h> #include <drv/can.h> #include <drv/ser.h> #include <drv/timer.h> @@ -39,6 +41,7 @@ typedef struct _usb_can { bool is_open; // Channel open? bool timestamped; // Emit timestamps? usb_can_timestamp *get_timestamp; // Get Timestamp function + struct Semaphore sem_receive; // Avoid receiving when tx_ing } usb_can; uint16_t get_timestamp(void); hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 21:47:24
|
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 f899b5a05ceb8f1181ca877a1cdf16a9dae90a6a (commit) via baba502bff9b9ba9a1a93ea54bc3fc068b299610 (commit) from 0db0f51619bea9184177ca44eda4366ae6d22488 (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 f899b5a05ceb8f1181ca877a1cdf16a9dae90a6a Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 23:22:58 2011 +0200 [info] typo (request were sent two times) commit baba502bff9b9ba9a1a93ea54bc3fc068b299610 Author: [Kro]bot <kr...@wa...> Date: Tue Mar 29 22:23:40 2011 +0200 [info] allow to disable the compilation of GTK programs ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index 710ebee..450a1bc 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -16,6 +16,14 @@ Description: Control program for the Eurobot robotic cup. FilesAB: src/driver/bus.conf.ab # +-------------------------------------------------------------------+ +# | Flags | +# +-------------------------------------------------------------------+ + +Flag gtk + Description: Enable GTK programs + Default: true + +# +-------------------------------------------------------------------+ # | Libraries | # +-------------------------------------------------------------------+ @@ -115,14 +123,16 @@ Executable "krobot-local" Executable "krobot-plot" Path: src/tools - Install: true + Build$: flag(gtk) + Install$: flag(gtk) CompiledObject: best MainIs: krobot_plot.ml BuildDepends: krobot, lwt.syntax, cairo.lablgtk2, lwt.glib, threads Executable "krobot-viewer" Path: src/tools - Install: true + Build$: flag(gtk) + Install$: flag(gtk) CompiledObject: best MainIs: krobot_viewer.ml BuildDepends: krobot, lwt.syntax, cairo.lablgtk2, lwt.glib, threads, lablgtk2.glade diff --git a/info/control2011/myocamlbuild.ml b/info/control2011/myocamlbuild.ml index 08cc900..58c15ed 100644 --- a/info/control2011/myocamlbuild.ml +++ b/info/control2011/myocamlbuild.ml @@ -1,7 +1,7 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 570b31c8f48685aca9662d28e560f425) *) +(* DO NOT EDIT (digest: 7b180d572761c507057af7fdf11b0222) *) module OASISGettext = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISGettext.ml" let ns_ str = str @@ -24,7 +24,7 @@ module OASISGettext = struct end module OASISExpr = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExpr.ml" @@ -115,7 +115,7 @@ end module BaseEnvLight = struct -# 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnvLight.ml" module MapString = Map.Make(String) @@ -212,7 +212,7 @@ end module MyOCamlbuildFindlib = struct -# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" (** OCamlbuild extension, copied from * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild @@ -320,7 +320,7 @@ module MyOCamlbuildFindlib = struct end module MyOCamlbuildBase = struct -# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" (** Base functions for writing myocamlbuild.ml @author Sylvain Le Gall @@ -335,7 +335,7 @@ module MyOCamlbuildBase = struct type name = string type tag = string -# 55 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" +# 55 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" type t = { diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 6f7ed53..3f22dfe 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,14 +1,14 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 4353dde9f1283d0e97c3df83edda68fd) *) +(* DO NOT EDIT (digest: e7a994aa7e43385f1fc743e7a7663a49) *) (* Regenerated by OASIS v0.2.0 Visit http://oasis.forge.ocamlcore.org for more information and documentation about functions used in this file. *) module OASISGettext = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISGettext.ml" let ns_ str = str @@ -31,7 +31,7 @@ module OASISGettext = struct end module OASISContext = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISContext.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISContext.ml" open OASISGettext @@ -90,7 +90,7 @@ module OASISContext = struct end module OASISUtils = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISUtils.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISUtils.ml" module MapString = Map.Make(String) @@ -242,7 +242,7 @@ module OASISUtils = struct end module PropList = struct -# 21 "/home/dim/sources/oasis/src/oasis/PropList.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/PropList.ml" open OASISGettext @@ -277,7 +277,7 @@ module PropList = struct let clear t = Hashtbl.clear t -# 59 "/home/dim/sources/oasis/src/oasis/PropList.ml" +# 59 "/home/krobot/ocaml-stuff/oasis/src/oasis/PropList.ml" end module Schema = @@ -518,7 +518,7 @@ module PropList = struct end module OASISMessage = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISMessage.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISMessage.ml" open OASISGettext @@ -567,7 +567,7 @@ module OASISMessage = struct end module OASISVersion = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISVersion.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISVersion.ml" open OASISGettext @@ -751,7 +751,7 @@ module OASISVersion = struct end module OASISLicense = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISLicense.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISLicense.ml" (** License for _oasis fields @author Sylvain Le Gall @@ -784,7 +784,7 @@ module OASISLicense = struct end module OASISExpr = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExpr.ml" @@ -874,7 +874,7 @@ module OASISExpr = struct end module OASISTypes = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTypes.ml" @@ -951,7 +951,7 @@ module OASISTypes = struct type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list -# 102 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" +# 102 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTypes.ml" type 'a conditional = 'a OASISExpr.choices @@ -1105,7 +1105,7 @@ module OASISTypes = struct end module OASISUnixPath = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISUnixPath.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISUnixPath.ml" type unix_filename = string type unix_dirname = string @@ -1184,7 +1184,7 @@ module OASISUnixPath = struct end module OASISSection = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISSection.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISSection.ml" (** Manipulate section @author Sylvain Le Gall @@ -1246,12 +1246,12 @@ module OASISSection = struct end module OASISBuildSection = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISBuildSection.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISBuildSection.ml" end module OASISExecutable = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISExecutable.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISExecutable.ml" open OASISTypes @@ -1282,7 +1282,7 @@ module OASISExecutable = struct end module OASISLibrary = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISLibrary.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISLibrary.ml" open OASISTypes open OASISUtils @@ -1573,33 +1573,33 @@ module OASISLibrary = struct end module OASISFlag = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISFlag.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISFlag.ml" end module OASISPackage = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISPackage.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISPackage.ml" end module OASISSourceRepository = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISSourceRepository.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISSourceRepository.ml" end module OASISTest = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISTest.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISTest.ml" end module OASISDocument = struct -# 21 "/home/dim/sources/oasis/src/oasis/OASISDocument.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/oasis/OASISDocument.ml" end module BaseEnvLight = struct -# 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnvLight.ml" module MapString = Map.Make(String) @@ -1696,7 +1696,7 @@ end module BaseContext = struct -# 21 "/home/dim/sources/oasis/src/base/BaseContext.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseContext.ml" open OASISContext @@ -1707,7 +1707,7 @@ module BaseContext = struct end module BaseMessage = struct -# 21 "/home/dim/sources/oasis/src/base/BaseMessage.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseMessage.ml" (** Message to user, overrid for Base @author Sylvain Le Gall @@ -1728,7 +1728,7 @@ module BaseMessage = struct end module BaseFilePath = struct -# 21 "/home/dim/sources/oasis/src/base/BaseFilePath.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFilePath.ml" open Filename @@ -1760,7 +1760,7 @@ module BaseFilePath = struct end module BaseEnv = struct -# 21 "/home/dim/sources/oasis/src/base/BaseEnv.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseEnv.ml" open OASISTypes open OASISGettext @@ -2219,7 +2219,7 @@ module BaseEnv = struct end module BaseExec = struct -# 21 "/home/dim/sources/oasis/src/base/BaseExec.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseExec.ml" open OASISGettext open OASISUtils @@ -2279,7 +2279,7 @@ module BaseExec = struct end module BaseFileUtil = struct -# 21 "/home/dim/sources/oasis/src/base/BaseFileUtil.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFileUtil.ml" open OASISGettext @@ -2457,7 +2457,7 @@ module BaseFileUtil = struct end module BaseArgExt = struct -# 21 "/home/dim/sources/oasis/src/base/BaseArgExt.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseArgExt.ml" open OASISUtils open OASISGettext @@ -2485,7 +2485,7 @@ module BaseArgExt = struct end module BaseCheck = struct -# 21 "/home/dim/sources/oasis/src/base/BaseCheck.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseCheck.ml" open BaseEnv open BaseMessage @@ -2611,7 +2611,7 @@ module BaseCheck = struct end module BaseOCamlcConfig = struct -# 21 "/home/dim/sources/oasis/src/base/BaseOCamlcConfig.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseOCamlcConfig.ml" open BaseEnv @@ -2713,7 +2713,7 @@ module BaseOCamlcConfig = struct end module BaseStandardVar = struct -# 21 "/home/dim/sources/oasis/src/base/BaseStandardVar.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseStandardVar.ml" open OASISGettext @@ -2973,7 +2973,7 @@ module BaseStandardVar = struct end module BaseFileAB = struct -# 21 "/home/dim/sources/oasis/src/base/BaseFileAB.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseFileAB.ml" open BaseEnv open OASISGettext @@ -3021,7 +3021,7 @@ module BaseFileAB = struct end module BaseLog = struct -# 21 "/home/dim/sources/oasis/src/base/BaseLog.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseLog.ml" open OASISUtils @@ -3140,7 +3140,7 @@ module BaseLog = struct end module BaseBuilt = struct -# 21 "/home/dim/sources/oasis/src/base/BaseBuilt.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseBuilt.ml" open OASISTypes open OASISGettext @@ -3287,7 +3287,7 @@ module BaseBuilt = struct end module BaseCustom = struct -# 21 "/home/dim/sources/oasis/src/base/BaseCustom.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseCustom.ml" open BaseEnv open BaseMessage @@ -3337,7 +3337,7 @@ module BaseCustom = struct end module BaseDynVar = struct -# 21 "/home/dim/sources/oasis/src/base/BaseDynVar.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDynVar.ml" open OASISTypes @@ -3381,7 +3381,7 @@ module BaseDynVar = struct end module BaseTest = struct -# 21 "/home/dim/sources/oasis/src/base/BaseTest.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseTest.ml" open BaseEnv open BaseMessage @@ -3463,7 +3463,7 @@ module BaseTest = struct end module BaseDoc = struct -# 21 "/home/dim/sources/oasis/src/base/BaseDoc.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDoc.ml" open BaseEnv open BaseMessage @@ -3493,7 +3493,7 @@ module BaseDoc = struct end module BaseSetup = struct -# 21 "/home/dim/sources/oasis/src/base/BaseSetup.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseSetup.ml" open BaseEnv open BaseMessage @@ -3911,7 +3911,7 @@ module BaseSetup = struct end module BaseDev = struct -# 21 "/home/dim/sources/oasis/src/base/BaseDev.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/base/BaseDev.ml" @@ -3969,7 +3969,7 @@ end module InternalConfigurePlugin = struct -# 21 "/home/dim/sources/oasis/src/plugins/internal/InternalConfigurePlugin.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/internal/InternalConfigurePlugin.ml" (** Configure using internal scheme @author Sylvain Le Gall @@ -4185,7 +4185,7 @@ module InternalConfigurePlugin = struct end module InternalInstallPlugin = struct -# 21 "/home/dim/sources/oasis/src/plugins/internal/InternalInstallPlugin.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/internal/InternalInstallPlugin.ml" (** Install using internal scheme @author Sylvain Le Gall @@ -4584,7 +4584,7 @@ end module OCamlbuildCommon = struct -# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildCommon.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildCommon.ml" (** Functions common to OCamlbuild build and doc plugin *) @@ -4684,7 +4684,7 @@ module OCamlbuildCommon = struct end module OCamlbuildPlugin = struct -# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" (** Build using ocamlbuild @author Sylvain Le Gall @@ -4928,7 +4928,7 @@ module OCamlbuildPlugin = struct end module OCamlbuildDocPlugin = struct -# 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" +# 21 "/home/krobot/ocaml-stuff/oasis/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" (* Create documentation using ocamlbuild .odocl files @author Sylvain Le Gall @@ -5289,8 +5289,16 @@ let setup_t = cs_plugin_data = []; }, { - bs_build = [(OASISExpr.EBool true, true)]; - bs_install = [(OASISExpr.EBool true, true)]; + bs_build = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "gtk", true) + ]; + bs_install = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "gtk", true) + ]; bs_path = "src/tools"; bs_compiled_object = Best; bs_build_depends = @@ -5340,6 +5348,16 @@ let setup_t = bs_nativeopt = [(OASISExpr.EBool true, [])]; }, {exec_custom = false; exec_main_is = "send_can.ml"; }); + Flag + ({ + cs_name = "gtk"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + flag_description = Some "Enable GTK programs"; + flag_default = [(OASISExpr.EBool true, true)]; + }); Executable ({ cs_name = "krobot-remote"; @@ -5482,8 +5500,16 @@ let setup_t = cs_plugin_data = []; }, { - bs_build = [(OASISExpr.EBool true, true)]; - bs_install = [(OASISExpr.EBool true, true)]; + bs_build = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "gtk", true) + ]; + bs_install = + [ + (OASISExpr.EBool true, false); + (OASISExpr.EFlag "gtk", true) + ]; bs_path = "src/tools"; bs_compiled_object = Best; bs_build_depends = diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index c0a5414..aff2580 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -233,7 +233,6 @@ let send_and_recv bus req f = | None -> None) (recv bus)) in - lwt () = send bus (Unix.gettimeofday (), Req_motor_status) in let rec loop () = lwt () = send bus (Unix.gettimeofday (), req) in match_lwt choose [t; Lwt_unix.sleep wait_timeout >|= fun () -> `Timeout] with hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 19:07:13
|
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 0db0f51619bea9184177ca44eda4366ae6d22488 (commit) from 5d598864322684bb871d17034c47b16e123dd56b (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 0db0f51619bea9184177ca44eda4366ae6d22488 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 21:06:16 2011 +0200 [krobot_simulator] Only use angles between -pi and pi. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index d0da734..806c364 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -14,6 +14,18 @@ open Lwt_react open Krobot_config open Krobot_message +let pi = 4. *. atan 1. + +let math_mod_float a b = + let b2 = b /. 2. in + let modf = mod_float a b in + if modf > b2 then + modf -. b + else if modf < -. b2 then + modf +. b + else + modf;; + (* +-----------------------------------------------------------------+ | Types | +-----------------------------------------------------------------+ *) @@ -233,7 +245,7 @@ lwt () = sim.state <- { x = sim.state.x +. dx *. sim_step; y = sim.state.y +. dy *. sim_step; - theta = sim.state.theta +. dtheta *. sim_step; + theta = math_mod_float (sim.state.theta +. dtheta *. sim_step) (2. *. pi); }; sim.internal_state <- { theta_l = sim.internal_state.theta_l +. sim_step *. (u1 *. 4. +. u2 *. wheels_distance) /. (2. *. wheels_diameter); hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2011-03-29 17:26:42
|
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 5d598864322684bb871d17034c47b16e123dd56b (commit) from 73d098f1abe08b3ce46993d9500d7d38c0bc407b (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 5d598864322684bb871d17034c47b16e123dd56b Author: Xavier Lagorce <Xav...@cr...> Date: Tue Mar 29 19:25:13 2011 +0200 [krobot_simulator] Unify and reproduce Controller Motor STM32 behavior ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index 72f0182..d0da734 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -84,7 +84,7 @@ let velocities sim = (vel *. (sim.command_end -. sim.time) /. t_acc, 0.) let move sim distance velocity acceleration = - if velocity <> 0. && acceleration <> 0. then begin + if distance <> 0. && velocity > 0. && acceleration > 0. then begin let t_acc = velocity /. acceleration in let t_end = (velocity *. velocity +. distance *. acceleration) /. (velocity *. acceleration) in if t_end > 2. *. t_acc then begin @@ -95,9 +95,10 @@ let move sim distance velocity acceleration = end end else begin if t_acc <> 0. then begin - let t_acc = sqrt (distance /. acceleration) in + let t_acc = sqrt (abs_float (distance) /. acceleration) in let t_end = 2. *. t_acc in - let velocity = acceleration *. t_acc in + let sign = if distance >= 0. then 1. else -1. in + let velocity = sign *. acceleration *. t_acc in sim.command <- Move(t_acc, velocity); sim.command_start <- sim.time; sim.command_end <- sim.time +. t_end @@ -106,7 +107,7 @@ let move sim distance velocity acceleration = end let turn sim angle velocity acceleration = - if velocity <> 0. && acceleration <> 0. then begin + if angle <> 0. && velocity > 0. && acceleration > 0. then begin let t_acc = velocity /. acceleration in let t_end = (velocity *. velocity +. angle *. acceleration) /. (velocity *. acceleration) in if t_end > 2. *. t_acc then begin hooks/post-receive -- krobot |
From: Nicolas D. <Ba...@us...> - 2011-03-29 16:58:23
|
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 73d098f1abe08b3ce46993d9500d7d38c0bc407b (commit) from 09cc51bf25cafe064191d4b69a7f66c2a4bb2312 (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 73d098f1abe08b3ce46993d9500d7d38c0bc407b Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 29 18:57:34 2011 +0200 [krobot_viewer] Only use angles between -pi and pi. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 4acbc91..fa853cd 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -38,6 +38,16 @@ let utf8 code = end else invalid_arg "utf8" +let math_mod_float a b = + let b2 = b /. 2. in + let modf = mod_float a b in + if modf > b2 then + modf -. b + else if modf < -. b2 then + modf +. b + else + modf;; + (* +-----------------------------------------------------------------+ | LCD | +-----------------------------------------------------------------+ *) @@ -453,7 +463,7 @@ module Board = struct match board.points with | (x, y) :: rest -> (* Turn the robot. *) - let alpha = atan2 (y -. board.state.y) (x -. board.state.x) -. board.state.theta in + let alpha = math_mod_float (atan2 (y -. board.state.y) (x -. board.state.x) -. board.state.theta) (2. *. pi) in lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), Motor_turn(alpha, board.ui#rotation_speed#adjustment#value, @@ -485,7 +495,7 @@ module Board = struct let board ={ bus; ui; - state = { x = 0.2; y = 1.9; theta = 2. *. atan (-1.) }; + state = { x = 0.2; y = 1.9; theta = -0.5 *. pi }; points = []; event = E.never; } in @@ -496,7 +506,8 @@ module Board = struct (fun (ts, frame) -> match frame with | Odometry(x, y, theta) -> - let state = { x; y; theta } in + let angle = math_mod_float (theta) (2. *. pi) in + let state = { x; y; theta = angle; } in if state <> board.state then begin board.state <- state; queue_draw board hooks/post-receive -- krobot |
From: Nicolas D. <Ba...@us...> - 2011-03-29 16:02:22
|
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 09cc51bf25cafe064191d4b69a7f66c2a4bb2312 (commit) from 24c465a1c1fc2b591a4e1f90959bc398d22df7e9 (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 09cc51bf25cafe064191d4b69a7f66c2a4bb2312 Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 29 18:01:29 2011 +0200 [krobot_simulator] Support negative angles for turn. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_simulator.ml b/info/control2011/src/tools/krobot_simulator.ml index 055acba..72f0182 100644 --- a/info/control2011/src/tools/krobot_simulator.ml +++ b/info/control2011/src/tools/krobot_simulator.ml @@ -116,9 +116,10 @@ let turn sim angle velocity acceleration = sim.command_end <- sim.time +. t_end end end else begin - let t_acc = sqrt (angle /. acceleration) in + let t_acc = sqrt (abs_float (angle) /. acceleration) in let t_end = 2. *. t_acc in - let velocity = acceleration *. t_acc in + let sign = if angle >= 0. then 1. else -1. in + let velocity = sign *. acceleration *. t_acc in if t_acc <> 0. then begin sim.command <- Turn(t_acc, velocity); sim.command_start <- sim.time; hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 13:42:13
|
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 24c465a1c1fc2b591a4e1f90959bc398d22df7e9 (commit) from 9d4506550842ef4ad199135517ec1033e40dae93 (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 24c465a1c1fc2b591a4e1f90959bc398d22df7e9 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 15:41:35 2011 +0200 [info] Viewer UI tweaks ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index 8dd2f54..4acbc91 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -502,9 +502,9 @@ module Board = struct queue_draw board end | Motor_status true -> - board.ui#label_moving#set_text "yes" + board.ui#entry_moving#set_text "yes" | Motor_status false -> - board.ui#label_moving#set_text "no" + board.ui#entry_moving#set_text "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 641dc86..9a4123b 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -255,97 +255,134 @@ </packing> </child> <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <child> - <widget class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="label" translatable="yes">Moving: </property> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_moving"> - <property name="visible">True</property> - <property name="label" translatable="yes">no</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">1</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">5</property> - </packing> - </child> - <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">4</property> + <property name="n_rows">5</property> <property name="n_columns">2</property> <child> - <widget class="GtkLabel" id="label3"> + <widget class="GtkSpinButton" id="moving_speed"> <property name="visible">True</property> - <property name="label" translatable="yes">Moving speed: </property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="adjustment">0.5 0 2 0.10000000000000001 0 0</property> + <property name="digits">2</property> + <property name="numeric">True</property> </widget> <packing> - <property name="x_options">GTK_FILL</property> + <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="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkLabel" id="label4"> + <widget class="GtkSpinButton" id="moving_acceleration"> <property name="visible">True</property> - <property name="label" translatable="yes">Moving acceleration: </property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="adjustment">1 0 10 0.10000000000000001 0 0</property> + <property name="digits">2</property> + <property name="numeric">True</property> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</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> <property name="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="moving_speed"> + <widget class="GtkSpinButton" id="rotation_speed"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="adjustment">0.5 0 2 0.10000000000000001 0 0</property> + <property name="invisible_char">•</property> + <property name="adjustment">0.99999999999999989 0 4 0.10000000000000001 0 0</property> <property name="digits">2</property> <property name="numeric">True</property> </widget> <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="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="moving_acceleration"> + <widget class="GtkSpinButton" id="rotation_acceleration"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="adjustment">1 0 10 0.10000000000000001 0 0</property> + <property name="invisible_char">•</property> + <property name="adjustment">2.0000000000000009 0 10 0.10000000000000001 0 0</property> <property name="digits">2</property> <property name="numeric">True</property> </widget> <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="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Moving speed: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> <property name="top_attach">1</property> <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkLabel" id="label5"> + <widget class="GtkHBox" id="hbox5"> <property name="visible">True</property> - <property name="label" translatable="yes">Rotation speed: </property> + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">Moving acceleration: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="top_attach">2</property> @@ -355,59 +392,115 @@ </packing> </child> <child> - <widget class="GtkLabel" id="label6"> + <widget class="GtkHBox" id="hbox6"> <property name="visible">True</property> - <property name="label" translatable="yes">Rotation acceleration: </property> + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Rotation speed: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="top_attach">3</property> <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="rotation_speed"> + <widget class="GtkHBox" id="hbox7"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">•</property> - <property name="adjustment">0.99999999999999989 0 4 0.10000000000000001 0 0</property> - <property name="digits">2</property> - <property name="numeric">True</property> + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Rotation acceleration: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> </widget> <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">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkSpinButton" id="rotation_acceleration"> + <widget class="GtkHBox" id="hbox8"> + <property name="visible">True</property> + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Moving: </property> + </widget> + <packing> + <property name="expand">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkAlignment" id="alignment5"> + <property name="visible">True</property> + <child> + <placeholder/> + </child> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </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="adjustment">2.0000000000000009 0 10 0.10000000000000001 0 0</property> - <property name="digits">2</property> - <property name="numeric">True</property> + <property name="text" translatable="yes">no</property> </widget> <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="y_options">GTK_FILL</property> </packing> </child> </widget> <packing> <property name="expand">False</property> - <property name="position">6</property> + <property name="position">5</property> </packing> </child> <child> - <placeholder/> - </child> - <child> <widget class="GtkViewport" id="viewport1"> <property name="visible">True</property> <property name="resize_mode">queue</property> @@ -416,7 +509,7 @@ </child> </widget> <packing> - <property name="position">8</property> + <property name="position">6</property> </packing> </child> </widget> hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 13:25:19
|
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 9d4506550842ef4ad199135517ec1033e40dae93 (commit) from fd224ab8ffc2fdc42e03a8aed77b0818592a0844 (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 9d4506550842ef4ad199135517ec1033e40dae93 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 15:24:34 2011 +0200 [info] allow to set the speed/acceleration for rotations and movements separately ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/tools/krobot_viewer.ml b/info/control2011/src/tools/krobot_viewer.ml index df3b383..8dd2f54 100644 --- a/info/control2011/src/tools/krobot_viewer.ml +++ b/info/control2011/src/tools/krobot_viewer.ml @@ -456,8 +456,8 @@ module Board = struct let alpha = atan2 (y -. board.state.y) (x -. board.state.x) -. board.state.theta in lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), Motor_turn(alpha, - board.ui#speed#adjustment#value, - board.ui#acceleration#adjustment#value)) in + board.ui#rotation_speed#adjustment#value, + board.ui#rotation_acceleration#adjustment#value)) in lwt () = wait_done board in (* Move the robot. *) @@ -465,8 +465,8 @@ module Board = struct let dist = sqrt (sqr (x -. board.state.x) +. sqr (y -. board.state.y)) in lwt () = Krobot_message.send board.bus (Unix.gettimeofday (), Motor_move(dist, - board.ui#speed#adjustment#value, - board.ui#acceleration#adjustment#value)) in + board.ui#moving_speed#adjustment#value, + board.ui#moving_acceleration#adjustment#value)) in lwt () = wait_done board in (* Remove the point. *) diff --git a/info/control2011/src/tools/krobot_viewer_ui.glade b/info/control2011/src/tools/krobot_viewer_ui.glade index a08240e..641dc86 100644 --- a/info/control2011/src/tools/krobot_viewer_ui.glade +++ b/info/control2011/src/tools/krobot_viewer_ui.glade @@ -286,12 +286,12 @@ <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="n_rows">2</property> + <property name="n_rows">4</property> <property name="n_columns">2</property> <child> <widget class="GtkLabel" id="label3"> <property name="visible">True</property> - <property name="label" translatable="yes">Speed: </property> + <property name="label" translatable="yes">Moving speed: </property> </widget> <packing> <property name="x_options">GTK_FILL</property> @@ -301,7 +301,7 @@ <child> <widget class="GtkLabel" id="label4"> <property name="visible">True</property> - <property name="label" translatable="yes">Acceleration: </property> + <property name="label" translatable="yes">Moving acceleration: </property> </widget> <packing> <property name="top_attach">1</property> @@ -311,11 +311,11 @@ </packing> </child> <child> - <widget class="GtkSpinButton" id="speed"> + <widget class="GtkSpinButton" id="moving_speed"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="adjustment">0.5 0 2 0.10000000000000001 0.20000000000000001 0.20000000000000001</property> + <property name="adjustment">0.5 0 2 0.10000000000000001 0 0</property> <property name="digits">2</property> <property name="numeric">True</property> </widget> @@ -326,11 +326,11 @@ </packing> </child> <child> - <widget class="GtkSpinButton" id="acceleration"> + <widget class="GtkSpinButton" id="moving_acceleration"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="invisible_char">●</property> - <property name="adjustment">1 0 10 0.10000000000000001 0.20000000000000001 0.20000000000000001</property> + <property name="adjustment">1 0 10 0.10000000000000001 0 0</property> <property name="digits">2</property> <property name="numeric">True</property> </widget> @@ -342,6 +342,62 @@ <property name="y_options">GTK_FILL</property> </packing> </child> + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Rotation speed: </property> + </widget> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">Rotation acceleration: </property> + </widget> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="rotation_speed"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="adjustment">0.99999999999999989 0 4 0.10000000000000001 0 0</property> + <property name="digits">2</property> + <property name="numeric">True</property> + </widget> + <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="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="rotation_acceleration"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="adjustment">2.0000000000000009 0 10 0.10000000000000001 0 0</property> + <property name="digits">2</property> + <property name="numeric">True</property> + </widget> + <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="y_options">GTK_FILL</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> @@ -349,6 +405,9 @@ </packing> </child> <child> + <placeholder/> + </child> + <child> <widget class="GtkViewport" id="viewport1"> <property name="visible">True</property> <property name="resize_mode">queue</property> @@ -357,7 +416,7 @@ </child> </widget> <packing> - <property name="position">7</property> + <property name="position">8</property> </packing> </child> </widget> hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2011-03-29 13:02:14
|
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 fd224ab8ffc2fdc42e03a8aed77b0818592a0844 (commit) from 03506f5a382fb6d9d49d8fdcaa332db3e1a6c112 (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 fd224ab8ffc2fdc42e03a8aed77b0818592a0844 Author: Jérémie Dimino <je...@di...> Date: Tue Mar 29 14:53:03 2011 +0200 [info] do not get stuck while waiting for the reply to a CAN request When waiting for a CAN data, if it does not come after a timeout (0.1 second by default), we resend the request. ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/src/lib/krobot_message.ml b/info/control2011/src/lib/krobot_message.ml index debdc1d..c0a5414 100644 --- a/info/control2011/src/lib/krobot_message.ml +++ b/info/control2011/src/lib/krobot_message.ml @@ -9,6 +9,7 @@ open Krobot_can open Printf +open Lwt open Lwt_react (* +-----------------------------------------------------------------+ @@ -220,15 +221,29 @@ let recv bus = E.map (fun (timestamp, frame) -> (timestamp, decode frame)) (Krob | Calls | +-----------------------------------------------------------------+ *) -let motor_status bus = +let wait_timeout = 0.1 + +let send_and_recv bus req f = let t = E.next (E.fmap (fun (ts, frame) -> - match frame with - | Motor_status status -> Some(ts, status) - | _ -> None) + match f frame with + | Some x -> Some(`Value(ts, x)) + | None -> None) (recv bus)) in lwt () = send bus (Unix.gettimeofday (), Req_motor_status) in - t + let rec loop () = + lwt () = send bus (Unix.gettimeofday (), req) in + match_lwt choose [t; Lwt_unix.sleep wait_timeout >|= fun () -> `Timeout] with + | `Value x -> return x + | `Timeout -> loop () + in + loop () + +let motor_status bus = + send_and_recv bus Req_motor_status + (function + | Motor_status status -> Some status + | _ -> None) hooks/post-receive -- krobot |