]> git.droids-corp.org - aversive.git/commitdiff
optimize xy->corn
authorzer0 <zer0@carbon.local>
Mon, 10 May 2010 16:48:08 +0000 (18:48 +0200)
committerzer0 <zer0@carbon.local>
Mon, 10 May 2010 16:48:08 +0000 (18:48 +0200)
projects/microb2010/mainboard/display.py
projects/microb2010/mainboard/strat.c
projects/microb2010/mainboard/strat_db.c

index 787c1c29ca11462088e5670dc948510866ab9670..583f9a8e05702fd670a13edc622ef64266671f35 100644 (file)
@@ -383,7 +383,7 @@ while True:
                     print "cobboard: %x,%x"%(int(m.groups()[0]),int(m.groups()[1]))
                     side = int(m.groups()[0])
                     flags = int(m.groups()[1])
-                    if side == 0:
+                    if (side == 0 and color == YELLOW) or (side == 1 and color == BLUE):
                         robot_lspickle_deployed = ((flags & 1) * 2)
                         robot_lspickle_autoharvest = ((flags & 2) != 0)
                     else:
index 3e29f3a22385011fa7ffce0d72debdd88db40c47..dd7b23c43cc48be4557e6b8c8171cd29f01afc66 100644 (file)
@@ -808,8 +808,8 @@ uint8_t run_to_the_hills(uint8_t orange_color)
                                    HILL_POSX_BALLS_DOWN3,
                                    TRAJ_FLAGS_SMALL_DIST);
        DEBUG(E_USER_STRAT, "deploy support balls");
-       strat_set_speed(SPEED_DIST_FAST, SPEED_ANGLE_FAST);
        strat_set_acc(ad, aa);
+       strat_set_speed(SPEED_DIST_FAST, SPEED_ANGLE_FAST);
        support_balls_deploy();
        err = wait_traj_end(TRAJ_FLAGS_SMALL_DIST);
        i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
index c3608d640897d5e00cf5db2fa14ce55ac2244235..015379488b6ddfb61899ffb5486da207aae9bc5c 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <aversive.h>
 #include <aversive/pgmspace.h>
+#include <aversive/error.h>
 
 #include <ax12.h>
 #include <uart.h>
@@ -174,7 +175,7 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp)
        x += (STEP_CORN_X/2);
        i = x / STEP_CORN_X;
 
-       y = COLOR_Y(y);
+       y = COLOR_Y(y); /* Y depends on color */
        y -= OFFSET_CORN_Y;
        if ((i & 1) == 1) {
                j = y / STEP_CORN_Y;
@@ -206,8 +207,7 @@ int8_t xycoord_to_ijcoord(int16_t *xp, int16_t *yp, uint8_t *ip, uint8_t *jp)
 
 /******** CORN */
 
-/* return the index of a corn given its i,j coords. */
-int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j)
+static int8_t early_ijcoord_to_corn_idx(uint8_t i, uint8_t j)
 {
        uint8_t n;
        for (n = 0; n < CORN_NB; n ++) {
@@ -218,6 +218,14 @@ int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j)
        return -1;
 }
 
+/* return the index of a corn given its i,j coords. */
+int8_t ijcoord_to_corn_idx(uint8_t i, uint8_t j)
+{
+       if (strat_db.wp_table[i][j].type != WP_TYPE_CORN)
+               return -1;
+       return strat_db.wp_table[i][j].corn.idx;
+}
+
 /* return the i,j coords of a corn given its index */
 int8_t corn_idx_to_ijcoord(uint8_t idx, uint8_t *i, uint8_t *j)
 {
@@ -492,7 +500,7 @@ void strat_db_init(void)
                        }
 
                        /* corn */
-                       idx = ijcoord_to_corn_idx(i, j);
+                       idx = early_ijcoord_to_corn_idx(i, j);
                        if (idx >= 0) {
                                wp->type = WP_TYPE_CORN;
                                wp->present = 1;