Browse Source

Stop of robot fixed + baterry level thread ok

Tali Elies 9 months ago
parent
commit
13f4ed3548

+ 8
- 0
scriptRasp.sh View File

@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+#Mettre en argument son login
3
+
4
+login=$1
5
+numRasp=$2
6
+
7
+cd "~/.netbeans/remote/10.105.1.$2/insa-09146-Linux-x86_64/home/$1/Temps_Reel/dumber/software/raspberry/superviseur-robot/dist/Debug__RPI_/GNU-Linux"
8
+sudo ./superviseur-robot

+ 2
- 2
software/raspberry/superviseur-robot/nbproject/private/configurations.xml View File

@@ -41,8 +41,8 @@
41 41
     </conf>
42 42
     <conf name="Debug__RPI_" type="1">
43 43
       <toolsSet>
44
-        <developmentServer>pi@10.105.1.08:22</developmentServer>
45
-        <platform>2</platform>
44
+        <developmentServer>pi@10.105.1.01:22</developmentServer>
45
+        <platform>6</platform>
46 46
       </toolsSet>
47 47
       <dbx_gdbdebugger version="1">
48 48
         <gdb_pathmaps>

+ 0
- 0
software/raspberry/superviseur-robot/nbproject/private/downloads-10.105.1.01-pi-22 View File


+ 39
- 0
software/raspberry/superviseur-robot/nbproject/private/timestamps-10.105.1.01-pi-22 View File

@@ -0,0 +1,39 @@
1
+#Fri Feb 26 10:21:09 CET 2021
2
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/scriptRasp.sh=c1614326506000
3
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1614324985000
4
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1614324985000
5
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1614324985000
6
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1614324985000
7
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1614324985000
8
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1614324985000
9
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1614324985000
10
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1614324985000
11
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1614324985000
12
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.h=c1614330385000
13
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.h=c1614324985000
14
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1614324985000
15
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1614331264000
16
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1614324985000
17
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1614324985000
18
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1614324985000
19
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1614324985000
20
+VERSION=1.3
21
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1614324985000
22
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/README.md=c1614324985000
23
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1614324985000
24
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/.dep.inc=c1614324985000
25
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1614324985000
26
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1614324985000
27
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1614324985000
28
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1614325587000
29
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/Makefile=c1614324985000
30
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1614325587000
31
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1614325587000
32
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/.gitignore=c1614324985000
33
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1614324985000
34
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1614324985000
35
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1614324985000
36
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1614324985000
37
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1614324985000
38
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1614324985000
39
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/main.cpp=c1614324985000

+ 8
- 0
software/raspberry/superviseur-robot/scriptRasp.sh View File

@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+#Mettre en argument son login
3
+
4
+login=$1
5
+numRasp=$2
6
+
7
+cd "~/.netbeans/remote/10.105.1.$2/insa-09146-Linux-x86_64/home/$1/Temps_Reel/dumber/software/raspberry/superviseur-robot/dist/Debug__RPI_/GNU-Linux"
8
+sudo ./superviseur-robot

+ 55
- 9
software/raspberry/superviseur-robot/tasks.cpp View File

@@ -123,6 +123,10 @@ void Tasks::Init() {
123 123
         cerr << "Error task create: " << strerror(-err) << endl << flush;
124 124
         exit(EXIT_FAILURE);
125 125
     }
126
+    if (err = rt_task_create(&th_battery, "th_battery", 0, PRIORITY_TMOVE, 0)) {
127
+        cerr << "Error task create: " << strerror(-err) << endl << flush;
128
+        exit(EXIT_FAILURE);
129
+    }
126 130
     cout << "Tasks created successfully" << endl << flush;
127 131
 
128 132
     /**************************************************************************************/
@@ -167,6 +171,10 @@ void Tasks::Run() {
167 171
         cerr << "Error task start: " << strerror(-err) << endl << flush;
168 172
         exit(EXIT_FAILURE);
169 173
     }
174
+    if (err = rt_task_start(&th_battery, (void(*)(void*)) & Tasks::SendBattery, this)) {
175
+        cerr << "Error task start: " << strerror(-err) << endl << flush;
176
+        exit(EXIT_FAILURE);
177
+    }
170 178
 
