Commit from zer0 (2008-03-27 10:55 CET)
================

Some timing optimisations

  aversive_projects  microb2008/extension/barrel.c    1.4
  aversive_projects  microb2008/extension/catapult.c  1.5
  aversive_projects  microb2008/extension/commands.c  1.3
  aversive_projects  microb2008/extension/state.c     1.4
  aversive_projects  microb2008/main/main.c           1.22
  aversive_projects  microb2008/main/main.h           1.13
  aversive_projects  microb2008/main/strat.c          1.5


===============================================
aversive_projects/microb2008/extension/barrel.c  (1.3 -> 1.4)
===============================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: barrel.c,v 1.3 2008-03-24 17:58:19 zer0 Exp $
+ *  Revision : $Id: barrel.c,v 1.4 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -274,5 +274,4 @@
        catapult_goto(speed, pos);
        wait_ms(150);
        catapult_release();
-       wait_ms(400);
 }


=================================================
aversive_projects/microb2008/extension/catapult.c  (1.4 -> 1.5)
=================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: catapult.c,v 1.4 2008-03-24 23:29:12 zer0 Exp $
+ *  Revision : $Id: catapult.c,v 1.5 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -34,8 +34,8 @@
 #include "catapult.h"
 #include "main.h"
 
-#define CATAPULT_ZERO_OFFSET -100
-#define CATAPULT_RELEASE_PWM -200
+#define CATAPULT_ZERO_OFFSET 0
+#define CATAPULT_RELEASE_PWM -300
 
 void catapult_pid_init(void);
 
@@ -95,5 +95,7 @@
        wait_ms(50);
        encoders_microb_set_value(CATAPULT_ENCODER, CATAPULT_ZERO_OFFSET);
        catapult_pid_init();
+       IRQ_LOCK(flags);
        ext.flags |= CATAPULT_CS_ON;
+       IRQ_UNLOCK(flags);
 }


=================================================
aversive_projects/microb2008/extension/commands.c  (1.2 -> 1.3)
=================================================

@@ -333,9 +333,7 @@
                action_servo_set(SERVO_RIGHT_EJECT_NUM, 
SERVO_RIGHT_EJECT_POS_NORMAL);
        }
        else if (!strcmp_P(res->dst, PSTR("drop"))) {
-               catapult_goto(catapult_speed, catapult_pos);
-               wait_ms(200);
-               catapult_release();
+               barrel_drop_shot(catapult_speed, catapult_pos);
        }
 }
 /* function called when cmd_eject is parsed successfully */
@@ -924,9 +922,7 @@
                barrel_room_to_dst(i, BARREL_OFFSET_DROP);
                while(barrel_get_idx(BARREL_OFFSET_DROP) != i);
                wait_ms(res->pause);
-               catapult_goto(catapult_speed, catapult_pos);
-               wait_ms(150);
-               catapult_release();
+               barrel_drop_shot(catapult_speed, catapult_pos);
        }
 }
 
@@ -1152,9 +1148,7 @@
        struct cmd_catapult_result * res = parsed_result;
 
        if (!strcmp_P(res->subcmd, PSTR("drop"))) {
-               catapult_goto(res->speed, res->pos);
-               wait_ms(200);
-               catapult_release();
+               barrel_drop_shot(res->speed, res->pos);
        }
        if (!strcmp_P(res->subcmd, PSTR("params"))) {
                catapult_speed = res->speed;


==============================================
aversive_projects/microb2008/extension/state.c  (1.3 -> 1.4)
==============================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: state.c,v 1.3 2008-03-24 23:29:12 zer0 Exp $
+ *  Revision : $Id: state.c,v 1.4 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -84,6 +84,44 @@
        return 0;
 }
 
+static void eat_ball(uint8_t type)
+{
+       /* the color sensor sees the ball before if it's white */
+       if (type == BARREL_ROOM_WHITE)
+               wait_ms(300);
+       else
+               wait_ms(100);
+
+       roller_off();
+       barrel_in(type);
+       if (type != BARREL_ROOM_BADCOL) {
+               if (type == BARREL_ROOM_COLORED)
+                       DEBUG(E_USER_ST_MACH, "%s: got colored", __FUNCTION__);
+               else
+                       DEBUG(E_USER_ST_MACH, "%s: got white", __FUNCTION__);
+               index = barrel_prepare(BARREL_ROOM_EMPTY, BARREL_OFFSET_IN);
+               if (index == -1)
+                       return; /* ? */
+               while(barrel_get_idx(BARREL_OFFSET_IN) != index);
+       }
+       else {
+               /* we need to eject the bad ball before doing
+                  anything else */
+               DEBUG(E_USER_ST_MACH, "%s: got bad color", __FUNCTION__);
+               if (ext.eject_side == I2C_EXTENSION_PREFER_LEFT_SIDE) {
+                       barrel_room_to_dst(index, BARREL_OFFSET_LEFT);
+                       while (barrel_get_idx(BARREL_OFFSET_LEFT) != index);
+                       barrel_drop_left();
+               }
+               else {
+                       barrel_room_to_dst(index, BARREL_OFFSET_RIGHT);
+                       while (barrel_get_idx(BARREL_OFFSET_RIGHT) != index);
+                       barrel_drop_right();
+               }
+       }
+       arm_roller_default();
+}
+
 /* pickup balls in dispensers */
 static int8_t state_do_pickup(void)
 {
@@ -96,9 +134,6 @@
 
        DEBUG(E_USER_ST_MACH, "%s", __FUNCTION__);
 
-       action_servo_set(SERVO_LEFT_ARM_NUM, SERVO_LEFT_ARM_POS_HARVEST);
-       action_servo_set(SERVO_RIGHT_ARM_NUM, SERVO_RIGHT_ARM_POS_HARVEST);
-
        /* prepare barrel with a free place */
        index = barrel_prepare(BARREL_ROOM_EMPTY, BARREL_OFFSET_IN);
        DEBUG(E_USER_ST_MACH, "%s: prepare room %d", __FUNCTION__, index);
@@ -107,6 +142,9 @@
                return 1; /* huh ? */
        }
 
