diff --git a/Inc/traitement.h b/Inc/traitement.h index 83754f07a67655dcae2339088b1a77845221f7ca..936f987c7aebf12b2bb4d6809ada92d02fa774f5 100644 --- a/Inc/traitement.h +++ b/Inc/traitement.h @@ -36,4 +36,7 @@ void chassis_consigne(double Vx, double Vy, double W); /*Effectue le suivi automatique des cibles */ void auto_follow_target(void); +/*Retourne true si le controller est a une position neutre*/ +bool isControllerNeutral(void); + #endif diff --git a/Src/main.c b/Src/main.c index 2043d574e3395802b774d89b4c768cd9811110b4..1bb5dc8c3f9abf41d56f510ef5f9b30265f05377 100644 --- a/Src/main.c +++ b/Src/main.c @@ -113,11 +113,21 @@ int main(void) extern motor_t motors[MAX_MOTORS]; extern pilote_t pilote; extern jetson_t jetson; + extern uint32_t signOfLife_Receiver_RadioController_tick; piloteInit(PILOTE_ANTONIN); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ + + while(1){ + + if(signOfLife_Receiver_RadioController_tick !=0 ){ + if(isControllerNeutral()){ + break; + } + } + } while (1) { signOfLife(); //LEDs BLINK diff --git a/Src/traitement.c b/Src/traitement.c index 4b8ea4ef3e1ec275326e6d7e7815f4fa69992cf9..b266c2963df2354fe0dbab952b6b65fc51f7a991 100644 --- a/Src/traitement.c +++ b/Src/traitement.c @@ -30,6 +30,34 @@ void traitement_pids_compute(){ } } +/*Returns true if controller is in neutral state*/ +bool isControllerNeutral(){ + + if(receiver_RadioController.data.ch1_float != 0){ + return false; + } + if(receiver_RadioController.data.ch2_float != 0){ + return false; + } + if(receiver_RadioController.data.ch3_float != 0){ + return false; + } + if(receiver_RadioController.data.ch4_float != 0){ + return false; + } + if(receiver_RadioController.data.sw1 != 1){ + return false; + } + if(receiver_RadioController.data.sw2 != 1){ + return false; + } + /*if(receiver_RadioController.data.wheel != 0){ + return false; + }*/ + return true; +} + + /* Fonctions qui fait les liens entre les entrées (capteurs, radio controller, CV, ...) et les sorties (consignes moteurs), on peut créer plusieurs traitements */ void traitement_1(){