1 #include "match-timing.h"
5 #define COMPETITION_TIME_DEFAULT 90
6 #define TIME_TO_DEPOSITE_DEFAULT 60
8 #define COMPETITION_TIME_DEFAULT 90
9 #define TIME_TO_DEPOSITE_DEFAULT 60
12 /* competition time in seconds */
13 #define COMPETITION_TIME COMPETITION_TIME_DEFAULT
14 #define TIME_TO_DEPOSITE TIME_TO_DEPOSITE_DEFAULT
15 /* competition time in seconds */
19 /** *********************************************************************
20 * Competition timer. Stop robot when the timer exceeds.
21 ********************************************************************** */
23 void *timing_thread(void *arg)
25 struct timespec start;
27 sem_wait(&robot.start);
28 clock_gettime(CLOCK_MONOTONIC, &start);
32 t.tv_sec = start.tv_sec+sec; \
33 t.tv_nsec = start.tv_nsec; \
34 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t, NULL); \
38 // // microswitch (backside opponent detector), ignore it while at starting point
39 // robot.use_back_switch = true;
40 // printf("Back switch not ignored\n");
42 WAIT(TIME_TO_DEPOSITE);
43 robot.short_time_to_end = true;
45 WAIT(COMPETITION_TIME);
46 printf("%d seconds timer exceeded! exiting!\n", COMPETITION_TIME);