+       action_servo_set(SERVO_LEFT_ARM_NUM, SERVO_LEFT_ARM_POS_HARVEST);
+       action_servo_set(SERVO_RIGHT_ARM_NUM, SERVO_RIGHT_ARM_POS_HARVEST);
+
        while(barrel_get_idx(BARREL_OFFSET_IN) != index) {
                if (state != I2C_EXTENSION_STATE_PICKUP)
                        return 0;
@@ -123,11 +161,11 @@
        while(type == BARREL_ROOM_EMPTY) {
                type = sensor_ball_front();
 
-               /* reopen it every second */
-               if ((time_get_us2() - us) > 1000000L) {
+               /* reopen it periodically */
+               if ((time_get_us2() - us) > 600000L) {
                        action_servo_set(SERVO_LEFT_ARM_NUM, 
SERVO_LEFT_ARM_POS_HARVEST);
                        action_servo_set(SERVO_RIGHT_ARM_NUM, 
SERVO_RIGHT_ARM_POS_HARVEST);
-                       wait_ms(500);
+                       wait_ms(300);
                        action_servo_set(SERVO_LEFT_ARM_NUM, 
SERVO_LEFT_ARM_POS_PICKUP);
                        action_servo_set(SERVO_RIGHT_ARM_NUM, 
SERVO_RIGHT_ARM_POS_PICKUP);
                        us = time_get_us2();
@@ -141,37 +179,7 @@
        action_servo_set(SERVO_LEFT_ARM_NUM, SERVO_LEFT_ARM_POS_HARVEST);
        action_servo_set(SERVO_RIGHT_ARM_NUM, SERVO_RIGHT_ARM_POS_HARVEST);
 
-       wait_ms(200);
-
-       roller_off();
-       barrel_in(type);
-       if (type != BARREL_ROOM_BADCOL) {
-               if (type == BARREL_ROOM_COLORED)
-                       DEBUG(E_USER_ST_MACH, "%s: got colored", __FUNCTION__);
-               else
-                       DEBUG(E_USER_ST_MACH, "%s: got white", __FUNCTION__);
-               index = barrel_prepare(BARREL_ROOM_EMPTY, BARREL_OFFSET_IN);
-               if (index == -1)
-                       return 0; /* ? */
-               while(barrel_get_idx(BARREL_OFFSET_IN) != index);
-       }
-       else {
-               /* we need to eject the bad ball before doing
-                  anything else */
-               DEBUG(E_USER_ST_MACH, "%s: got bad color", __FUNCTION__);
-               if (ext.eject_side == I2C_EXTENSION_PREFER_LEFT_SIDE) {
-                       barrel_room_to_dst(index, BARREL_OFFSET_LEFT);
-                       while (barrel_get_idx(BARREL_OFFSET_LEFT) != index);
-                       barrel_drop_left();
-               }
-               else {
-                       barrel_room_to_dst(index, BARREL_OFFSET_RIGHT);
-                       while (barrel_get_idx(BARREL_OFFSET_RIGHT) != index);
-                       barrel_drop_right();
-               }
-       }
-
-       arm_roller_default();
+       eat_ball(type);
 
        return 1; /* loop when return 1 */
 }
@@ -185,8 +193,6 @@
        if (state != I2C_EXTENSION_STATE_HARVEST)
                return 0;
 
-       arm_roller_default();
-
        /* prepare barrel with a free place */
        index = barrel_prepare(BARREL_ROOM_EMPTY, BARREL_OFFSET_IN);
        DEBUG(E_USER_ST_MACH, "%s: prepare room %d", __FUNCTION__, index);
@@ -196,6 +202,8 @@
                return 1; /* huh ? */
        }
 
+       arm_roller_default();
+
        while(barrel_get_idx(BARREL_OFFSET_IN) != index) {
                if (state != I2C_EXTENSION_STATE_HARVEST)
                        return 0;
@@ -211,35 +219,7 @@
                        return 0;
        }
 
-       wait_ms(200);
-       roller_off();
-       barrel_in(type);
-       if (type != BARREL_ROOM_BADCOL) {
-               if (type == BARREL_ROOM_COLORED)
-                       DEBUG(E_USER_ST_MACH, "%s: got colored", __FUNCTION__);
-               else
-                       DEBUG(E_USER_ST_MACH, "%s: got white", __FUNCTION__);
-               index = barrel_prepare(BARREL_ROOM_EMPTY, BARREL_OFFSET_IN);
-               if (index == -1)
-                       return 0; /* ? */
-               while(barrel_get_idx(BARREL_OFFSET_IN) != index);
-       }
-       else {
-               /* we need to eject the bad ball before doing
-                  anything else */
-               DEBUG(E_USER_ST_MACH, "%s: got bad color", __FUNCTION__);
-               if (ext.eject_side == I2C_EXTENSION_PREFER_LEFT_SIDE) {
-                       barrel_room_to_dst(index, BARREL_OFFSET_LEFT);
-                       while (barrel_get_idx(BARREL_OFFSET_LEFT) != index);
-                       barrel_drop_left();
-               }
-               else {
-                       barrel_room_to_dst(index, BARREL_OFFSET_RIGHT);
-                       while (barrel_get_idx(BARREL_OFFSET_RIGHT) != index);
-                       barrel_drop_right();
-               }
-       }
-       arm_roller_default();
+       eat_ball(type);
        return 1; /* loop when return 1 */
 }
 
@@ -270,16 +250,15 @@
                        return 0;
        }
 
+       wait_ms(50); /* a little wait to be sure that the barrel is
+                       not moving anymore */
        DEBUG(E_USER_ST_MACH, "%s: prepared !", __FUNCTION__);
-       
-       /* exit if we changed the state */
-       if (state != I2C_EXTENSION_STATE_PREPARE)
-               return 0;
 
        IRQ_LOCK(flags);
        if (state == I2C_EXTENSION_STATE_PREPARE)
                state = I2C_EXTENSION_STATE_DROP_READY;
        IRQ_UNLOCK(flags);
+
        return 0;
 }
 


========================================
aversive_projects/microb2008/main/main.c  (1.21 -> 1.22)
========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.c,v 1.21 2008-03-24 23:29:13 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.22 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -44,6 +44,7 @@
 #include <rdline.h>
 #include <parse.h>
 #include <obstacle_avoidance.h>
+#include <blocking_detection_manager.h>
 
 #include "cam.h"
 #include "main.h"
@@ -87,7 +88,6 @@
 void do_cs(void * dummy) 
 {
        static uint8_t cpt = 0;
-       uint8_t second;
 
        /* used for cs debugging */
        static uint32_t debug_cs_cpt = 0;
@@ -145,9 +145,11 @@
                bd_manage(&robot.bd_d);
        }
 
+#if 0
        if(robot.cs_events & DO_TIMER) {
+               uint8_t second;
                second = time_get_s();
-               if (second>= MATCH_TIME) {
+               if (second >= MATCH_TIME) {
                        strat_uninit();
                        pwm_set(LEFT_PWM, 0);
                        pwm_set(RIGHT_PWM, 0);
@@ -155,6 +157,7 @@
                        while(1);
                }
        }
+#endif
        cpt++;
 }
 


