]> git.droids-corp.org - aversive.git/commitdiff
reliability
authorzer0 <zer0@carbon.local>
Thu, 13 May 2010 13:39:23 +0000 (15:39 +0200)
committerzer0 <zer0@carbon.local>
Thu, 13 May 2010 13:39:23 +0000 (15:39 +0200)
projects/microb2010/ballboard/i2c_protocol.c
projects/microb2010/cobboard/actuator.c
projects/microb2010/cobboard/shovel.c
projects/microb2010/common/i2c_commands.h
projects/microb2010/mainboard/cs.c
projects/microb2010/mainboard/i2c_protocol.c
projects/microb2010/mainboard/main.h
projects/microb2010/mainboard/robotsim.c
projects/microb2010/mainboard/strat_base.c

index 8f0242d0bdb682108f42a788d71ebcb0df82a0d2..71ac5166a925f93842cc8815d489eb3298203364 100644 (file)
@@ -161,6 +161,10 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                        if (size != sizeof (*cmd))
                                goto error;
 
+                       beacon.robot_x = cmd->x;
+                       beacon.robot_y = cmd->y;
+                       beacon.robot_angle = cmd->a;
+
                        i2c_send_status();
                        break;
                }
index bf979468656004030986d2f4a285e54af9099af3..85b2ac14aa1a57972882b09ab591346a4faf0877 100644 (file)
@@ -45,7 +45,7 @@
 #include "main.h"
 #include "actuator.h"
 
-#define COBROLLER_SPEED 1000
+#define COBROLLER_SPEED 666
 
 #define SERVO_DOOR_OPEN 300
 #define SERVO_DOOR_CLOSED 525
index 1f38e1a313aeb8c1590adddd3dc46353e72677bb..8714367decc766ba438a7a2b1ce722e413a83a20 100644 (file)
@@ -45,7 +45,7 @@
 
 #define SHOVEL_DOWN 100
 #define SHOVEL_MID  4500
-#define SHOVEL_UP   11000
+#define SHOVEL_UP   11300
 #define SHOVEL_KICKSTAND_UP   12800
 #define SHOVEL_KICKSTAND_DOWN 10000
 
index 9882ba645d6975141657fad88429ffaa95c50e18..1168100f4cd81802e5a2c10e8fdb07c2ebc2a742 100644 (file)
@@ -150,6 +150,11 @@ struct i2c_ans_cobboard_status {
 
 struct i2c_req_ballboard_status {
        struct i2c_cmd_hdr hdr;
+
+       /* position sent by mainboard */
+       int16_t x;
+       int16_t y;
+       int16_t a;
 };
 
 #define I2C_ANS_BALLBOARD_STATUS 0x83
index 070046955e7d2dbcbbf6860a549ca905ee209cd3..fbb28d9004d1adf97f1b686d48a5b0576ba81dd1 100644 (file)
@@ -212,9 +212,9 @@ void microb_cs_init(void)
                                 RIGHT_ENCODER, IMP_COEF * 1.);
 #else
        rs_set_left_ext_encoder(&mainboard.rs, encoders_spi_get_value,
-                               LEFT_ENCODER, IMP_COEF * -1.011718);
+                               LEFT_ENCODER, IMP_COEF * -1.012729);
        rs_set_right_ext_encoder(&mainboard.rs, encoders_spi_get_value,
-                                RIGHT_ENCODER, IMP_COEF * 1.012695);
+                                RIGHT_ENCODER, IMP_COEF * 1.01370769);
 #endif
        /* rs will use external encoders */
        rs_set_flags(&mainboard.rs, RS_USE_EXT);
index 2c2741090a256ee2026300063d5d0db2b7fab8fa..49b707bdca892570d373d85eddd7330f0717a815 100644 (file)
@@ -379,6 +379,10 @@ static int8_t i2c_req_ballboard_status(void)
        struct i2c_req_ballboard_status buf;
 
        buf.hdr.cmd = I2C_REQ_BALLBOARD_STATUS;
+       /* robot position */
+       buf.x = position_get_x_s16(&mainboard.pos);
+       buf.y = position_get_y_s16(&mainboard.pos);
+       buf.a = position_get_a_deg_s16(&mainboard.pos);
        return i2c_send(I2C_BALLBOARD_ADDR, (uint8_t*)&buf,
                        sizeof(buf), I2C_CTRL_GENERIC);
 }
