1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-11-16 13:26:03 +01:00
cdf2018-principal/chef/src/test1m.c

80 lines
1.6 KiB
C
Raw Normal View History

2018-05-09 09:57:11 +02:00
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h> // random seed
#include <unistd.h> // sleep
#include <wiringPi.h>
#include "CF.h"
#include "actionneurs.h"
#include "debug.h"
#include "i2c.h"
#include "ihm.h"
#include "imu.h"
#include "movement.h"
#include "motor.h"
#include "position.h"
pthread_mutex_t sRunning;
void endRunning(int signal)
{
(void)signal;
pthread_mutex_unlock(&sRunning);
}
int main()
{
if (wiringPiSetup() < 0) {
fprintf(stderr, "Impossible d'initialiser WiringPi\n");
exit(EXIT_FAILURE);
}
initI2C();
srand(time(NULL));
configureDebug();
configureCF();
configureIMU();
2018-05-09 14:24:12 +02:00
printf("40\n");
2018-05-09 09:57:11 +02:00
configureActionneurs();
2018-05-09 14:24:12 +02:00
printf("41\n");
2018-05-09 09:57:11 +02:00
configurePosition();
2018-05-09 14:24:12 +02:00
printf("44\n");
2018-05-09 09:57:11 +02:00
configureMovement();
2018-05-09 14:24:12 +02:00
printf("46\n");
2018-05-09 09:57:11 +02:00
startDebug();
2018-05-09 14:24:12 +02:00
printf("48\n");
2018-05-09 09:57:11 +02:00
debugSetActive(true);
2018-05-09 14:24:12 +02:00
sleep(1);
printf("46\n");
2018-05-09 09:57:11 +02:00
enableConsigne();
2018-05-09 14:24:12 +02:00
struct position pos = { 0, -100, -M_PI };
2018-05-09 09:57:11 +02:00
setDestination(&pos);
2018-05-09 14:24:12 +02:00
printf("50\n");
2018-05-09 09:57:11 +02:00
waitDestination();
2018-05-09 14:24:12 +02:00
printf("52\n");
2018-05-09 09:57:11 +02:00
disableConsigne();
2018-05-09 14:24:12 +02:00
printf("54\n");
brake();
printf("Done\n");
2018-05-09 09:57:11 +02:00
// Bloque jusqu'à l'arrivée d'un signal
pthread_mutex_init(&sRunning, NULL);
signal(SIGINT, endRunning);
signal(SIGTERM, endRunning);
signal(SIGQUIT, endRunning);
pthread_mutex_lock(&sRunning);
pthread_mutex_lock(&sRunning);
deconfigureMovement();
deconfigurePosition();
deconfigureActionneurs();
deconfigureIMU();
deconfigureCF();
deconfigureDebug();
return EXIT_SUCCESS;
}