========================================
aversive_projects/microb2008/main/main.h  (1.12 -> 1.13)
========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.h,v 1.12 2008-03-24 23:29:13 zer0 Exp $
+ *  Revision : $Id: main.h,v 1.13 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -35,7 +35,7 @@
 //#define PROFILE
 
 
-/* XXX it is 90 don't forget it :) */
+/* it is 90 don't forget it :) */
 #define MATCH_TIME 90
 
 /* decrease track to decrease angle */


=========================================
aversive_projects/microb2008/main/strat.c  (1.4 -> 1.5)
=========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: strat.c,v 1.4 2008-03-24 23:29:13 zer0 Exp $
+ *  Revision : $Id: strat.c,v 1.5 2008-03-27 09:55:49 zer0 Exp $
  *
  */
 
@@ -38,8 +38,15 @@
 #define CATAPULT_SPEED_H_DISP 200
 #define CATAPULT_POS_H_DISP  8000
 
-static int8_t colored_v_disp_balls;
-static int8_t white_v_disp_balls;
+#define DISP_MAX_TRIES 2
+
+struct v_dispenser {
+       int8_t count;
+       uint8_t tries;
+};
+
+static struct v_dispenser colored_disp;
+static struct v_dispenser white_disp;
 
 static uint8_t h_disp_enabled;
 
@@ -52,8 +59,8 @@
        i2c_set_roller(1);
        i2c_set_arm(I2C_EXTENSION_ARM_HARVEST);
        time_reset();
-       colored_v_disp_balls = 5;
-       white_v_disp_balls = 5;
+       colored_disp.count = 5;
+       white_disp.count = 5;
        h_disp_enabled = 0;
        robot.cs_events =  DO_CS | DO_RS | DO_POS | DO_BD | DO_TIMER;
 }
@@ -63,6 +70,7 @@
 {
        i2c_set_roller(0);
        i2c_set_arm(I2C_EXTENSION_ARM_INSIDE);
+       robot.cs_events &= DO_TIMER;
 }
 
 /* get static balls on the game area
@@ -75,35 +83,79 @@
        return END_TRAJ;
 }
 
-/* get balls from dispenser 
- * Return values: 
- *   - END_TRAJ: we emptied the dispenser
- *   - ERROR: Cannot finish the trajectory, some balls can
- *     remain in the dispenser */
+#define PICKUP_TIMEOUT (2000000L) /* 2 seconds */
+
+/* get balls from dispenser */
+static uint8_t strat_pickup_v_disp(struct v_dispenser *disp)
+{
+       uint8_t prev_count;
+       microseconds us;
+
+       if (disp->tries >= DISP_MAX_TRIES || disp->count == 0)
+               return END_TRAJ;
+
+       disp->tries++;
+       prev_count = barrel_colored_count();
+       i2c_pickup();
+
+       /* retrieve balls */
+       us = time_get_us2();
+       while (!barrel_full()) {
+
+               /* we got a ball */
+               if (barrel_colored_count() != prev_count) {
+                       us = time_get_us2(); /* reinit timeout */
+                       disp->count --;
+                       prev_count = barrel_colored_count();
+               }
+
+               /* no ball left */
+               if (disp->count == 0) {
+                       DEBUG(E_USER_STRAT, "%s: all balls have been 
retrieved");
+                       return END_TRAJ;
+               }
+
+               /* cannot get any ball, ok we will try later */
+               if ((time_get_us2() - us) > PICKUP_TIMEOUT) {
+                       DEBUG(E_USER_STRAT, "%s: barrel full");
+                       return END_TRAJ;
+               }
+       }
+
+       DEBUG(E_USER_STRAT, "%s: barrel full");
+       return END_TRAJ;
+}
+
+/* */
 static uint8_t strat_get_white_v_disp(void)
 {
-       if (white_v_disp_balls <= 0)
+       if (white_disp.count <= 0)
                return END_TRAJ;
        DEBUG(E_USER_STRAT, "%s, %d balls remaining", __FUNCTION__, 
-             white_v_disp_balls);
+             white_disp.count);
+
+       /* XXX check traj failures */
+       trajectory_goto_xy_abs(&robot.traj, 45, COL_COORD_Y(75));
+       wait_traj_end(END_TRAJ);
+       trajectory_a_abs(&robot.traj, COL_ANGLE(180));
+       wait_traj_end(END_TRAJ);
+       trajectory_goto_xy_abs(&robot.traj, 25, COL_COORD_Y(75));
+       wait_traj_end(END_TRAJ);
+       
+       strat_pickup_v_disp(&white_disp);
+
        return END_TRAJ;
 }
 
-/* get balls from dispenser 
- * Return values: 
- *   - END_TRAJ: we emptied the dispenser
- *   - ERROR: Cannot finish the trajectory, some balls can
- *     remain in the dispenser */
+/* */
 static uint8_t strat_get_colored_v_disp(void)
 {
-       uint8_t old_count;
-
-       if (colored_v_disp_balls <= 0)
+       if (colored_disp.count <= 0)
                return END_TRAJ;
        DEBUG(E_USER_STRAT, "%s, %d balls remaining", __FUNCTION__, 
-             colored_v_disp_balls);
+             colored_disp.count);
 
-       /* XXX check errors */
+       /* XXX check traj failures */
        trajectory_goto_xy_abs(&robot.traj, 70, COL_COORD_Y(45));
        wait_traj_end(END_TRAJ);
        trajectory_a_abs(&robot.traj, COL_ANGLE(-90));
@@ -111,15 +163,7 @@
        trajectory_goto_xy_abs(&robot.traj, 70, COL_COORD_Y(25));
        wait_traj_end(END_TRAJ);
        
-       old_count = barrel_colored_count();
-       i2c_pickup();
-
-       /* count retrieved balls */
-       /* XXX add a timeout */
-
-       while (!barrel_full() &&
-              (colored_v_disp_balls - (barrel_colored_count() - old_count)) != 
0);
-       colored_v_disp_balls -= (barrel_colored_count() - old_count);
+        strat_pickup_v_disp(&colored_disp);
 
        return END_TRAJ;
 }