index 2fe71997a0264a5085d31fe40351235db195ea73..abe92f23503f9b84a203322e393a7548c68dc9cf 100755 (executable)
@@ -76,7 +76,7 @@
 #define MATCH_TIME 89
 
 /* decrease track to decrease angle */
-#define EXT_TRACK_MM 304.61875
+#define EXT_TRACK_MM 305.1097108
 #define VIRTUAL_TRACK_MM EXT_TRACK_MM
 
 #define ROBOT_HALF_LENGTH_FRONT 130
index df8ee0ebcc2c9dac32903b6aea6c2fd47953b214..bf4b731aff49064d5ecd23c068cd525fb2ae6a01 100644 (file)
@@ -196,6 +196,27 @@ robotsim_i2c(uint8_t addr, uint8_t *buf, uint8_t size)
        return 0;
 }
 
+static void beacon_update(void)
+{
+       uint8_t flags;
+       int16_t oppx, oppy;
+       double oppa, oppd;
+
+       IRQ_LOCK(flags);
+       if (ballboard.opponent_x == I2C_OPPONENT_NOT_THERE) {
+               IRQ_UNLOCK(flags);
+               return;
+       }
+       oppx = ballboard.opponent_x;
+       oppy = ballboard.opponent_y;
+       abs_xy_to_rel_da(oppx, oppy, &oppd, &oppa);
+       ballboard.opponent_a = DEG(oppa);
+       if (ballboard.opponent_a < 0)
+               ballboard.opponent_a += 360;
+       ballboard.opponent_d = oppd;
+       IRQ_UNLOCK(flags);
+}
+
 /* must be called periodically */
 void robotsim_update(void)
 {
@@ -220,6 +241,8 @@ void robotsim_update(void)
        int oppx, oppy;
        double oppa, oppd;
 
+       beacon_update();
+
        /* time shift the command */
        l_pwm_shift[i] = l_pwm;
        r_pwm_shift[i] = r_pwm;
@@ -245,12 +268,12 @@ void robotsim_update(void)
                if (sscanf(cmd, "opp %d %d", &oppx, &oppy) == 2) {
                        abs_xy_to_rel_da(oppx, oppy, &oppd, &oppa);
                        IRQ_LOCK(flags);
-                       beaconboard.oppx = oppx;
-                       beaconboard.oppy = oppy;
-                       beaconboard.oppa = DEG(oppa);
-                       if (beaconboard.oppa < 0)
-                               beaconboard.oppa += 360;
-                       beaconboard.oppd = oppd;
+                       ballboard.opponent_x = oppx;
+                       ballboard.opponent_y = oppy;
+                       ballboard.opponent_a = DEG(oppa);
+                       if (ballboard.opponent_a < 0)
+                               ballboard.opponent_a += 360;
+                       ballboard.opponent_d = oppd;
                        IRQ_UNLOCK(flags);
                }
        }
index 023db360331a0ca02404d981d79deda7947e034f..0b14384f840dc78a1acbd83b88548274333d1661 100644 (file)
@@ -382,6 +382,8 @@ void strat_start(void)
        strat_exit();
 }
 
