mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-11-16 13:26:03 +01:00
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
|
#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();
|
||
|
configureActionneurs();
|
||
|
configurePosition();
|
||
|
configureMovement();
|
||
|
startDebug();
|
||
|
|
||
|
debugSetActive(true);
|
||
|
enableConsigne();
|
||
|
struct position pos = { 100, 0, 0 };
|
||
|
setDestination(&pos);
|
||
|
waitDestination();
|
||
|
brake();
|
||
|
disableConsigne();
|
||
|
|
||
|
// 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;
|
||
|
}
|