7 * @brief Robot's main control program
14 * Robot's main control program (Eurobot 2010).
16 * Copyright: (c) 2009-2010 CTU Dragons
17 * CTU FEE - Department of Control Engineering
18 * License: GNU GPL v.2
25 // FIXME: remove unused includes:
32 #include <movehelper.h>
40 #include <actuators.h>
41 #include "match-timing.h"
44 #define WAIT_FOR_START
49 /************************************************************************
50 * SUBFSM's return values ...
51 ************************************************************************/
58 #define FSM_EVENT_RET_VAL ((subfsm_ret_val)FSM_EVENT_INT)
60 /************************************************************************
61 * Trajectory constraints used, are initialized in the init state
62 ************************************************************************/
64 struct TrajectoryConstraints tcFast, tcSlow, tcVerySlow;
66 /************************************************************************
67 * Definition of particular movement sequences (FIXME)
68 ************************************************************************/
70 /************************************************************************
71 * FSM STATES DECLARATION
72 ************************************************************************/
74 /* initial and starting states */
76 FSM_STATE_DECL(wait_for_start);
77 /* strategies related states */
78 FSM_STATE_DECL(decide_what_next);
81 /************************************************************************
82 * INITIAL AND STARTING STATES
83 ************************************************************************/
89 robot.short_time_to_end = false;
91 tcFast = trajectoryConstraintsDefault;
92 tcSlow = trajectoryConstraintsDefault;
97 tcVerySlow = trajectoryConstraintsDefault;
98 tcVerySlow.maxv = 0.1;
99 tcVerySlow.maxacc = 0.05;
100 tcVerySlow.maxomega = 0.7;
101 tcVerySlow.maxangacc = 1;
102 FSM_TRANSITION(wait_for_start);
109 void set_initial_position()
111 robot_set_est_pos_trans(0.16,
112 PLAYGROUND_HEIGHT_M - 0.16,
116 FSM_STATE(wait_for_start)
120 printf("COMPETITION mode set\n");
124 pthread_create(&thid, NULL, timing_thread, NULL);
125 #ifdef WAIT_FOR_START
131 /* start competition timer */
132 sem_post(&robot.start);
134 set_initial_position();
135 FSM_TRANSITION(decide_what_next);
138 // We set initial position periodically in
139 // order for it to be updated on the display
140 // if the team color is changed during waiting
142 set_initial_position();
145 case EV_GOAL_NOT_REACHABLE: // currently not used
147 case EV_ACTION_ERROR:
149 DBG_PRINT_EVENT("unhandled event");
156 /************************************************************************
157 * STRATEGIES RELATED STATES
158 ************************************************************************/
160 FSM_STATE(decide_what_next)
164 if(robot.short_time_to_end) {
172 case EV_GOAL_NOT_REACHABLE: // currently not used
173 case EV_ACTION_ERROR:
175 DBG_PRINT_EVENT("unhandled event");
188 if (rv) error(1, errno, "robot_init() returned %d\n", rv);
190 robot.fsm.main.debug_states = 1;
191 robot.fsm.motion.debug_states = 1;
192 robot.fsm.act.debug_states = 1;
194 robot.fsm.main.state = &fsm_state_main_init;
197 if (rv) error(1, errno, "robot_start() returned %d\n", rv);