diff --git a/software/raspberry/superviseur-robot/lib/commonitor.cpp b/software/raspberry/superviseur-robot/lib/commonitor.cpp index bb64388..90a0832 100644 --- a/software/raspberry/superviseur-robot/lib/commonitor.cpp +++ b/software/raspberry/superviseur-robot/lib/commonitor.cpp @@ -135,7 +135,7 @@ int ComMonitor::AcceptClient() { * Send a message to monitor * * @param msg Message to send to monitor - * @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that. + * @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that. * @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously */ void ComMonitor::Write(Message *msg) { diff --git a/software/raspberry/superviseur-robot/nbproject/private/private.xml b/software/raspberry/superviseur-robot/nbproject/private/private.xml index 39a10ef..6d1bce2 100644 --- a/software/raspberry/superviseur-robot/nbproject/private/private.xml +++ b/software/raspberry/superviseur-robot/nbproject/private/private.xml @@ -7,7 +7,13 @@ + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/camera.cpp + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/comrobot.cpp file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/tasks.h + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/img.cpp + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/img.h + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/tasks.cpp + file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/commonitor.cpp diff --git a/software/raspberry/superviseur-robot/tasks.cpp b/software/raspberry/superviseur-robot/tasks.cpp index d2c617b..3d122c0 100644 --- a/software/raspberry/superviseur-robot/tasks.cpp +++ b/software/raspberry/superviseur-robot/tasks.cpp @@ -24,8 +24,8 @@ #define PRIORITY_TMOVE 20 #define PRIORITY_TSENDTOMON 22 #define PRIORITY_TRECEIVEFROMMON 25 -#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 22 -#define PRIORITY_TSTARTROBOTWITHWATCHDOG 22 +#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 19 +#define PRIORITY_TSTARTROBOTWITHWATCHDOG 19 #define PRIORITY_TCAMERA 21 @@ -358,7 +358,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) { rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE); cout << "Start robot without watchdog ("; - //Boolean to get the battery + //Boolean to kill the loop and stop the robot and battery acquisition rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE); killBatteryBool=0; rt_mutex_release(&mutex_kill_battery); @@ -383,7 +383,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) { rt_mutex_acquire(&mutex_monitor, TM_INFINITE); monitor.Write(p_mess_answer_battery); rt_mutex_release(&mutex_monitor); - //cout << endl << flush; + cout << endl << flush; rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE); killBattery=killBatteryBool; rt_mutex_release(&mutex_kill_battery); @@ -408,8 +408,9 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) { /**************************************************************************************/ Message* p_mess_answer_battery; Message * msgSend; - int cpt=1; - int err; + int cpt=0; + int killBattery=0; + rt_sem_p(&sem_startRobotWithWatchdog, TM_INFINITE); cout << "Start robot with watchdog ("; rt_mutex_acquire(&mutex_robot, TM_INFINITE); @@ -423,31 +424,38 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) { cout << msgSend->GetID(); cout << ")" << endl; - + cout << "Movement answer: " << msgSend->ToString() << endl << flush; WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon - + + //si réussite : if (msgSend->GetID() == MESSAGE_ANSWER_ACK) { - + rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE); robotStarted = 1; rt_mutex_release(&mutex_robotStarted); rt_task_set_periodic(NULL, TM_NOW, 500000000); - while (1) { + while (!killBattery) { + rt_task_wait_period(NULL); cpt++; if(cpt%2==0){ rt_mutex_acquire(&mutex_robot, TM_INFINITE); robot.Write(robot.ReloadWD()); rt_mutex_release(&mutex_robot); } - rt_task_wait_period(NULL); rt_mutex_acquire(&mutex_robot, TM_INFINITE); p_mess_answer_battery = robot.Write(robot.GetBattery()); rt_mutex_release(&mutex_robot); + rt_mutex_acquire(&mutex_monitor, TM_INFINITE); monitor.Write(p_mess_answer_battery); rt_mutex_release(&mutex_monitor); cout << endl << flush; + + //mise à jour de la variable d'acquisition de la batterie + rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE); + killBattery=killBatteryBool; + rt_mutex_release(&mutex_kill_battery); } } } diff --git a/software/raspberry/superviseur-robot/tasks.h b/software/raspberry/superviseur-robot/tasks.h index 609aeda..40b3e36 100644 --- a/software/raspberry/superviseur-robot/tasks.h +++ b/software/raspberry/superviseur-robot/tasks.h @@ -66,7 +66,6 @@ private: ComRobot robot; int robotStarted = 0; int killBatteryBool = 0; - int killRobotWithoutWd = 0; int move = MESSAGE_ROBOT_STOP; /**********************************************************************/ diff --git a/software/simulateur/nbproject/private/private.xml b/software/simulateur/nbproject/private/private.xml index aef7ea3..304d47a 100755 --- a/software/simulateur/nbproject/private/private.xml +++ b/software/simulateur/nbproject/private/private.xml @@ -6,6 +6,8 @@ - + + file:/home/romainv/Documents/temps_reel/dumber1/software/simulateur/main.cpp +