@@ -143,7 +187,6 @@
        
        while (barrel_colored_count()) {
                while(extension_state() != I2C_EXTENSION_STATE_DROP_READY);
-               wait_ms(50);
                i2c_drop(get_catapult_speed(distance_from_robot(300, 
COL_COORD_Y(185))), 8000);
                while(extension_state() != I2C_EXTENSION_STATE_HARVEST);
                if (barrel_colored_count())
@@ -210,20 +253,25 @@
        trajectory_set_speed(&robot.traj, 300, 300);
 
        err = strat_get_static_balls();
-       err = strat_drop_balls(1);
+       err = strat_drop_balls(1); /* ou pas force ? */
 
        while(1) {
                err = strat_get_colored_v_disp();
-               err = strat_drop_balls(0);
-
-               return 0; /* XXX */
+               strat_drop_balls(0);
 
-               if (colored_v_disp_balls != 0)
+               /* si on a une chance s'y retourner sans encombres, on retente 
*/
+               if (err == END_TRAJ && colored_disp.count != 0)
                        continue;
 
+               /* ici, il vaut mieux s'arranger pour ne plus avoir de
+                * balles, car ça serait con de faire plusieurs
+                * voyages */
                err = strat_get_white_v_disp();
-               err = strat_drop_balls(0);
-               if (white_v_disp_balls != 0)
+               strat_drop_balls(0);
+
+               return 0; /* XXX */
+
+               if (white_disp.count != 0)
                        continue;
                
                err = strat_enable_h_disp();


Commit from zer0 (2008-03-27 11:01 CET)
================

replace all \n by \r\n

  aversive_projects  microb2008/extension/main.c   1.15
  aversive_projects  microb2008/main/main.c        1.23
  aversive_projects  microb2008/sensor/commands.c  1.2
  aversive_projects  microb2008/sensor/main.c      1.2


=============================================
aversive_projects/microb2008/extension/main.c  (1.14 -> 1.15)
=============================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.c,v 1.14 2008-03-24 17:58:19 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.15 2008-03-27 10:01:34 zer0 Exp $
  *
  */
 
@@ -149,11 +149,11 @@
        int8_t ret;
        ret = parse(main_ctx, buf);
        if (ret == PARSE_AMBIGUOUS)
-               printf_P(PSTR("Ambiguous command\n"));
+               printf_P(PSTR("Ambiguous command\r\n"));
        else if (ret == PARSE_NOMATCH)
-               printf_P(PSTR("Command not found\n"));
+               printf_P(PSTR("Command not found\r\n"));
        else if (ret == PARSE_BAD_ARGS)
-               printf_P(PSTR("Bad arguments\n"));
+               printf_P(PSTR("Bad arguments\r\n"));
 }
 
 static int8_t 
@@ -209,8 +209,8 @@
        uart0_register_rx_event(emergency);
        sei();
 
-       printf_P(PSTR("\nBitte Schnell Edition 3.0"             "\n"));
-       printf_P(PSTR("                -- Um zu gut zu machen --\n\n"));
+       printf_P(PSTR("\r\nBitte Schnell Edition 3.0"             "\r\n"));
+       printf_P(PSTR("                -- Um zu gut zu machen --\r\n\n"));
        printf_P(PSTR("Init... please wait..."));
 
        /* LOGS */
@@ -256,7 +256,7 @@
        scheduler_add_periodical_event_priority(do_cs, NULL, 
                                                5000L / SCHEDULER_UNIT, 
CS_PRIO);
 
-       printf_P(PSTR("Starting state machine\n"));
+       printf_P(PSTR("Starting state machine\r\n"));
        ext.logs[0] = E_USER_ST_MACH;
        ext.log_level = 5;
        state_harvest();


========================================
aversive_projects/microb2008/main/main.c  (1.22 -> 1.23)
========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.c,v 1.22 2008-03-27 09:55:49 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.23 2008-03-27 10:01:34 zer0 Exp $
  *
  */
 
@@ -233,11 +233,11 @@
        int8_t ret;
        ret = parse(main_ctx, buf);
        if (ret == PARSE_AMBIGUOUS)
-               printf_P(PSTR("Ambiguous command\n"));
+               printf_P(PSTR("Ambiguous command\r\n"));
        else if (ret == PARSE_NOMATCH)
-               printf_P(PSTR("Command not found\n"));
+               printf_P(PSTR("Command not found\r\n"));
        else if (ret == PARSE_BAD_ARGS)
-               printf_P(PSTR("Bad arguments\n"));
+               printf_P(PSTR("Bad arguments\r\n"));
 }
 
 static int8_t 
@@ -265,7 +265,7 @@
                TCCR2 = 4;
                TCNT2 = 0;
                cpt = PROFILE_TIME;
-               printf("%.4x\n", pc);
+               printf("%.4x\r\n", pc);
        }
        cpt--;
 }
@@ -502,32 +502,32 @@
        wait_ms(100);
        //strat_uninit();
 
-       printf_P(PSTR("           .*.           .**"            "\n"));
-       printf_P(PSTR("          ,*.     --------------------"  "\n"));
-       printf_P(PSTR("         .*.       Microb Technology"    "\n"));
-       printf_P(PSTR("        .**       --------------------"  "\n"));
-       printf_P(PSTR("        .**                 ***"         "\n"));
-       printf_P(PSTR("        ***.                ***"         "\n"));
-       printf_P(PSTR("        .***    .,****..   ***."         "\n"));
-       printf_P(PSTR("        .****.***     .**,****."         "\n"));
-       printf_P(PSTR("        ..****,.       ..****..."        "\n"));
-       printf_P(PSTR("     ************** **************"      "\n"));
-       printf_P(PSTR("  .**************** ****************."   "\n"));
-       printf_P(PSTR("..**.     **.*****   *****,,*    ..***." "\n"));
-       printf_P(PSTR(".*        **  .**.   .**,  **       .**.""\n"));
-       printf_P(PSTR("*         .*.  ..** **..  .**         *.""\n"));
-       printf_P(PSTR("          .**  .*******.  .*.         .*""\n"));
-       printf_P(PSTR("           .**. .*****.  **.           *""\n"));
-       printf_P(PSTR("             **, *****..**"              "\n"));
-       printf_P(PSTR("               ,*******."                "\n"));
-       printf_P(PSTR("               .*******."                "\n"));
-       printf_P(PSTR("               .***.****     2008"       "\n"));
-       printf_P(PSTR("              ****  .****."              "\n"));
-       printf_P(PSTR("    .*....******      .*****.....*."     "\n"));
-       printf_P(PSTR("       ..**,.             .:**.."        "\n"));
+       printf_P(PSTR("           .*.           .**"            "\r\n"));
+       printf_P(PSTR("          ,*.     --------------------"  "\r\n"));
+       printf_P(PSTR("         .*.       Microb Technology"    "\r\n"));
+       printf_P(PSTR("        .**       --------------------"  "\r\n"));
+       printf_P(PSTR("        .**                 ***"         "\r\n"));
+       printf_P(PSTR("        ***.                ***"         "\r\n"));
+       printf_P(PSTR("        .***    .,****..   ***."         "\r\n"));
+       printf_P(PSTR("        .****.***     .**,****."         "\r\n"));
+       printf_P(PSTR("        ..****,.       ..****..."        "\r\n"));
+       printf_P(PSTR("     ************** **************"      "\r\n"));
+       printf_P(PSTR("  .**************** ****************."   "\r\n"));
+       printf_P(PSTR("..**.     **.*****   *****,,*    ..***." "\r\n"));
+       printf_P(PSTR(".*        **  .**.   .**,  **       .**.""\r\n"));
+       printf_P(PSTR("*         .*.  ..** **..  .**         *.""\r\n"));
+       printf_P(PSTR("          .**  .*******.  .*.         .*""\r\n"));
+       printf_P(PSTR("           .**. .*****.  **.           *""\r\n"));
+       printf_P(PSTR("             **, *****..**"              "\r\n"));
+       printf_P(PSTR("               ,*******."                "\r\n"));
+       printf_P(PSTR("               .*******."                "\r\n"));
+       printf_P(PSTR("               .***.****     2008"       "\r\n"));
+       printf_P(PSTR("              ****  .****."              "\r\n"));
+       printf_P(PSTR("    .*....******      .*****.....*."     "\r\n"));
+       printf_P(PSTR("       ..**,.             .:**.."        "\r\n"));
 
