#define COBROLLER_SPEED 1000
#define SERVO_DOOR_OPEN 300
-#define SERVO_DOOR_CLOSED 530
-#define SERVO_DOOR_BLOCK 530
+#define SERVO_DOOR_CLOSED 525
+#define SERVO_DOOR_BLOCK 525
#define SERVO_CARRY_L_OPEN 295
#define SERVO_CARRY_L_CLOSED 430 //400
* CAP 1,5,6,7,8 (notation elec)
*/
static struct sensor_filter sensor_filter[SENSOR_MAX] = {
- [S_COB_INSIDE_L] = { 5, 0, 4, 1, 0, 1 }, /* 0 */
+ [S_COB_INSIDE_R] = { 5, 0, 4, 1, 0, 1 }, /* 0 */
[S_CAP2] = { 10, 0, 3, 7, 0, 0 }, /* 1 */
- [S_COB_INSIDE_R] = { 5, 0, 4, 1, 0, 0 }, /* 2 */
+ [S_COB_INSIDE_L] = { 5, 0, 4, 1, 0, 0 }, /* 2 */
[S_CAP4] = { 1, 0, 0, 1, 0, 0 }, /* 3 */
[S_LCOB] = { 1, 0, 0, 1, 0, 1 }, /* 4 */
[S_CAP6] = { 5, 0, 4, 1, 0, 0 }, /* 5 */
#define ADC_MAX 4
/* synchronize with sensor.c */
-#define S_COB_INSIDE_L 0
+#define S_COB_INSIDE_R 0
#define S_CAP2 1
-#define S_COB_INSIDE_R 2
+#define S_COB_INSIDE_L 2
#define S_CAP4 3
#define S_LCOB 4
#define S_CAP6 5
#include "shovel.h"
#define SHOVEL_DOWN 100
-#define SHOVEL_MID 4500
+#define SHOVEL_MID 5250
#define SHOVEL_UP 11000
/* init spickle position at beginning */
&cobboard.right_spickle,
},
.pos_deployed = {
- 7000, // 200, /* left */
- 7000, // 200, /* right */
+ 500,// 7000, // 200, /* left */
+ 500,// 7000, // 200, /* right */
},
.pos_mid = {
25000, /* left */
interrupt_traj_reset();
strat_get_speed(&old_spdd, &old_spda);
strat_set_speed(AUTOPOS_SPEED_FAST, AUTOPOS_SPEED_FAST);
+ strat_set_acc(3, 3);
err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING);
if (err == END_INTR)
COLOR_A(-90));
strat_hardstop();
- trajectory_d_rel(&mainboard.traj, -180);
+ trajectory_d_rel(&mainboard.traj, -70);
err = wait_traj_end(END_INTR|END_TRAJ);
if (err == END_INTR)
goto intr;
+ time_wait_ms(250);
trajectory_a_rel(&mainboard.traj, COLOR_A(-90));
err = wait_traj_end(END_INTR|END_TRAJ);
if (err == END_INTR)
goto intr;
+ time_wait_ms(250);
err = strat_calib(300, END_INTR|END_TRAJ|END_BLOCKING);
if (err == END_INTR)
goto intr;
180);
strat_hardstop();
- trajectory_d_rel(&mainboard.traj, -170);
+ trajectory_d_rel(&mainboard.traj, -80);
err = wait_traj_end(END_INTR|END_TRAJ);
if (err == END_INTR)
goto intr;
- wait_ms(100);
+ time_wait_ms(250);
- trajectory_a_rel(&mainboard.traj, COLOR_A(-110));
+ trajectory_a_rel(&mainboard.traj, COLOR_A(-135));
err = wait_traj_end(END_INTR|END_TRAJ);
if (err == END_INTR)
goto intr;
- wait_ms(100);
+ time_wait_ms(250);
strat_set_speed(old_spdd, old_spda);
return;
}
#endif
-#ifndef HOST_VERSION
-#define DEBUG_CPLD
-#endif
-
-#ifdef DEBUG_CPLD
-extern int16_t g_encoders_spi_previous[4];
-static int32_t ll_prev, rr_prev;
-#endif
-
/* called every 5 ms */
static void do_cs(void *dummy)
{
#ifdef HOST_VERSION
robotsim_update();
#else
-#ifdef DEBUG_CPLD
- int32_t ll, rr;
-#endif
/* read encoders */
if (mainboard.flags & DO_ENCODERS) {
encoders_spi_manage(NULL);
}
-#ifdef DEBUG_CPLD
- ll = encoders_spi_get_value(LEFT_ENCODER);
- rr = encoders_spi_get_value(RIGHT_ENCODER);
- if ((ll - ll_prev > 3000) || (ll - ll_prev < -3000) ||
- (rr - rr_prev > 3000) || (rr - rr_prev < -3000)) {
- printf_P(PSTR("/ %d %d %d %d\r\n"),
- g_encoders_spi_previous[0],
- g_encoders_spi_previous[1],
- g_encoders_spi_previous[2],
- g_encoders_spi_previous[3]);
- BRAKE_ON();
- while (1);
- }
- ll_prev = ll;
- rr_prev = rr;
-#endif
#endif
/* robot system, conversion to angle,distance */
bd_manage_from_cs(&mainboard.left_cobroller.bd, &mainboard.left_cobroller.cs);
bd_manage_from_cs(&mainboard.right_cobroller.bd, &mainboard.right_cobroller.cs);
if (mainboard.flags & DO_ERRBLOCKING) {
- if (bd_get(&mainboard.left_cobroller.bd) ||
- bd_get(&mainboard.left_cobroller.bd)) {
- printf_P(PSTR("MOTOR BLOCKED STOP ALL\r\n"));
- mainboard.flags &= ~(DO_POWER | DO_ERRBLOCKING);
- }
+/* if (bd_get(&mainboard.left_cobroller.bd) || */
+/* bd_get(&mainboard.left_cobroller.bd)) { */
+/* printf_P(PSTR("MOTOR BLOCKED STOP ALL\r\n")); */
+/* mainboard.flags &= ~(DO_POWER | DO_ERRBLOCKING); */
+/* } */
}
#endif
}
#ifdef HOST_VERSION
if ((cpt & 7) == 0) {
- // dump_cs("dist", &mainboard.distance.cs);
robotsim_dump();
}
#endif
position_init(&mainboard.pos);
position_set_physical_params(&mainboard.pos, VIRTUAL_TRACK_MM, DIST_IMP_MM);
position_set_related_robot_system(&mainboard.pos, &mainboard.rs);
- position_set_centrifugal_coef(&mainboard.pos, 0.000025);
+ //position_set_centrifugal_coef(&mainboard.pos, 0.000025);
position_use_ext(&mainboard.pos);
/* TRAJECTORY MANAGER */
mainboard.left_cobroller.on = 1;
mainboard.right_cobroller.on = 1;
-#ifdef DEBUG_CPLD
- ll_prev = encoders_spi_get_value(LEFT_ENCODER);
- rr_prev = encoders_spi_get_value(RIGHT_ENCODER);
-#endif
-
scheduler_add_periodical_event_priority(do_cs, NULL,
5000L / SCHEDULER_UNIT,
CS_PRIO);
ROBOT_HEIGHT=5 # 350
CORN_HEIGHT=5 # 150
+ROBOT_WIDTH=320
+ROBOT_LENGTH=360
+
area = [ (0.0, 0.0, -0.2), (3000.0, 2100.0, 0.2) ]
areasize = reduce(lambda x,y:tuple([abs(x[i])+abs(y[i]) for i in range(len(x))]) , area)
area_box = box(size=areasize, color=(0.0, 1.0, 0.0))
0)
robot.axis = axis
- robot.size = (250, 320, ROBOT_HEIGHT)
+ robot.size = (ROBOT_LENGTH, ROBOT_WIDTH, ROBOT_HEIGHT)
robot_lspickle = 2 # XXX
lspickle.pos = (tmp_x + (robot_lspickle*60) * math.cos((tmp_a+90)*math.pi/180),
tmp_y + (robot_lspickle*60) * math.sin((tmp_a+90)*math.pi/180),
ROBOT_HEIGHT/2)
lspickle.axis = axis
- lspickle.size = (20, 320, 5)
+ lspickle.size = (20, ROBOT_WIDTH, 5)
robot_rspickle = 2 # XXX
rspickle.pos = (tmp_x + (robot_rspickle*60) * math.cos((tmp_a-90)*math.pi/180),
tmp_y + (robot_rspickle*60) * math.sin((tmp_a-90)*math.pi/180),
ROBOT_HEIGHT/2)
rspickle.axis = axis
- rspickle.size = (20, 320, 5)
+ rspickle.size = (20, ROBOT_WIDTH, 5)
# save position
save_pos.append((robot.pos.x, robot.pos.y, tmp_a))
# parse cobboard
if not m:
- m = re.match("cobboard=%s"%(INT), l)
+ m = re.match("cobboard=%s,%s"%(INT,INT), l)
if m:
- mode = int(m.groups()[0])
- if (mode & 0x01) == 0:
- robot_lspickle = 0
- elif (mode & 0x02) == 0:
- robot_lspickle = 1
- else:
- robot_lspickle = 2
- if (mode & 0x04) == 0:
- robot_rspickle = 0
- elif (mode & 0x08) == 0:
- robot_rspickle = 1
+ 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 (flags & 0x01) == 0:
+ robot_lspickle = 1
+ else:
+ robot_lspickle = 2
else:
- robot_rspickle = 2
+ if (flags & 0x01) == 0:
+ robot_rspickle = 1
+ else:
+ robot_rspickle = 2
if scene.kb.keys == 0:
continue
int8_t i2c_cobboard_set_mode(uint8_t mode)
{
#ifdef HOST_VERSION
- return robotsim_i2c_cobboard_set_mode(mode);
+ cobboard.mode = mode;
+ return 0;
#else
struct i2c_cmd_cobboard_set_mode buf;
buf.hdr.cmd = I2C_CMD_COBBOARD_SET_MODE;
static int8_t i2c_cobboard_set_spickle(uint8_t side, uint8_t flags)
{
+#ifdef HOST_VERSION
+ return robotsim_i2c_cobboard_set_spickles(side, flags);
+#else
if (side == I2C_LEFT_SIDE)
cobboard.lspickle = flags;
else
cobboard.rspickle = flags;
return 0;
+#endif
}
int8_t i2c_cobboard_pack(uint8_t side)
#define MATCH_TIME 89
/* decrease track to decrease angle */
-#define EXT_TRACK_MM 304.61875
+#define EXT_TRACK_MM 304.9
#define VIRTUAL_TRACK_MM EXT_TRACK_MM
-#define ROBOT_HALF_LENGTH_FRONT 130
-#define ROBOT_HALF_LENGTH_REAR 120
+#define ROBOT_HALF_LENGTH_FRONT 180
+#define ROBOT_HALF_LENGTH_REAR 70
#define ROBOT_WIDTH 320
/* it is a 1024 imps -> 4096 because we see 1/4 period
}
int8_t
-robotsim_i2c_cobboard_set_mode(uint8_t mode)
+robotsim_i2c_cobboard_set_spickles(uint8_t side, uint8_t flags)
{
char buf[BUFSIZ];
int len;
- if (cobboard.mode == mode)
- return 0;
+ if (side == I2C_LEFT_SIDE) {
+ if (cobboard.lspickle == flags)
+ return 0;
+ else
+ cobboard.lspickle = flags;
+ }
+ if (side == I2C_RIGHT_SIDE) {
+ if (cobboard.rspickle == flags)
+ return 0;
+ else
+ cobboard.rspickle = flags;
+ }
- cobboard.mode = mode;
- len = snprintf(buf, sizeof(buf), "cobboard=%d\n", mode);
+ len = snprintf(buf, sizeof(buf), "cobboard=%d,%d\n", side, flags);
hostsim_lock();
write(fdw, buf, len);
hostsim_unlock();
((local_r_pwm * 1000 * FILTER2)/1000);
/* basic collision detection */
- a2 = atan2(ROBOT_WIDTH/2, ROBOT_HALF_LENGTH_REAR);
- d = norm(ROBOT_WIDTH/2, ROBOT_HALF_LENGTH_REAR);
+ a2 = atan2(ROBOT_WIDTH/2, ROBOT_HALF_LENGTH_FRONT);
+ d = norm(ROBOT_WIDTH/2, ROBOT_HALF_LENGTH_FRONT);
xfl = x + cos(a+a2) * d;
yfl = y + sin(a+a2) * d;
int32_t robotsim_encoder_get(void *arg);
int robotsim_init(void);
void robotsim_dump(void);
-int8_t robotsim_i2c_cobboard_set_mode(uint8_t mode);
+int8_t robotsim_i2c_cobboard_set_spickles(uint8_t side, uint8_t flags);
void strat_init(void)
{
#ifdef HOST_VERSION
- position_set(&mainboard.pos, 298.16,
- COLOR_Y(308.78), COLOR_A(70.00));
+ position_set(&mainboard.pos, 258.,
+ COLOR_Y(246.), COLOR_A(45.));
#endif
/* we consider that the color is correctly set */
uint8_t err;
strat_set_acc(ACC_DIST, ACC_ANGLE);
- strat_set_speed(600, 60); /* OK */
- //strat_set_speed(250, 28); /* OK */
+ strat_set_speed(400, 150); /* OK */
- trajectory_d_a_rel(&mainboard.traj, 1000, COLOR_A(20));
+ trajectory_d_a_rel(&mainboard.traj, 800, COLOR_A(45));
err = WAIT_COND_OR_TRAJ_END(trajectory_angle_finished(&mainboard.traj),
TRAJ_FLAGS_STD);
#define SPEED_DIST_VERY_SLOW 400.
#define SPEED_ANGLE_VERY_SLOW 400.
-#define SPEED_CLITOID_SLOW 250.
-#define SPEED_CLITOID_FAST 500.
+#define SPEED_CLITOID_SLOW 100. ///250.
+#define SPEED_CLITOID_FAST 100. ///500.
/* strat infos structures */
return END_TRAJ; // XXX
}
+uint8_t strat_unblock(void)
+{
+ return END_TRAJ;
+}
+
void test_strat_avoid(void)
{
#ifdef TEST_STRAT_AVOID
}
/* hard turn, 120 deg */
else {
- radius = 75;
+ radius = 120;//75;
if (diff_a_deg > 0)
beta_deg = 0;
else
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); */
-
strat_rpack60 = 0;
strat_lpack60 = 0;
return err;