Browse Source

Battery and stop

Lartigue Auriane 3 years ago
parent
commit
08bcb07f05

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

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

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


+ 38
- 0
software/raspberry/superviseur-robot/nbproject/private/timestamps-10.105.1.7-pi-22 View File

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

+ 51
- 7
software/raspberry/superviseur-robot/tasks.cpp View File

@@ -26,6 +26,7 @@
26 26
 #define PRIORITY_TRECEIVEFROMMON 25
27 27
 #define PRIORITY_TSTARTROBOT 20
28 28
 #define PRIORITY_TCAMERA 21
29
+#define PRIORITY_TBATTERY 31
29 30
 
30 31
 /*
31 32
  * Some remarks:
@@ -123,6 +124,10 @@ void Tasks::Init() {
123 124
         cerr << "Error task create: " << strerror(-err) << endl << flush;
124 125
         exit(EXIT_FAILURE);
125 126
     }
127
+    if (err = rt_task_create(&th_getBattery, "th_getBattery", 0, PRIORITY_TBATTERY, 0)) {
128
+        cerr << "Error task create: " << strerror(-err) << endl << flush;
129
+        exit(EXIT_FAILURE);
130
+    }
126 131
     cout << "Tasks created successfully" << endl << flush;
127 132
 
128 133
     /**************************************************************************************/
@@ -167,7 +172,11 @@ void Tasks::Run() {
167 172
         cerr << "Error task start: " << strerror(-err) << endl << flush;
168 173
         exit(EXIT_FAILURE);
169 174
     }
170
-
175
+    if (err = rt_task_start(&th_getBattery, (void(*)(void*)) & Tasks::ReadBattery, this)) {
176
+        cerr << "Error task start: " << strerror(-err) << endl << flush;
177
+        exit(EXIT_FAILURE);
178
+    }
179
+    
171 180
     cout << "Tasks launched" << endl << flush;
172 181
 }
173 182
 
@@ -351,6 +360,7 @@ void Tasks::StartRobotTask(void *arg) {
351 360
  */
352 361
 void Tasks::MoveTask(void *arg) {
353 362
     int rs;
363
+    int previousMove = MESSAGE_ROBOT_GO_FORWARD;
354 364
     int cpMove;
355 365
     
356 366
     cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
@@ -372,12 +382,15 @@ void Tasks::MoveTask(void *arg) {
372 382
             rt_mutex_acquire(&mutex_move, TM_INFINITE);
373 383
             cpMove = move;
374 384
             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);
385
+            if (cpMove != previousMove) {
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
+                
392
+                previousMove = cpMove;
393
+            }
381 394
         }
382 395
         cout << endl << flush;
383 396
     }
@@ -415,3 +428,34 @@ Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
415 428
     return msg;
416 429
 }
417 430
 
431
+void Tasks::ReadBattery(void *arg){    
432
+    cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
433
+    // Synchronization barrier (waiting that all tasks are starting)
434
+    rt_sem_p(&sem_barrier, TM_INFINITE);
435
+    
436
+    /**************************************************************************************/
437
+    /* The task starts here                                                               */
438
+    /**************************************************************************************/
439
+    rt_task_set_periodic(NULL, TM_NOW, 500000000);
440
+    
441
+    int rs;
442
+
443
+    while (1) {
444
+        rt_task_wait_period(NULL);
445
+        cout << "Periodic battery get lvl \n";
446
+        rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
447
+        rs = robotStarted;
448
+        rt_mutex_release(&mutex_robotStarted);
449
+        if (rs == 1) {
450
+            rt_mutex_acquire(&mutex_robot, TM_INFINITE);
451
+            Message *msg = robot.Write( robot.GetBattery() ) ; 
452
+            rt_mutex_release(&mutex_robot);
453
+            rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
454
+            monitor.Write(msg);
455
+            rt_mutex_release(&mutex_monitor);
456
+             
457
+        }
458
+       
459
+        cout << endl << flush;
460
+    }
461
+}

+ 9
- 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_getBattery;
79 80
     
80 81
     /**********************************************************************/
81 82
     /* Mutex                                                              */
@@ -148,6 +149,14 @@ private:
148 149
      * @return Message read
149 150
      */
150 151
     Message *ReadInQueue(RT_QUEUE *queue);
152
+    
153
+    
154
+    /**
155
+     * Read the battery level of the robot
156
+     * @return Nothing
157
+     */
158
+    void ReadBattery(void *arg);
159
+
151 160
 
152 161
 };
153 162
 

Loading…
Cancel
Save