-       printf_P(PSTR("\nBitte Schnell Edition 3.0"             "\n"));
-       printf_P(PSTR("                -- Um zu gut zu machen --\n\n"));
+       printf_P(PSTR("\r\nBitte Schnell Edition 3.0"             "\r\n"));
+       printf_P(PSTR("                -- Um zu gut zu machen --\r\n\n"));
 
 
        rdline_init(&rdl, write_char, valid_buffer, complete_buffer);


==============================================
aversive_projects/microb2008/sensor/commands.c  (1.1 -> 1.2)
==============================================

@@ -29,10 +29,10 @@
 {
        //      struct cmd_sensor_result *res = parsed_result;
 
-       printf_P(PSTR("Sensors state:\n"
-                     "  %lx\n"), sensor_read());
+       printf_P(PSTR("Sensors state:\r\n"
+                     "  %lx\r\n"), sensor_read());
        
-       printf_P(PSTR("PINA=%x\n"), PINA);
+       printf_P(PSTR("PINA=%x\r\n"), PINA);
        
 }
 


==========================================
aversive_projects/microb2008/sensor/main.c  (1.1 -> 1.2)
==========================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: main.c,v 1.1 2008-03-24 18:02:11 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.2 2008-03-27 10:01:34 zer0 Exp $
  *
  */
 
@@ -85,11 +85,11 @@
        int8_t ret;
        ret = parse(main_ctx, buf);
        if (ret == PARSE_AMBIGUOUS)
-               printf_P(PSTR("Ambiguous command\n"));
+               printf_P(PSTR("Ambiguous command\r\n"));
        else if (ret == PARSE_NOMATCH)
-               printf_P(PSTR("Command not found\n"));
+               printf_P(PSTR("Command not found\r\n"));
        else if (ret == PARSE_BAD_ARGS)
-               printf_P(PSTR("Bad arguments\n"));
+               printf_P(PSTR("Bad arguments\r\n"));
 }
 
 static int8_t 
@@ -118,8 +118,8 @@
        uart1_register_rx_event(emergency);
        sei();
 
-       printf_P(PSTR("\nBitte Schnell Edition 3.0"             "\n"));
-       printf_P(PSTR("                -- Um zu gut zu machen --\n\n"));
+       printf_P(PSTR("\r\nBitte Schnell Edition 3.0"             "\r\n"));
+       printf_P(PSTR("                -- Um zu gut zu machen --\r\n\n"));
 
        /* i2c */
        i2c_protocol_init();


Commit from zer0 on branch b_zer0 (2008-03-27 20:19 CET)
=================================

fix i2c:
  - workaround when i2c is stucked, use i2c_reset()
  - add debug

  aversive  modules/comm/i2c/i2c.c  1.1.2.10
  aversive  modules/comm/i2c/i2c.h  1.1.2.8


===============================
aversive/modules/comm/i2c/i2c.c  (1.1.2.9 -> 1.1.2.10)
===============================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: i2c.c,v 1.1.2.9 2008-01-07 22:49:06 zer0 Exp $
+ *  Revision : $Id: i2c.c,v 1.1.2.10 2008-03-27 19:19:33 zer0 Exp $
  *
  */
 
@@ -34,7 +34,6 @@
 #include <aversive/errno.h>
 #include <i2c.h>
 
-
 #if I2C_SEND_BUFFER_SIZE < 1
 #error "I2C_SEND_BUFFER_SIZE must be at least 1"
 #endif
@@ -56,7 +55,7 @@
 static void (*g_send_event)(int8_t) = NULL;
 
 static volatile i2c_mode_t g_mode = I2C_MODE_UNINIT;
-volatile uint8_t g_status = I2C_STATUS_READY;/* XXX */
+static volatile uint8_t g_status = I2C_STATUS_READY;
 
 static volatile uint8_t g_ctrl = 0; /* ctrl flags */
 static volatile uint8_t g_sync_res = 0; /* result of sync send */
@@ -70,6 +69,14 @@
 static volatile uint8_t g_recv_nbytes = 0; /* number of received bytes */
 static volatile uint8_t g_recv_size = 0; /* size of buffer to be received */
 
+#if I2C_DEBUG == 1
+#include <stdio.h>
+#include <aversive/pgmspace.h>
+static volatile uint8_t g_prev_twstatus = 0;
+static volatile uint8_t g_intr_cpt = 0;
+static volatile uint8_t g_prev_status = 0;
+static volatile uint8_t g_command = 0;
+#endif
 
 /**
  * mode is I2C_MODE_UNINIT, I2C_MODE_MASTER, I2C_MODE_MULTIMASTER or
@@ -185,7 +192,6 @@
        IRQ_UNLOCK(flags);
 }
 
-
 /**
  * Send a buffer. Return 0 if xmit starts correctly.
  * On error, return != 0.
@@ -265,12 +271,19 @@
        /* If it is sync mode, wait op_finished. Here we will reset
         * the status flag to ready */
        if (ctrl & I2C_CTRL_SYNC) {
-               while ( (g_status & I2C_STATUS_OP_FINISHED) == 0 );
-               g_status &= ~(I2C_STATUS_MASTER_XMIT |
-                             I2C_STATUS_MASTER_RECV |
-                             I2C_STATUS_SLAVE_XMIT |
-                             I2C_STATUS_SLAVE_RECV |
-                             I2C_STATUS_OP_FINISHED);
+               while ( 1 ) {
+                       IRQ_LOCK(flags);
+                       if (g_status & I2C_STATUS_OP_FINISHED) {
+                               g_status &= ~(I2C_STATUS_MASTER_XMIT |
+                                             I2C_STATUS_MASTER_RECV |
+                                             I2C_STATUS_SLAVE_XMIT |
+                                             I2C_STATUS_SLAVE_RECV |
+                                             I2C_STATUS_OP_FINISHED);
+                               break;
+                       }
+                       IRQ_UNLOCK(flags);
+               }
+               IRQ_UNLOCK(flags);
                return g_sync_res;
        }
        
