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

94 lines
2 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
2018-04-04 16:17:13 +02:00
#include "CF.h"
#include "movement.h"
2018-04-04 16:17:13 +02:00
#include "position.h"
#include "debug.h"
2018-03-26 10:06:32 +02:00
#define TEMPSMAX 60
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);
// ↑
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); */
/* } */
printf("Fin du parcours\n");
return NULL;
}
2018-02-12 19:23:24 +01:00
int main()
{
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();
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);
sleep(TEMPSMAX);
printf("Fin des %d secondes\n", TEMPSMAX);
/* pthread_cancel(tParcours); */
2018-04-29 09:38:49 +02:00
for (;;) {
}
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();
return EXIT_SUCCESS;
2018-02-07 17:57:01 +01:00
}