case NEW_DATA:
/* Stupid way of controlling the robot by
* pluggin in and out start connector. */
- if (instance->start) {
- robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
- } else {
- robot.hw_status[STATUS_STA] = HW_STATUS_OK;
- }
switch (robot.state) {
case POWER_ON:
+ if (instance->start) {
+ robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
+ } else {
+ robot.hw_status[STATUS_STA] = HW_STATUS_OK;
+ }
if (!instance->start) {
robot.state = START_PLUGGED_IN;
printf("START_PLUGGED_IN\n");
break;
case START_PLUGGED_IN:
+ robot.hw_status[STATUS_STA] = HW_STATUS_OK;
/* Competition starts when plugged out */
if (instance->start) {
FSM_SIGNAL(MAIN, EV_START, NULL);
}
break;
- case COMPETITION_STARTED:
+ case COMPETITION_STARTED: {
/* Subsequent plug-in stops the robot */
+ static int num = 0;
if (!instance->start) {
- //robot_exit();
+ robot.hw_status[STATUS_STA] = HW_STATUS_WARNING;
+ if (++num == 10)
+ robot_exit();
}
break;
+ }
}
last_instance = *instance;
break;
void rcv_puck_inside_cb(const ORTERecvInfo *info, void *vinstance,
void *recvCallBackParam)
{
- static bool previous_switch_status;
switch (info->status) {
case NEW_DATA: {
if (robot.use_back_switch) {
- if (robot.orte.puck_inside.status & 0x01) {
+ static bool previous_switch_status = 0;
+ if (robot.orte.puck_inside.status & 0x02) {
//FSM_SIGNAL(ACT, EV_PUCK_INSIDE, NULL);
/* React on the first switch or when moving backward. */
- if ((previous_switch_status & 0x01) == 0 ||
+ if ((previous_switch_status & 0x02) == 0 ||
robot.moves_backward) {
FSM_SIGNAL(MOTION, EV_OBSTACLE_BEHIND, NULL);
}