171 179
     cout << "Tasks launched" << endl << flush;
172 180
 }
@@ -352,6 +360,7 @@ void Tasks::StartRobotTask(void *arg) {
352 360
 void Tasks::MoveTask(void *arg) {
353 361
     int rs;
354 362
     int cpMove;
363
+    int previousMove = -1;
355 364
     
356 365
     cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
357 366
     // Synchronization barrier (waiting that all tasks are starting)
@@ -369,15 +378,18 @@ void Tasks::MoveTask(void *arg) {
369 378
         rs = robotStarted;
370 379
         rt_mutex_release(&mutex_robotStarted);
371 380
         if (rs == 1) {
372
-            rt_mutex_acquire(&mutex_move, TM_INFINITE);
373
-            cpMove = move;
374
-            rt_mutex_release(&mutex_move);
375
-            
376
-            cout << " move: " << cpMove;
377
-            
378
-            rt_mutex_acquire(&mutex_robot, TM_INFINITE);
379
-            robot.Write(new Message((MessageID)cpMove));
380
-            rt_mutex_release(&mutex_robot);
381
+            if (!(previousMove == move)){
382
+                rt_mutex_acquire(&mutex_move, TM_INFINITE);
383
+                cpMove = move;
384
+                rt_mutex_release(&mutex_move);
385
+
386
+                cout << " move: " << cpMove;
387
+
388
+                rt_mutex_acquire(&mutex_robot, TM_INFINITE);
389
+                robot.Write(new Message((MessageID)cpMove));
390
+                rt_mutex_release(&mutex_robot);
391
+                previousMove = cpMove;
392
+            }
381 393
         }
382 394
         cout << endl << flush;
383 395
     }
@@ -415,3 +427,37 @@ Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
415 427
     return msg;
416 428
 }
417 429
 
430
+void Tasks::SendBattery(void *arg){
431
+    int rs;
432
+    Message * responseBattery;
433
+    
434
+    cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
435
+    // Synchronization barrier (waiting that all tasks are starting)
436
+    rt_sem_p(&sem_barrier, TM_INFINITE);
437
+    
438
+    /**************************************************************************************/
439
+    /* The task starts here                                                               */
440
+    /**************************************************************************************/
441
+    rt_task_set_periodic(NULL, TM_NOW, 500000000);
442
+    
443
+    while(1){
444
+        rt_task_wait_period(NULL);
445
+        rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
446
+        rs = robotStarted;
447
+        rt_mutex_release(&mutex_robotStarted);
448
+        cout << "Periodic battery update before rs" << endl << flush;
449
+        if (rs){
450
+            cout << "Periodic battery update" << endl << flush;
451
+
452
+            rt_mutex_acquire(&mutex_robot, TM_INFINITE);
453
+            responseBattery = robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET));
454
+            rt_mutex_release(&mutex_robot);
455
+            
456
+            cout << "Periodic battery update before comparing message" << endl << flush;
457
+            if (responseBattery->CompareID(MESSAGE_ROBOT_BATTERY_LEVEL)){
458
+                WriteInQueue(&q_messageToMon,responseBattery);
459
+            }
460
+        }
461
+        cout << endl << flush;
462
+    }
463
+}

+ 7
- 0
software/raspberry/superviseur-robot/tasks.h View File

@@ -76,6 +76,7 @@ private:
76 76
     RT_TASK th_openComRobot;
77 77
     RT_TASK th_startRobot;
78 78
     RT_TASK th_move;
79
+    RT_TASK th_battery;
79 80
     
80 81
     /**********************************************************************/
81 82
     /* Mutex                                                              */
@@ -132,6 +133,12 @@ private:
132 133
      */
133 134
     void MoveTask(void *arg);
134 135
     
136
+        
137
+    /**
138
+     * @brief Thread to get battery from robot and send it to the monitor (every 500ms)
139
+     */
140
+    void SendBattery(void *arg);
141
+    
135 142
     /**********************************************************************/
136 143
     /* Queue services                                                     */
137 144
     /**********************************************************************/

Loading…
Cancel
Save