7 #include <movehelper.h>
14 #include "actuators.h"
17 #include "match-timing.h"
20 #include "common-states.h"
24 UL_LOG_CUST(ulogd_strategy_odo_calibration); /* Log domain name = ulogd + name of the file */
33 ul_logmsg("waiting for start\n");
39 robot.obstacle_avoidance_enabled = false;
40 robot.use_back_bumpers = false;
43 FSM_TRANSITION(go_back_for_cal);
52 case EV_SWITCH_STRATEGY:
53 FSM_TRANSITION(get_central_buillon_first);
59 /* State for odometry calibration */
61 FSM_STATE(go_back_for_cal)
63 double x1 = 0, y1 = 0;
67 robot_set_est_pos_trans(ROBOT_AXIS_TO_BACK_M + 1.0,
68 PLAYGROUND_HEIGHT_M - (ROBOT_WIDTH_M/2.0),
70 robot_move_by(-1.1, NO_TURN(), &tcVerySlow);
74 ROBOT_LOCK(est_pos_odo);
75 robot.odo_cal_a = -1.0/robot.odo_distance_a;
76 robot.odo_cal_b = -1.0/robot.odo_distance_b;
77 x1 = robot.odo_distance_a;
78 y1 = robot.odo_distance_b;
79 ROBOT_UNLOCK(est_pos_odo);
80 if(x1 != 0 || y1 != 0) {
81 printf("Distance for calibration: \n");
82 printf("Left%f\n", x1);
83 printf("Right%f\n", y1);
85 file = fopen ("odometry_cal_data","a+");
86 sprintf(buffer, "%4.4f", -1/x1);
89 sprintf(buffer, "%4.4f", -1/y1);
94 FSM_TRANSITION(get_central_buillon_first);
97 ROBOT_LOCK(est_pos_odo);
98 if(x1 == robot.odo_distance_a){
99 x1 = robot.odo_distance_a;
100 y1 = robot.odo_distance_b;
101 FSM_SIGNAL(MOTION,EV_MOVE_STOP, NULL);
102 FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);
106 ROBOT_UNLOCK(est_pos_odo);