@@ -308,6 +321,25 @@
 }
 
 /**
+ * recover from error state
+ */
+void
+i2c_reset(void)
+{
+       uint8_t flags;
+
+       IRQ_LOCK(flags);
+       TWCR = 0;
+       g_status = I2C_STATUS_READY;
+       if (g_mode == I2C_MODE_MASTER) 
+               TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
+       else
+               TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | 
+                       (1<<TWSTO) | (1<<TWEA);
+       IRQ_UNLOCK(flags);
+}
+
+/**
  * In slave mode, it returns error and is useless (all data is
  * received trough the callback).  In master mode, if dest_add is
  * between 0 and 127, it will start to read the addressed slave. The
@@ -456,8 +488,21 @@
        return size;
 }
 
-
-
+#if I2C_DEBUG == 1
+void i2c_debug(void)
+{
+       printf_P(PSTR("mode=0x%x\r\n"), g_mode);
+       printf_P(PSTR("status=0x%x\r\n"), g_status);
+       printf_P(PSTR("ctrl=0x%x\r\n"), g_ctrl);
+       printf_P(PSTR("dst=%d\r\n"), g_dest);
+       printf_P(PSTR("send_nbytes=%d, send_size=%d\r\n"), g_send_nbytes, 
g_send_size);
+       printf_P(PSTR("recv_nbytes=%d, recv_size=%d\r\n"), g_recv_nbytes, 
g_recv_size);
+       printf_P(PSTR("prev_twstatus=0x%x\r\n"), g_prev_twstatus);
+       printf_P(PSTR("intr_cpt=%d\r\n"), g_intr_cpt);
+       printf_P(PSTR("prev_status=0x%x\r\n"), g_prev_status);
+       printf_P(PSTR("prev_command=0x%x\r\n"), g_command);
+}
+#endif
 
 /** interrupt ********************************************************/
 
@@ -472,6 +517,10 @@
 
        hard_status = TW_STATUS;
 
+#if I2C_DEBUG == 1
+       g_prev_twstatus = hard_status;
+       g_intr_cpt++;
+#endif
        switch(hard_status) {
 
 #ifdef CONFIG_MODULE_I2C_MASTER
@@ -504,7 +553,7 @@
                g_status |= (I2C_STATUS_OP_FINISHED | I2C_STATUS_NEED_XMIT_EVT);
                break;
 
-       case TW_MT_DATA_ACK:
+       case TW_MT_DATA_ACK: /* 0x28 */
                /* we transmitted data with success, send next one or
                 * stop condition if there is no more data */
                if (g_send_nbytes >= g_send_size) {
@@ -581,6 +630,7 @@
                        g_send_nbytes = -2;
                        g_status |= I2C_STATUS_NEED_XMIT_EVT;           
                }
+               /* g_status |= I2C_STATUS_OP_FINISHED; */ /* ?? or not ? */
                break;
 
 #endif      
@@ -588,10 +638,10 @@
        
                /* SLAVE RECEIVER */
 
-       case TW_SR_GCALL_ACK:
-       case TW_SR_SLA_ACK:
        case TW_SR_ARB_LOST_SLA_ACK:
        case TW_SR_ARB_LOST_GCALL_ACK:
+       case TW_SR_GCALL_ACK:
+       case TW_SR_SLA_ACK:
                /* slave is addressed (in general call or not, and
                 * after arbiteration lost or not) */
                g_recv_nbytes = 0;
@@ -637,8 +687,8 @@
       
                /* SLAVE TRANSMITTER */
 
-       case TW_ST_SLA_ACK: 
        case TW_ST_ARB_LOST_SLA_ACK:
+       case TW_ST_SLA_ACK: 
                /* slave is addressed. If it is not ready, send a 0 as
                 * last byte. */
                g_send_nbytes = 0;
@@ -682,16 +732,21 @@
                /* COMMON */
 
        case TW_BUS_ERROR:
-               /* error >> send stop ?? XXX */
+               command |= (1<<TWSTO);
                g_status |= I2C_STATUS_OP_FINISHED;
                break;
     
        default :
                /* default ... what can we do ? */
+               g_status |= I2C_STATUS_OP_FINISHED;
                break;
 
        }
        
+#if I2C_DEBUG == 1
+       g_prev_status = g_status;
+#endif
+
        /* transmission finished */
        if (g_status & I2C_STATUS_OP_FINISHED) {
                /* if it is not a synchronous op, we should be aware
@@ -735,9 +790,13 @@
        }
        g_status &= ~(I2C_STATUS_NEED_XMIT_EVT | I2C_STATUS_NEED_RECV_EVT);
        
+#if I2C_DEBUG == 1
+       g_command = command;
+#endif
+
        /* if a command (repeated start) has been sent in the callback
         * (by calling i2c_send() or i2c_recv(), we don't need to
         * send it (we are back in MASTER_SEND or MASTER_RECV mode) */
-       if (TWCR & TWINT)
+       if (TWCR & (1<<TWINT))
                TWCR = command; 
 }


===============================
aversive/modules/comm/i2c/i2c.h  (1.1.2.7 -> 1.1.2.8)
===============================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: i2c.h,v 1.1.2.7 2007-07-01 15:35:35 zer0 Exp $
+ *  Revision : $Id: i2c.h,v 1.1.2.8 2008-03-27 19:19:33 zer0 Exp $
  *
  */
 
@@ -50,6 +50,7 @@
 #include <aversive.h>
 #include <i2c_config.h>
 
+#define I2C_DEBUG 1
 
 #define I2C_ADD_GENCALL 0x00
 
@@ -241,5 +242,17 @@
  */
 uint8_t i2c_get_recv_buffer(uint8_t *buf, uint8_t size);
 
+/**
+ * recover from error states
+ */
+void i2c_reset(void);
+
+#if I2C_DEBUG == 1
+/**
+ * display debug infos
+ */
+void i2c_debug(void);
+#endif
+
 
 #endif


Commit from zer0 on branch b_zer0 (2008-03-27 20:20 CET)
=================================

new interface for blocking detection

  aversive  
modules/devices/robot/blocking_detection_manager/blocking_detection_manager.c  
1.1.2.2
  aversive  
modules/devices/robot/blocking_detection_manager/blocking_detection_manager.h  
1.1.2.3


