if (i >= WAYPOINTS_NBX && j >= WAYPOINTS_NBY)
return -1;
*x = (OFFSET_CORN_X + i*STEP_CORN_X);
- *y = (OFFSET_CORN_Y + j*STEP_CORN_Y);
+ *y = COLOR_Y(OFFSET_CORN_Y + j*STEP_CORN_Y);
return 0;
}
return 0;
}
+#define CORN_MARGIN 200
/* return the index of the closest corn at these coordinates. If the
* corn is really too far (~20cm), return NULL. The x and y pointer are
* updated with the real position of the corn */
for (n = 0; n < CORN_NB; n ++) {
corn_idx_to_xycoord(n, &x_corn, &y_corn);
d = xy_norm(x_corn, y_corn, *x, *y);
- /* XXX 200 -> constant */
- if (d < 200 && (d_min == 0 || d < d_min)) {
+ if (d < CORN_MARGIN && (d_min == 0 || d < d_min)) {
d_min = d;
idx = n;
x_corn_min = x_corn;
wp->corn.color = color;
if (color == I2C_COB_UNKNOWN)
return;
+ if (wp->corn.color != I2C_COB_UNKNOWN)
+ return;
corn_deduct_other(wp->corn.idx, color);
symidx = corn_get_sym_idx(wp->corn.idx);
strat_db.corn_table[symidx]->corn.color = color;
return 0;
}
+#define TOMATO_MARGIN 200
/* return the index of the closest tomato at these coordinates. If the
* tomato is really too far (~20cm), return NULL. The x and y pointer are
* updated with the real position of the tomato */
for (n = 0; n < TOMATO_NB; n ++) {
tomato_idx_to_xycoord(n, &x_tomato, &y_tomato);
d = xy_norm(x_tomato, y_tomato, *x, *y);
- /* XXX 200 -> constant */
- if (d < 200 && (d_min == 0 || d < d_min)) {
+ if (d < TOMATO_MARGIN && (d_min == 0 || d < d_min)) {
d_min = d;
idx = n;
x_tomato_min = x_tomato;