#define FORKROT_DEPLOYED -55000
#define FORKROT_MID -33000
-#define FORKROT_PACKED 0
+#define FORKROT_PACKED -4000
void roller_on(void)
{
bd_init(&ballboard.roller.bd);
#define ROLLER_SPEED_THRES (ROLLER_SPEED * 0.75)
bd_set_speed_threshold(&ballboard.roller.bd, ROLLER_SPEED_THRES);
- bd_set_current_thresholds(&ballboard.roller.bd, 500, 1500, 1000000, 20);
+ bd_set_current_thresholds(&ballboard.roller.bd, 500, 1500, 1200000, 70);
/* ---- CS forktrans */
/* PID */
}
/* timeout */
- if ((time_get_us2() - us) > 1000UL * 1000UL) {
+ if ((time_get_us2() - us) > 2000UL * 1000UL) {
STMCH_DEBUG("%s(): eject timeout", __FUNCTION__);
blocked = 1;
break;
&cobboard.right_spickle,
},
.pos_deployed = {
- 500,// 7000, // 200, /* left */
- 500,// 7000, // 200, /* right */
+ 7000, // 200, /* left */
+ 7000, // 200, /* right */
},
.pos_mid = {
25000, /* left */
shovel_down();
time_wait_ms(250);
shovel_up();
+ /* if eject command is received, force exit */
+ if (EJECT(state_mode))
+ return;
}
state_debug_wait_key_pressed();
#include "main.h"
#include "strat_utils.h"
-#define BEACON_UART_NUM 0
+#define BEACON_UART_NUM 2
#define INIT 0
#define OPP0 1
#define STA4 9
#define STA5 10
+#define BEACON_ANGLE_OFFSET 449
+
static volatile uint8_t opp_age = 0;
static volatile int16_t opp_a = I2C_OPPONENT_NOT_THERE;
static volatile int16_t opp_d = I2C_OPPONENT_NOT_THERE;
static volatile int16_t pos_y = I2C_BEACON_NOT_FOUND;
static volatile int16_t pos_a = I2C_BEACON_NOT_FOUND;
-#define BEACON_OFFSET (-50.)
+#define BEACON_POS_OFFSET (-50.)
int8_t beacon_get_pos_double(double *x, double *y, double *a_rad)
{
uint8_t flags;
dtmpy = tmpy;
dtmpa = RAD((double)tmpa / 10.);
- dtmpx += cos(dtmpa) * BEACON_OFFSET;
- dtmpx += sin(dtmpa) * BEACON_OFFSET;
+ dtmpx += cos(dtmpa) * BEACON_POS_OFFSET;
+ dtmpx += sin(dtmpa) * BEACON_POS_OFFSET;
*x = dtmpx;
*y = dtmpy;
/* if beacon is too old, remove it */
IRQ_LOCK(flags);
- if (opp_age < 3)
+ if (opp_age < 50)
opp_age ++;
else {
beaconboard.oppx = I2C_OPPONENT_NOT_THERE;
id = opp_d;
IRQ_UNLOCK(flags);
+ ia = (ia + BEACON_ANGLE_OFFSET);
+ if (ia > 3600)
+ ia -= 3600;
fa = ia;
fa = RAD(fa);
fd = id;
IRQ_LOCK(flags);
beaconboard.oppx = ix;
beaconboard.oppy = iy;
- beaconboard.oppa = ia;
+ beaconboard.oppa = ia / 10;
beaconboard.oppd = id;
IRQ_UNLOCK(flags);
#endif
* and diameter: 55mm -> perimeter 134mm
* dist_imp_mm = 4096/134 x 10 -> 304 */
/* increase it to go further */
-#define IMP_ENCODERS 1024
+#define IMP_ENCODERS 1000
#define WHEEL_DIAMETER_MM 42.9
#define WHEEL_PERIM_MM (WHEEL_DIAMETER_MM * M_PI)
#define IMP_COEF 10.
/* ball ejection */
if (get_ball_count() > 0) {
i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_EJECT);
+ time_wait_ms(300);
trajectory_a_abs(&mainboard.traj, COLOR_A(70));
err = wait_traj_end(TRAJ_FLAGS_NO_NEAR);
if (!TRAJ_SUCCESS(err))
2000);
#endif
}
+ else {
+ /* to pack spickles */
+ time_wait_ms(300);
+ }
if (get_cob_count() > 0) {
/* half turn */
strat_hardstop();
i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_TAKE_FORK);
- time_wait_ms(1800);
+ time_wait_ms(1100);
+
+ trajectory_d_rel(&mainboard.traj, 15);
+ time_wait_ms(400);
+ strat_hardstop();
+ time_wait_ms(200);
/* reach top, go down */
trajectory_d_rel(&mainboard.traj, -HILL_LEN);
y_rel = sin(RAD(opp_a)) * (double)opp_d;
/* opponent too far */
- if (opp_d > 500)
+ if (opp_d > 650)
return 0;
/* opponent is in front of us */
- if (mainboard.speed_d > 0 && (opp_a > 325 || opp_a < 35)) {
+ 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))) {
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);
return 1;
}
/* opponent is behind us */
- if (mainboard.speed_d < 0 && (opp_a < 215 && opp_a > 145)) {
+ 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))) {
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();
#define UART_CONFIG_H\r
\r
/*\r
- * UART0 definitions\r
+ * UART2 definitions\r
*/\r
\r
-/* compile uart0 fonctions, undefine it to pass compilation */\r
-#define UART0_COMPILE\r
+/* compile uart2 fonctions, undefine it to pass compilation */\r
+#define UART2_COMPILE\r
\r
-/* enable uart0 if == 1, disable if == 0 */\r
-#define UART0_ENABLED 1\r
+/* enable uart2 if == 1, disable if == 0 */\r
+#define UART2_ENABLED 1\r
\r
-/* enable uart0 interrupts if == 1, disable if == 0 */\r
-#define UART0_INTERRUPT_ENABLED 1\r
+/* enable uart2 interrupts if == 1, disable if == 0 */\r
+#define UART2_INTERRUPT_ENABLED 1\r
\r
-#define UART0_BAUDRATE 57600\r
+#define UART2_BAUDRATE 57600\r
\r
/*\r
* if you enable this, the maximum baudrate you can reach is\r
* higher, but the precision is lower.\r
*/\r
-#define UART0_USE_DOUBLE_SPEED 1\r
+#define UART2_USE_DOUBLE_SPEED 1\r
\r
-#define UART0_RX_FIFO_SIZE 64\r
-#define UART0_TX_FIFO_SIZE 64\r
-#define UART0_NBITS 8\r
+#define UART2_RX_FIFO_SIZE 64\r
+#define UART2_TX_FIFO_SIZE 64\r
+#define UART2_NBITS 8\r
\r
-#define UART0_PARITY UART_PARTITY_NONE\r
+#define UART2_PARITY UART_PARTITY_NONE\r
\r
-#define UART0_STOP_BIT UART_STOP_BITS_1\r
+#define UART2_STOP_BIT UART_STOP_BITS_1\r
\r
/*\r
* UART1 definitions\r