1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-15 04:46:06 +01:00
cdf2018-principal/chef/src/premier.c

60 lines
1.1 KiB
C
Raw Normal View History

#include <stdlib.h>
#include <stdio.h>
#include <time.h> // random seed
#include <pthread.h>
#include <unistd.h> // sleep
2018-02-07 17:57:01 +01:00
#include "CA.h"
#include "movement.h"
#include "debug.h"
#define TEMPSMAX 10
void* TaskParcours(void *pdata)
{
(void) pdata;
struct position pos;
for (;;) {
pos.x = (int) (rand()*200.0/RAND_MAX);
pos.y = (int) (rand()*100.0/RAND_MAX);
pos.o = (int) (rand()*360.0/RAND_MAX);
aller(&pos);
sleep(1);
2018-02-16 22:13:24 +01:00
brake();
sleep(2);
}
printf("Fin du parcours\n");
return NULL;
}
2018-02-12 19:23:24 +01:00
int main()
{
printf("Démarrage...\n");
2018-02-12 19:23:24 +01:00
configureCA();
configureDebug();
srand(time(NULL));
/* printf("Synchronisation avec le Raspberry Pi\n"); // TODO */
/* printf("En attente de la tirette...\n"); // TODO */
printf("C'est parti !\n");
pthread_t tParcours;
pthread_create(&tParcours, NULL, TaskParcours, NULL);
sleep(TEMPSMAX);
printf("Fin des %d secondes\n", TEMPSMAX);
/* pthread_cancel(tParcours); */
2018-02-16 22:13:24 +01:00
stop();
deconfigureDebug();
2018-02-12 19:23:24 +01:00
deconfigureCA();
return EXIT_SUCCESS;
2018-02-07 17:57:01 +01:00
}