2018-02-16 15:44:45 +01:00
|
|
|
#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
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
#include "CF.h"
|
2018-02-16 15:44:45 +01:00
|
|
|
#include "movement.h"
|
2018-04-04 16:17:13 +02:00
|
|
|
#include "position.h"
|
2018-02-16 15:44:45 +01:00
|
|
|
#include "debug.h"
|
|
|
|
|
2018-03-26 10:06:32 +02:00
|
|
|
#define TEMPSMAX 60
|
2018-02-16 15:44:45 +01:00
|
|
|
|
|
|
|
void* TaskParcours(void *pdata)
|
|
|
|
{
|
|
|
|
(void) pdata;
|
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
/* 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); */
|
|
|
|
/* brake(); */
|
|
|
|
/* sleep(2); */
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
struct timespec tim; // 10 ms
|
|
|
|
tim.tv_sec = 0;
|
|
|
|
tim.tv_nsec = 10000000L;
|
|
|
|
|
|
|
|
#define RAMP_TIME 100
|
|
|
|
#define MAX_VIT MOT_MAX_V
|
|
|
|
|
2018-04-29 09:38:49 +02:00
|
|
|
/* for (;;) { */
|
2018-04-04 16:17:13 +02:00
|
|
|
// ↗
|
|
|
|
for (int i = 0; i < RAMP_TIME; i++) {
|
|
|
|
float p = (float) i / (float) RAMP_TIME;
|
|
|
|
changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V);
|
|
|
|
nanosleep(&tim, NULL);
|
|
|
|
}
|
|
|
|
changerMoteurs(MOT_MAX_V, MOT_MAX_V);
|
|
|
|
// ↑
|
2018-02-16 15:44:45 +01:00
|
|
|
sleep(2);
|
2018-04-29 09:38:49 +02:00
|
|
|
/* // ↘ */
|
|
|
|
/* for (int i = 0; i < RAMP_TIME; i++) { */
|
|
|
|
/* float p = (float) i / (float) RAMP_TIME; */
|
|
|
|
/* p = 1 - p; */
|
|
|
|
/* changerMoteurs(p * MOT_MAX_V, p * MOT_MAX_V); */
|
|
|
|
/* nanosleep(&tim, NULL); */
|
|
|
|
/* } */
|
|
|
|
/* sleep(5); */
|
|
|
|
/* } */
|
2018-02-16 15:44:45 +01:00
|
|
|
|
|
|
|
printf("Fin du parcours\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-02-12 19:23:24 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2018-02-16 15:44:45 +01:00
|
|
|
|
|
|
|
printf("Démarrage...\n");
|
|
|
|
configureDebug();
|
2018-04-29 09:38:49 +02:00
|
|
|
configureCF();
|
2018-04-04 16:17:13 +02:00
|
|
|
configureMovement();
|
|
|
|
configurePosition();
|
2018-04-29 09:38:49 +02:00
|
|
|
startDebug();
|
2018-02-16 15:44:45 +01:00
|
|
|
srand(time(NULL));
|
|
|
|
|
|
|
|
/* printf("En attente de la tirette...\n"); // TODO */
|
|
|
|
printf("C'est parti !\n");
|
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
pthread_t tParcours;
|
|
|
|
pthread_create(&tParcours, NULL, TaskParcours, NULL);
|
2018-02-16 15:44:45 +01:00
|
|
|
|
|
|
|
sleep(TEMPSMAX);
|
|
|
|
|
|
|
|
printf("Fin des %d secondes\n", TEMPSMAX);
|
|
|
|
/* pthread_cancel(tParcours); */
|
|
|
|
|
2018-04-29 09:38:49 +02:00
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
}
|
2018-02-16 15:44:45 +01:00
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
/* stop(); */
|
2018-02-16 22:13:24 +01:00
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
deconfigureMovement();
|
|
|
|
deconfigurePosition();
|
|
|
|
deconfigureCF();
|
2018-04-29 09:38:49 +02:00
|
|
|
deconfigureDebug();
|
2018-02-16 15:44:45 +01:00
|
|
|
return EXIT_SUCCESS;
|
2018-02-07 17:57:01 +01:00
|
|
|
}
|