+uint8_t xxxdebug = 0;
+
 /* return true if we have to brake due to an obstacle */
 uint8_t strat_obstacle(void)
 {
@@ -389,12 +391,25 @@ uint8_t strat_obstacle(void)
        int16_t opp_x, opp_y, opp_d, opp_a;
 
        /* too slow */
-       if (ABS(mainboard.speed_d) < 150)
+       if (ABS(mainboard.speed_d) < 0) {
+               if (xxxdebug != 1) {
+                       DEBUG(E_USER_STRAT, "XXX too slow");
+                       xxxdebug = 1;
+               }
                return 0;
+       }
 
        /* no opponent detected */
-       if (get_opponent_xyda(&opp_x, &opp_y, &opp_d, &opp_a))
+       if (get_opponent_xyda(&opp_x, &opp_y, &opp_d, &opp_a)) {
+               if (xxxdebug != 2) {
+                       DEBUG(E_USER_STRAT, "XXX no opp");
+                       DEBUG(E_USER_STRAT, "opponent d=%d, a=%d "
+                             "x=%d y=%d (speed_d=%d)",
+                             opp_d, opp_a, opp_x, opp_y, mainboard.speed_d);
+                       xxxdebug = 2;
+               }
                return 0;
+       }
 
        /* save obstacle position */
        opponent_obstacle.x = opp_x;
@@ -402,24 +417,48 @@ uint8_t strat_obstacle(void)
        opponent_obstacle.d = opp_d;
        opponent_obstacle.a = opp_a;
 
-       if (!is_in_area(opp_x, opp_y, 250))
+       if (!is_in_area(opp_x, opp_y, 250)) {
+               if (xxxdebug != 3) {
+                       DEBUG(E_USER_STRAT, "XXX not in area");
+                       DEBUG(E_USER_STRAT, "opponent d=%d, a=%d "
+                             "x=%d y=%d (speed_d=%d)",
+                             opp_d, opp_a, opp_x, opp_y, mainboard.speed_d);
+                       xxxdebug = 3;
+               }
                return 0;
+       }
 
        /* sensor are temporarily disabled */
-       if (sensor_obstacle_is_disabled())
+       if (sensor_obstacle_is_disabled()) {
+               if (xxxdebug != 4) {
+                       DEBUG(E_USER_STRAT, "XXX disabled");
+                       DEBUG(E_USER_STRAT, "opponent d=%d, a=%d "
+                             "x=%d y=%d (speed_d=%d)",
+                             opp_d, opp_a, opp_x, opp_y, mainboard.speed_d);
+                       xxxdebug = 4;
+               }
                return 0;
+       }
 
        /* relative position */
        x_rel = cos(RAD(opp_a)) * (double)opp_d;
        y_rel = sin(RAD(opp_a)) * (double)opp_d;
 
        /* opponent too far */
-       if (opp_d > 650)
+       if (opp_d > 650) {
+               if (xxxdebug != 5) {
+                       DEBUG(E_USER_STRAT, "XXX too far");
+                       DEBUG(E_USER_STRAT, "opponent d=%d, a=%d "
+                             "x=%d y=%d (speed_d=%d)",
+                             opp_d, opp_a, opp_x, opp_y, mainboard.speed_d);
+                       xxxdebug = 5;
+               }
                return 0;
+       }
 
        /* opponent is in front of us */
-       if ((mainboard.speed_d > 0 && opp_d < 500 && (opp_a > 325 || opp_a < 35)) &&
-           (mainboard.speed_d > 0 && opp_d < 650 && (opp_a > 340 || opp_a < 20))) {
+       if ((mainboard.speed_d >= 0 && opp_d < 500 && (opp_a > 315 || opp_a < 45)) ||
+           (mainboard.speed_d >= 0 && opp_d < 650 && (opp_a > 330 || opp_a < 30))) {
                DEBUG(E_USER_STRAT, "opponent front d=%d, a=%d "
                      "xrel=%d yrel=%d (speed_d=%d)",
                      opp_d, opp_a, x_rel, y_rel, mainboard.speed_d);
@@ -427,14 +466,22 @@ uint8_t strat_obstacle(void)
                return 1;
        }
        /* opponent is behind us */
-       if ((mainboard.speed_d < 0 && opp_d < 500 && (opp_a < 215 && opp_a > 145)) &&
-           (mainboard.speed_d < 0 && opp_d < 650 && (opp_a < 200 && opp_a > 160))) {
+       if ((mainboard.speed_d < 0 && opp_d < 500 && (opp_a < 225 && opp_a > 135)) ||
+           (mainboard.speed_d < 0 && opp_d < 650 && (opp_a < 210 && opp_a > 150))) {
                DEBUG(E_USER_STRAT, "opponent behind d=%d, a=%d xrel=%d yrel=%d",
                      opp_d, opp_a, x_rel, y_rel);
                sensor_obstacle_disable();
                return 1;
        }
 
+       if (xxxdebug != 6) {
+               DEBUG(E_USER_STRAT, "XXX not in cone");
+               DEBUG(E_USER_STRAT, "opponent d=%d, a=%d "
+                     "x=%d y=%d (speed_d=%d)",
+                     opp_d, opp_a, opp_x, opp_y, mainboard.speed_d);
+               xxxdebug = 6;
+       }
+
        return 0;
 }