======================================================================================
aversive/modules/devices/robot/blocking_detection_manager/blocking_detection_manager.c
  (1.1.2.1 -> 1.1.2.2)
======================================================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: blocking_detection_manager.c,v 1.1.2.1 2007-12-31 16:25:00 
zer0 Exp $
+ *  Revision : $Id: blocking_detection_manager.c,v 1.1.2.2 2008-03-27 19:20:49 
zer0 Exp $
  *
  *  Olivier MATZ <[EMAIL PROTECTED]>
  */
@@ -38,14 +38,30 @@
 }
 
 /* thresholds */
-void bd_set_thresholds(struct blocking_detection * bd, uint32_t speed_thres, 
-                      uint32_t err_thres, uint16_t cpt_thres)
+void bd_set_speed_err_thresholds(struct blocking_detection * bd, uint32_t 
speed_thres, 
+                                uint32_t err_thres, uint16_t cpt_thres)
 {
        uint8_t flags;
        IRQ_LOCK(flags);
        bd->speed_thres = speed_thres;
        bd->err_thres = err_thres;
-       bd->cpt_thres = cpt_thres;
+       bd->cpt1_thres = cpt_thres;
+       bd->cpt1 = 0;
+       IRQ_UNLOCK(flags);
+}
+
+/* thresholds */
+void bd_set_current_thresholds(struct blocking_detection * bd, 
+                              int32_t k1, int32_t k2, 
+                              uint32_t i_thres, uint16_t cpt_thres)
+{
+       uint8_t flags;
+       IRQ_LOCK(flags);
+       bd->k1 = k1;
+       bd->k2 = k2;
+       bd->i_thres = i_thres;
+       bd->cpt2_thres = cpt_thres;
+       bd->cpt2 = 0;
        IRQ_UNLOCK(flags);
 }
 
