robot whitout WD perfect + (with WD and vision not ok)

This commit is contained in:
Raphael Benistant 2020-03-31 15:39:09 +02:00
parent fc10a54aae
commit 4208c91f0e
3 changed files with 49 additions and 40 deletions

View file

@ -9,10 +9,6 @@
<group> <group>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.cpp</file> <file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.cpp</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.h</file> <file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/tasks.h</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/main.cpp</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.h</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
<file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/messages.h</file> <file>file:/home/raphael/Documents/real_time/software/raspberry/superviseur-robot/lib/messages.h</file>
</group> </group>
</open-files> </open-files>

View file

@ -428,6 +428,10 @@ void Tasks::ReceiveFromMonTask(void *arg) {
rt_mutex_acquire(&mutex_acquireImage, TM_INFINITE); rt_mutex_acquire(&mutex_acquireImage, TM_INFINITE);
acquireImage=0; acquireImage=0;
rt_mutex_release(&mutex_acquireImage); rt_mutex_release(&mutex_acquireImage);
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted=0;
rt_mutex_release(&mutex_robotStarted);
//Wait every task to die //Wait every task to die
sleep(1); sleep(1);
@ -603,39 +607,42 @@ void Tasks::OpenComRobot(void *arg) { //PAS DE SOUCIS AU REDEMARAGE
* @brief Thread starting the communication with the robot. * @brief Thread starting the communication with the robot.
*/ */
void Tasks::StartRobotTaskWithoutWatchdog(void *arg) { void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
int killBatteryOk=0; int killBatteryOk=0;
Message * msgSend; Message * msgSend;
/**************************************************************************************/ /**************************************************************************************/
/* The task startRobot starts here */ /* The task startRobot starts here */
/**************************************************************************************/ /**************************************************************************************/
//Boolean to get the battery while(1){
rt_mutex_acquire(&mutex_killBattery, TM_INFINITE); cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
killBatteryOk=0; // Synchronization barrier (waiting that all tasks are starting)
rt_mutex_release(&mutex_killBattery); rt_sem_p(&sem_barrier, TM_INFINITE);
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE); //Boolean to get the battery
cout << "Start robot without watchdog ("; rt_mutex_acquire(&mutex_killBattery, TM_INFINITE);
rt_mutex_acquire(&mutex_robot, TM_INFINITE); killBatteryOk=0;
msgSend = robot.Write(robot.StartWithoutWD()); rt_mutex_release(&mutex_killBattery);
rt_mutex_release(&mutex_robot); rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
cout << msgSend->GetID(); cout << "Start robot without watchdog (";
cout << ")" << endl; rt_mutex_acquire(&mutex_robot, TM_INFINITE);
cout << "Movement answer: " << msgSend->ToString() << endl << flush; msgSend = robot.Write(robot.StartWithoutWD());
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon rt_mutex_release(&mutex_robot);
cout << msgSend->GetID();
cout << ")" << endl;
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) { if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE); rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted = 1; robotStarted = 1;
rt_mutex_release(&mutex_robotStarted); rt_mutex_release(&mutex_robotStarted);
rt_task_set_periodic(NULL, TM_NOW, 500000000); rt_task_set_periodic(NULL, TM_NOW, 500000000);
while (killBatteryOk==0) { while (killBatteryOk==0) {
rt_task_wait_period(NULL); rt_task_wait_period(NULL);
rt_sem_v(&sem_askBattery); rt_sem_v(&sem_askBattery);
rt_mutex_acquire(&mutex_killBattery, TM_INFINITE); rt_mutex_acquire(&mutex_killBattery, TM_INFINITE);
killBatteryOk=killBattery; killBatteryOk=killBattery;
rt_mutex_release(&mutex_killBattery); rt_mutex_release(&mutex_killBattery);
}
} }
} }
} }
@ -647,18 +654,22 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
* @brief Thread starting the communication with the robot. * @brief Thread starting the communication with the robot.
*/ */
void Tasks::StartRobotTaskWithWatchdog(void *arg) { void Tasks::StartRobotTaskWithWatchdog(void *arg) {
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
int killBatteryOk=0; int killBatteryOk=0;
int cpt=1; int cpt=1;
Message * msgSend; Message * msgSend;
/**************************************************************************************/
/* The task startRobot starts here */
/**************************************************************************************/
int err; int err;
while(1){ while(1){
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
/**************************************************************************************/
/* The task startRobot starts here */
/**************************************************************************************/
//Boolean to get the battery //Boolean to get the battery
rt_mutex_acquire(&mutex_killBattery, TM_INFINITE); rt_mutex_acquire(&mutex_killBattery, TM_INFINITE);
killBattery=0; killBattery=0;
@ -795,6 +806,10 @@ void Tasks::DetectLostSupRob(void *arg){
killBattery=1; killBattery=1;
rt_mutex_release(&mutex_killBattery); rt_mutex_release(&mutex_killBattery);
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted=0;
rt_mutex_release(&mutex_robotStarted);
rt_sem_v(&sem_openComRobot); rt_sem_v(&sem_openComRobot);

View file

@ -6,8 +6,6 @@
</data> </data>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group> <group/>
<file>file:/home/raphael/Documents/real_time/software/simulateur/main.cpp</file>
</group>
</open-files> </open-files>
</project-private> </project-private>