mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2025-09-04 01:05:56 +02:00
Différentiation Stop / Brake
This commit is contained in:
parent
89d3bf21cd
commit
98e1bde49d
8 changed files with 85 additions and 25 deletions
|
@ -23,8 +23,10 @@ void printDebugInfos(struct A2CI_DBGs* debug)
|
|||
{
|
||||
printf("← Position actuelle (%f; %f) (%f°)", debug->actuel.x, debug->actuel.y, debug->actuel.o);
|
||||
printf(", destination : ");
|
||||
if (debug->movement == C2AD_STOP) {
|
||||
printf("aucune\n");
|
||||
if (debug->movement == C2AD_BRAKE) {
|
||||
printf("ne pas bouger\n");
|
||||
} else if (debug->movement == C2AD_FREE) {
|
||||
printf("là où le vent l'emporte\n");
|
||||
} else {
|
||||
printf("(%f; %f) (%f°)\n", debug->destination.x, debug->destination.y, debug->destination.o);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,20 @@ void stop()
|
|||
sendCA(C2AD_STOP, NULL, 0);
|
||||
}
|
||||
|
||||
void onC2AD_BRAKE()
|
||||
{
|
||||
// On considère que l'arrêt se fait très rapidement pour ne pas
|
||||
// avoir à attendre le signal de retour de C2AD_BRAKE
|
||||
registerRxHandler(C2AD_BRAKE, NULL);
|
||||
}
|
||||
|
||||
void brake()
|
||||
{
|
||||
printf("→ Frein\n");
|
||||
registerRxHandler(C2AD_BRAKE, onC2AD_BRAKE);
|
||||
sendCA(C2AD_BRAKE, NULL, 0);
|
||||
}
|
||||
|
||||
// Inspiré de https://stackoverflow.com/a/1760819
|
||||
pthread_mutex_t reponseMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t reponseCond = PTHREAD_COND_INITIALIZER;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "CA.h"
|
||||
|
||||
void stop();
|
||||
void brake();
|
||||
void aller(struct position* pos);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,7 @@ void* TaskParcours(void *pdata)
|
|||
pos.o = (int) (rand()*360.0/RAND_MAX);
|
||||
aller(&pos);
|
||||
sleep(1);
|
||||
stop();
|
||||
brake();
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ int main()
|
|||
/* pthread_cancel(tParcours); */
|
||||
|
||||
|
||||
/* stop(); */
|
||||
/* */
|
||||
stop();
|
||||
|
||||
deconfigureDebug();
|
||||
deconfigureCA();
|
||||
return EXIT_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue