X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat_corn.c;h=c5f05236079d611cd46f003d5fe514d476258840;hp=1f5e1d347c4868af3093b634cb242ef842498480;hb=cc67fe587de07a329525c8f5c8ecfd1fabbf83b8;hpb=876789a372da2e93a816428649e511c2ad9e40be diff --git a/projects/microb2010/mainboard/strat_corn.c b/projects/microb2010/mainboard/strat_corn.c index 1f5e1d3..c5f0523 100644 --- a/projects/microb2010/mainboard/strat_corn.c +++ b/projects/microb2010/mainboard/strat_corn.c @@ -168,15 +168,23 @@ static uint8_t clitoid_select_speed(uint8_t num1, uint8_t dir1, return 1; } -/* if (time_get_s() > 39) */ -/* DEBUG(E_USER_STRAT, "i,j = (%d %d), count=%d", i, j, corn_count_neigh(i, j)); */ +/* if (time_get_s() > 32) */ +/* DEBUG(E_USER_STRAT, "i,j = (%d %d), count=%d", i, j, */ +/* corn_count_neigh(i, j)); */ if (corn_count_neigh(i, j) == 2) return 1; + /* we are on intersection, let's go slow... but as we enter in + * the curve-part of the clitoid, we should not go there */ if (wp_belongs_to_line(i, j, num2, dir2)) return 0; + /* we can ge fast if it's a 60deg angle and if we checked the + * current point */ + if (is_60deg(dir1, dir2)) + return 0; + /* get next point */ if (wp_get_neigh(i, j, &i2, &j2, dir1) < 0) { DEBUG(E_USER_STRAT, "%s(): cannot get neigh1", @@ -184,7 +192,7 @@ static uint8_t clitoid_select_speed(uint8_t num1, uint8_t dir1, return 1; } - /* if (i2, j2) belongs to next line, check corn in opposition */ + /* if (i2, j2) belongs to next line, check corns */ if (wp_belongs_to_line(i2, j2, num2, dir2)) { if (corn_count_neigh(i2, j2) > 0) return 1; @@ -199,7 +207,7 @@ static uint8_t clitoid_select_speed(uint8_t num1, uint8_t dir1, return 1; } - /* if (i3, j3) belongs to next line, check corn in opposition */ + /* if (i3, j3) belongs to next line, check corns */ if (wp_belongs_to_line(i3, j3, num2, dir2)) { if (corn_count_neigh(i2, j2) > 0 || corn_count_neigh(i3, j3) > 0) @@ -316,15 +324,14 @@ static int8_t strat_calc_clitoid(uint8_t num1, uint8_t dir1, clitoid_slow = clitoid_select_speed(num1, dir1, num2, dir2); if (clitoid_slow) { - DEBUG(E_USER_STRAT, "slow clito\n"); + DEBUG(E_USER_STRAT, "slow clito"); strat_set_speed(SPEED_CLITOID_SLOW, SPEED_ANGLE_SLOW); } else { - DEBUG(E_USER_STRAT, "fast clito\n"); + DEBUG(E_USER_STRAT, "fast clito"); strat_set_speed(SPEED_CLITOID_FAST, SPEED_ANGLE_SLOW); } - /* XXX check return value !! */ ret = trajectory_clitoid(&mainboard.traj, l1.p1.x, l1.p1.y, line1_a_deg, 150., diff_a_deg, beta_deg, radius, xy_norm(l1.p1.x, l1.p1.y, @@ -342,8 +349,10 @@ uint8_t line2line(uint8_t num1, uint8_t dir1, uint8_t num2, reprocess: ret = strat_calc_clitoid(num1, dir1, num2, dir2, &pack_spickles); - if (ret < 0) + if (ret < 0) { DEBUG(E_USER_STRAT, "clitoid failed"); + return END_ERROR; + } /* XXX what to do if cobboard is stucked */ @@ -352,8 +361,13 @@ uint8_t line2line(uint8_t num1, uint8_t dir1, uint8_t num2, num2, dir2), flags); + /* error during traj, or traj finished */ + if (err != 0) + return err; + /* the speed has to change */ - if (trajectory_get_state(&mainboard.traj) != RUNNING_CLITOID_CURVE) + if (err == 0 && + trajectory_get_state(&mainboard.traj) != RUNNING_CLITOID_CURVE) goto reprocess; DEBUG(E_USER_STRAT, "clitoid started err=%d pack_spickles=%d", @@ -371,13 +385,7 @@ uint8_t line2line(uint8_t num1, uint8_t dir1, uint8_t num2, err = wait_traj_end(flags); } - DEBUG(E_USER_STRAT, "clitoid finished"); - - /* XXX 600 -> cste */ - /* XXX does not work, do better */ -/* if (err == 0 && d_speed < 600 && */ -/* mainboard.traj.state == RUNNING_CLITOID_LINE) */ -/* strat_set_speed(600, SPEED_ANGLE_FAST); */ + DEBUG(E_USER_STRAT, "clitoid finished, err=%d", err); strat_rpack60 = 0; strat_lpack60 = 0;