4 * Movement test: goto test.
6 * Copyright: (c) 2007 CTU Dragons
7 * CTU FEE - Department of Control Engineering
12 #include <movehelper_eb2008.h>
13 #include <robot_eb2008.h>
15 #include <path_planner.h>
24 FSM_STATE_DECL(robot_goto_test);
28 if (FSM_EVENT == EV_ENTRY) {
29 /* Where we are at the begining? */
30 robot_set_est_pos_trans(ROBOT_WIDTH_M/2,
31 PLAYGROUND_HEIGHT_M - ROBOT_AXIS_TO_BACK_M,
33 FSM_TRANSITION(robot_goto_test);
37 FSM_STATE(robot_goto_test)
42 ShmapSetRectangleFlag(0.0, 0.0, 0.199, 2.1, MAP_FLAG_WALL, 0);
43 ShmapSetRectangleFlag(0.0, 0.0, 3.0, 0.199, MAP_FLAG_WALL, 0);
44 ShmapSetRectangleFlag(0.0, 1.901, 3.0, 2.1, MAP_FLAG_WALL, 0);
45 ShmapSetRectangleFlag(2.801, 0.0, 3.0, 2.1, MAP_FLAG_WALL, 0);
46 //ShmapSetRectangleFlag(1.3, 0.7, 1.7, 1.0, MAP_FLAG_SIMULATED_WALL, 0);
47 //ShmapSetRectangleFlag(1.8, 1.5, 2.3, 1.8, MAP_FLAG_SIMULATED_WALL, 0);
49 goalx = (rand()%(MAP_PLAYGROUND_WIDTH_MM-50)+25)/1000.0;
50 goaly = ((rand()%(MAP_PLAYGROUND_HEIGHT_MM-50)+25)/1000.0);
51 // goalx = robot.act_pos->x + (rand()%100)/1000.0;
52 // goaly = robot.act_pos->y + (rand()%100)/1000.0;
53 } while (!ShmapIsFreePoint(goalx, goaly));
55 robot_goto_notrans(goalx, goaly, NO_TURN(), NULL);
57 case EV_GOAL_NOT_REACHABLE:
58 DBG("Goal is not reachable\n");
63 FSM_TRANSITION(robot_goto_test);
76 void trans_callback(struct robo_fsm *fsm)
78 if(fsm->state_name!=NULL)
79 strncpy(robot.act_fsm_state_name, fsm->state_name, FSM_STATE_NAME_MAX_LEN);
82 void move_trans_callback(struct robo_fsm *fsm)
84 if(fsm->state_name!=NULL)
85 strncpy(robot.move_fsm_state_name, fsm->state_name, FSM_STATE_NAME_MAX_LEN);
90 /* robot initialization */
93 FSM(MAIN)->debug_states = 1;
94 FSM(MOTION)->debug_states = 1;
95 robot.obstacle_avoidance_enabled = true;
97 robot.fsm[FSM_ID_MAIN].transition_callback = trans_callback;
98 robot.fsm[FSM_ID_MOTION].transition_callback = move_trans_callback;
99 FSM(MAIN)->state = &fsm_state_main_init;
101 /* start threads and wait */