2 * homologation.cc 12/03/15
4 * Robot's control program intended for homologation (approval phase) on Eurobot 2012.
6 * Copyright: (c) 2012 CTU Flamingos
7 * CTU FEE - Department of Control Engineering
16 #include <movehelper.h>
23 #include "actuators.h"
25 #include "match-timing.h"
28 UL_LOG_CUST(ulogd_homologation); /* Log domain name = ulogd + name of the file */
30 /************************************************************************
31 * Trajectory constraints used, are initialized in the init state
32 ************************************************************************/
34 struct TrajectoryConstraints tcFast, tcSlow, tcVerySlow;
36 /************************************************************************
37 * FSM STATES DECLARATION
38 ************************************************************************/
41 FSM_STATE_DECL(wait_for_start);
42 /* movement states - buillon */
43 FSM_STATE_DECL(aproach_buillon);
44 /* Pushing the bottle */
45 FSM_STATE_DECL(push_bottle);
52 tcSlow = trajectoryConstraintsDefault;
56 FSM_TRANSITION(wait_for_start);
63 void set_initial_position()
65 // TODO define initial position
66 robot_set_est_pos_trans(ROBOT_AXIS_TO_BACK_M,
67 PLAYGROUND_HEIGHT_M - (ROBOT_WIDTH_M/2.0),
74 // drive lift to home position
76 // unset the homing request
80 FSM_STATE(wait_for_start)
84 ul_logdeb("WAIT_FOR_START mode set\n");
86 ul_logdeb("WAIT_FOR_START mode NOT set\n");
89 ul_logdeb("COMPETITION mode set\n");
91 ul_logdeb("COMPETITION mode NOT set\n");
95 pthread_create(&thid, NULL, timing_thread, NULL);
101 /* start competition timer */
102 sem_post(&robot.start);
104 set_initial_position();
105 FSM_TRANSITION(aproach_buillon);
109 // We set initial position periodically in
110 // order for it to be updated on the display
111 // if the team color is changed during waiting
113 set_initial_position();
114 if (robot.start_state == START_PLUGGED_IN)
118 case EV_MOTION_ERROR:
120 //case EV_VIDLE_DONE:
121 case EV_SWITCH_STRATEGY:
122 DBG_PRINT_EVENT("unhandled event");
131 FSM_STATE(aproach_buillon)
135 robot_trajectory_new(&tcSlow); // new trajectory
136 robot_trajectory_add_point_trans(
138 PLAYGROUND_HEIGHT_M - (ROBOT_WIDTH_M/2.0));
139 robot_trajectory_add_point_trans(
142 robot_trajectory_add_final_point_trans(
149 FSM_TRANSITION(push_bottle);
156 FSM_STATE(push_bottle)
160 robot_trajectory_new(&tcSlow); // new trajectory
161 robot_trajectory_add_point_trans(
164 robot_trajectory_add_final_point_trans(
166 ROBOT_AXIS_TO_FRONT_M + 0.05,
167 ARRIVE_FROM(DEG2RAD(270), 0.10));
175 /************************************************************************
177 ************************************************************************/
184 if (rv) error(1, errno, "robot_init() returned %d\n", rv);
186 robot.obstacle_avoidance_enabled = true;
188 robot.fsm.main.debug_states = 1;
189 robot.fsm.motion.debug_states = 1;
190 //robot.fsm.act.debug_states = 1;
192 robot.fsm.main.state = &fsm_state_main_init;
193 //robot.team_color = BLUE;
194 //robot.fsm.main.transition_callback = trans_callback;
195 //robot.fsm.motion.transition_callback = move_trans_callback;
198 if (rv) error(1, errno, "robot_start() returned %d\n", rv);