@@ -54,34 +70,67 @@
 {
        uint8_t flags;
        IRQ_LOCK(flags);
-       bd->cpt = 0;
+       bd->cpt1 = 0;
+       bd->cpt2 = 0;
        IRQ_UNLOCK(flags);
 }
 
 /** function to be called periodically */
 void bd_manage(struct blocking_detection * bd)
 {
-       int32_t err;
+       int32_t err=0;
        int32_t pos;
+       int32_t cmd;
+       int32_t i=0;
+       int32_t speed;
+
+       static uint8_t a=0;
 
-       err = cs_get_error(bd->cs);
        pos = cs_get_filtered_feedback(bd->cs);
+       speed = (pos - bd->prev_pos);
 
-       if ( (ABS(err) > bd->err_thres &&
-             ABS(pos - bd->prev_pos) < bd->speed_thres)) {
+       /* if blocking detection enabled */
+       if ( bd->cpt1_thres ) {
+               err = cs_get_error(bd->cs);
+               if ((ABS(err) > bd->err_thres &&
+                    ABS(speed) < bd->speed_thres)) {
+                       if (bd->cpt1 == bd->cpt1_thres - 1)
+                               DEBUG(E_BLOCKING_DETECTION_MANAGER, 
+                                     "A: err=%ld speed=%ld",
+                                     ABS(err), ABS(speed));
+                       
+                       if(bd->cpt1 < bd->cpt1_thres)
+                               bd->cpt1++;
+               }
+               else {
+                       bd->cpt2=0;
+               }
+       }
 
-               if (bd->cpt == bd->cpt_thres - 1)
-                       DEBUG(E_BLOCKING_DETECTION_MANAGER, "err=%ld speed=%ld",
-                             ABS(err), ABS(pos - bd->prev_pos));
 
-               if(bd->cpt < bd->cpt_thres)
-                       bd->cpt++;
-       }
-       else {
-               bd->cpt=0;
+       /* if current-based blocking_detection enabled */
+       if ( bd->cpt2_thres ) {
+               cmd = cs_get_out(bd->cs);
+               i = bd->k1 * cmd - bd->k2*speed;
+               if (ABS(i) > bd->i_thres) {
+                       if (bd->cpt2 == bd->cpt2_thres - 1)
+                               DEBUG(E_BLOCKING_DETECTION_MANAGER, 
+                                     "A: i=%ld", i);
+                       if(bd->cpt2 < bd->cpt2_thres)
+                               bd->cpt2++;
+               }
+               else {
+                       bd->cpt2=0;
+               }
        }
 
+       if (a++ == 0)
+               DEBUG(E_BLOCKING_DETECTION_MANAGER, 
+                     "test err=%ld speed=%ld i=%ld",
+                     ABS(err), ABS(speed), i);
+
        bd->prev_pos = pos;
+       bd->speed = speed;
 }
 
 /** get value of blocking detection */
@@ -89,7 +138,8 @@
 {
        uint8_t ret, flags;
        IRQ_LOCK(flags);
-       ret = bd->cpt == bd->cpt_thres;
+       ret = (bd->cpt1 && (bd->cpt1 == bd->cpt1_thres)) ||
+               ( bd->cpt2 && (bd->cpt2 == bd->cpt2_thres));
        IRQ_UNLOCK(flags);
        return ret;
 }


======================================================================================
aversive/modules/devices/robot/blocking_detection_manager/blocking_detection_manager.h
  (1.1.2.2 -> 1.1.2.3)
======================================================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: blocking_detection_manager.h,v 1.1.2.2 2008-01-09 22:27:45 
zer0 Exp $
+ *  Revision : $Id: blocking_detection_manager.h,v 1.1.2.3 2008-03-27 19:20:49 
zer0 Exp $
  *
  *  Olivier MATZ <[EMAIL PROTECTED]>
  */
@@ -24,28 +24,50 @@
 
 #include <control_system_manager.h>
 
-/* detect blocking : if the speed is below a threshold and the error
- * is below another threshold during n tests, trigger the blocking
- * detection. */
+/* detect blocking : 
+ * 
+ * 1/ if the speed is below a threshold and the error is above another
+ * threshold during n tests, trigger the blocking detection.
+ *
+ * 2/ based on motor current. if the current in the motor is a above a
+ * threshold suring n tests, trigger the blocking detection.
+ * We suppose that i = k1.V - k2.w
+ * (V is the voltage applied on the motor, and w the current speed 
+ * of the motor)
+ */
 
 struct blocking_detection {
        struct cs *cs;
        uint32_t speed_thres;
        uint32_t err_thres;
-       uint16_t cpt_thres;
+       uint16_t cpt1_thres;
+       uint16_t cpt1;
+
+       uint32_t i_thres;
+       int32_t k1;
+       int32_t k2;
+       uint16_t cpt2_thres;
+       uint16_t cpt2;
+
        int32_t prev_pos;
-       uint16_t cpt;
+       int32_t speed;
 };
 
 /** init module, give the cs as parameter */
 void bd_init(struct blocking_detection * bd, struct cs *cs);
 
 /** thresholds. Be carreful, speed threshold depends on the period of
- *  bd_manage() call */
-void bd_set_thresholds(struct blocking_detection * bd, 
+ *  bd_manage() call. If cpt_thres is 0, disable it. */
+void bd_set_speed_err_thresholds(struct blocking_detection * bd, 
                       uint32_t speed_thres, uint32_t err_thres, uint16_t 
cpt_thres);
 
-/** reset current blocking */
+/* thresholds for current-based blocking detection. If cpt_thres 
+ * is 0, disable it. */
+void bd_set_current_thresholds(struct blocking_detection * bd, 
+                              int32_t k1, int32_t k2, 
+                              uint32_t i_thres, uint16_t cpt_thres);
+
+/** reset the blocking */
 void bd_reset(struct blocking_detection * bd);
 
 /** function to be called periodically */


Commit from zer0 on branch b_zer0 (2008-03-27 20:22 CET)
=================================

add a func trajectory manager turn_to_behind

  aversive  modules/devices/robot/trajectory_manager/trajectory_manager.c  
1.4.4.8
  aversive  modules/devices/robot/trajectory_manager/trajectory_manager.h  
1.4.4.6


======================================================================
aversive/modules/devices/robot/trajectory_manager/trajectory_manager.c  
(1.4.4.7 -> 1.4.4.8)
======================================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: trajectory_manager.c,v 1.4.4.7 2007-12-31 16:25:01 zer0 
Exp $
+ *  Revision : $Id: trajectory_manager.c,v 1.4.4.8 2008-03-27 19:22:19 zer0 
Exp $
  *
  */
 
@@ -302,7 +302,22 @@
 
        traj->state = RUNNING_A;
        DEBUG(E_TRAJECTORY, "Goto Turn To xy %f %f", x_abs_cm, y_abs_cm);
-       __trajectory_goto_d_a_rel(traj, 0, simple_modulo_2pi(atan2(y_abs_cm - 
posy, x_abs_cm - posx) - posa),
+       __trajectory_goto_d_a_rel(traj, 0,
+                       simple_modulo_2pi(atan2(y_abs_cm - posy, x_abs_cm - 
posx) - posa),
+                                 UPDATE_A | UPDATE_D | RESET_D);
+}
+
+/** turn the robot until the point x,y is behind us */ 
+void trajectory_turnto_xy_behind(struct trajectory* traj, double x_abs_cm, 
double y_abs_cm)
+{
+       double posx = position_get_x_double(traj->position); 
+       double posy = position_get_y_double(traj->position);
+       double posa = position_get_a_rad_double(traj->position);
+
+       traj->state = RUNNING_A;
+       DEBUG(E_TRAJECTORY, "Goto Turn To xy %f %f", x_abs_cm, y_abs_cm);
+       __trajectory_goto_d_a_rel(traj, 0, 
+                       modulo_2pi(atan2(y_abs_cm - posy, x_abs_cm - posx) - 
posa + M_PI),
                                  UPDATE_A | UPDATE_D | RESET_D);
 }
 


======================================================================
aversive/modules/devices/robot/trajectory_manager/trajectory_manager.h  
(1.4.4.5 -> 1.4.4.6)
======================================================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: trajectory_manager.h,v 1.4.4.5 2007-12-31 16:25:01 zer0 
Exp $
+ *  Revision : $Id: trajectory_manager.h,v 1.4.4.6 2008-03-27 19:22:19 zer0 
Exp $
  *
  */
 
@@ -124,6 +124,9 @@
 /** turn the robot until the point x,y is in front of us */ 
 void trajectory_turnto_xy(struct trajectory* traj, double x_abs_cm, double 
y_abs_cm);
 
+/** turn the robot until the point x,y is behind us */ 
+void trajectory_turnto_xy_behind(struct trajectory* traj, double x_abs_cm, 
double y_abs_cm);
+
 /** update angle consign without changing distance consign */
 void trajectory_only_a_rel(struct trajectory * traj, double a_deg);
 


Commit from zer0 on branch b_zer0 (2008-03-27 20:22 CET)
=================================

don't forget to put this in config.

  aversive  modules/devices/robot/obstacle_avoidance/obstacle_avoidance.h  
1.1.2.2


======================================================================
aversive/modules/devices/robot/obstacle_avoidance/obstacle_avoidance.h  
(1.1.2.1 -> 1.1.2.2)
======================================================================

@@ -15,12 +15,13 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: obstacle_avoidance.h,v 1.1.2.1 2007-12-31 16:25:00 zer0 
Exp $
+ *  Revision : $Id: obstacle_avoidance.h,v 1.1.2.2 2008-03-27 19:22:43 zer0 
Exp $
  *
  *  Fabrice DESCLAUX <[EMAIL PROTECTED]>
  *  Olivier MATZ <[EMAIL PROTECTED]>
  */
 
+/* XXX this should be set in obstacle_avoidance_config.h !! */
 #define MAX_POLY 3
 #define MAX_PTS 10
 #define MAX_RAYS 100


Commit from zer0 on branch b_zer0 (2008-03-27 20:23 CET)
=================================

Use \r\n instead of \n

  aversive  modules/ihm/rdline/rdline.c  1.1.2.8


====================================
aversive/modules/ihm/rdline/rdline.c  (1.1.2.7 -> 1.1.2.8)
====================================

@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: rdline.c,v 1.1.2.7 2008-01-05 22:46:27 zer0 Exp $
+ *  Revision : $Id: rdline.c,v 1.1.2.8 2008-03-27 19:23:28 zer0 Exp $
  *
  *
  */
@@ -345,12 +345,12 @@
                                }
 
                                /* choice */
-                               rdl->write_char('\n');
+                               rdline_puts_P(rdl, PSTR("\r\n"));
                                while (ret) {
                                        rdl->write_char(' ');
                                        for (i=0 ; tmp_buf[i] ; i++)
                                                rdl->write_char(tmp_buf[i]);
-                                       rdl->write_char('\n');
+                                       rdline_puts_P(rdl, PSTR("\r\n"));
                                        ret = rdl->complete(rdl->left_buf, 
tmp_buf, 
                                                            sizeof(tmp_buf), 
&complete_state);
                                }

_______________________________________________
Avr-list mailing list
Avr-list@droids-corp.org
CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive
WIKI : http://wiki.droids-corp.org/index.php/Aversive
DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/
BUGZILLA : http://bugzilla.droids-corp.org
COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog

Répondre à