Browse Source

images are now sent using base64. 40fps on localhost, test to be done on raspberry

Sébastien DI MERCURIO 5 years ago
parent
commit
8bf6c73dbb
40 changed files with 1021 additions and 1289 deletions
  1. 0
    16
      .vscode/c_cpp_properties.json
  2. 0
    16
      .vscode/tasks.json
  3. 143
    25
      software/monitor/monitor/Client.cs
  4. 4
    4
      software/monitor/monitor/CommandManager.cs
  5. 215
    96
      software/monitor/monitor/DestijlCommandManager.cs
  6. 130
    59
      software/monitor/monitor/MonitorUI.cs
  7. BIN
      software/monitor/monitor/monitor
  8. 0
    5
      software/raspberry/superviseur-robot/.dep.inc
  9. 0
    1
      software/raspberry/superviseur-robot/.idea/.name
  10. 0
    29
      software/raspberry/superviseur-robot/.idea/codeStyles/Project.xml
  11. 0
    7
      software/raspberry/superviseur-robot/.idea/misc.xml
  12. 0
    8
      software/raspberry/superviseur-robot/.idea/modules.xml
  13. 0
    2
      software/raspberry/superviseur-robot/.idea/superviseur-robot.iml
  14. 0
    6
      software/raspberry/superviseur-robot/.idea/vcs.xml
  15. 0
    864
      software/raspberry/superviseur-robot/.idea/workspace.xml
  16. BIN
      software/raspberry/superviseur-robot/dist/Debug__Pthread_/GNU-Linux/superviseur-robot
  17. 2
    0
      software/raspberry/superviseur-robot/lib/base64/.gitignore
  18. 19
    0
      software/raspberry/superviseur-robot/lib/base64/LICENSE
  19. 7
    0
      software/raspberry/superviseur-robot/lib/base64/README.md
  20. 122
    0
      software/raspberry/superviseur-robot/lib/base64/base64.cpp
  21. 14
    0
      software/raspberry/superviseur-robot/lib/base64/base64.h
  22. 2
    0
      software/raspberry/superviseur-robot/lib/base64/compile-and-run-test
  23. 56
    0
      software/raspberry/superviseur-robot/lib/base64/test.cpp
  24. 23
    23
      software/raspberry/superviseur-robot/lib/camera.cpp
  25. 8
    10
      software/raspberry/superviseur-robot/lib/camera.h
  26. 34
    14
      software/raspberry/superviseur-robot/lib/commonitor.cpp
  27. 3
    3
      software/raspberry/superviseur-robot/lib/commonitor.h
  28. 30
    34
      software/raspberry/superviseur-robot/lib/img.cpp
  29. 15
    16
      software/raspberry/superviseur-robot/lib/img.h
  30. 3
    3
      software/raspberry/superviseur-robot/lib/messages.cpp
  31. 5
    5
      software/raspberry/superviseur-robot/lib/messages.h
  32. 4
    3
      software/raspberry/superviseur-robot/main.cpp
  33. 6
    0
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug.mk
  34. 6
    0
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug__Pthread_.mk
  35. 6
    0
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk
  36. 6
    0
      software/raspberry/superviseur-robot/nbproject/Makefile-Release.mk
  37. 42
    0
      software/raspberry/superviseur-robot/nbproject/configurations.xml
  38. 1
    2
      software/raspberry/superviseur-robot/nbproject/private/private.xml
  39. 112
    38
      software/raspberry/superviseur-robot/tasks_pthread.cpp
  40. 3
    0
      software/raspberry/superviseur-robot/tasks_pthread.h

+ 0
- 16
.vscode/c_cpp_properties.json View File

@@ -1,16 +0,0 @@
1
-{
2
-    "configurations": [
3
-        {
4
-            "name": "Linux",
5
-            "includePath": [
6
-                "${workspaceFolder}/**"
7
-            ],
8
-            "defines": [],
9
-            "compilerPath": "/usr/bin/clang",
10
-            "cStandard": "c11",
11
-            "cppStandard": "c++17",
12
-            "intelliSenseMode": "clang-x64"
13
-        }
14
-    ],
15
-    "version": 4
16
-}

+ 0
- 16
.vscode/tasks.json View File

@@ -1,16 +0,0 @@
1
-{
2
-  // See https://go.microsoft.com/fwlink/?LinkId=733558
3
-    // for the documentation about the tasks.json format
4
-    "version": "2.0.0",
5
-    "tasks": [
6
-        {
7
-            "taskName": "Compile on raspberry",
8
-            "command": "rsync -az '${file}' 10.105.1.6:~ && ssh server.example.org 'chmod +x ./${fileBasename}; ./${fileBasename}'",
9
-            "type": "shell",
10
-            "group": {
11
-                "kind": "build",
12
-                "isDefault": true
13
-            }
14
-        }
15
-    ]
16
-}

+ 143
- 25
software/monitor/monitor/Client.cs View File

@@ -23,6 +23,8 @@ using System;
23 23
 using System.Net.Sockets;
24 24
 using System.Text;
25 25
 
26
+using System.Threading;
27
+
26 28
 namespace monitor
27 29
 {
28 30
     /// <summary>
@@ -66,22 +68,27 @@ namespace monitor
66 68
         /// </summary>
67 69
         private static byte[] receiveBuffer;
68 70
 
69
-        private static int initialReceiveBufferIndex = 0;
71
+        //private static int initialReceiveBufferIndex = 0;
70 72
 
71 73
         /// <summary>
72 74
         /// String containing received message from tcp server
73 75
         /// </summary>
74 76
         private static StringBuilder message = new StringBuilder();
75
-        private static int newLength = 1;
76
-        private static int packetCounter = 0;
77
+        //private static int newLength = 1;
78
+        //private static int packetCounter = 0;
77 79
 
78 80
         /// <summary>
79 81
         /// Callback to send received message to upper level
80 82
         /// </summary>
81
-        public delegate void ReadEvent(string msg, byte[] buffer);
83
+        public delegate void ReadEvent(string msg);
82 84
         public static ReadEvent readEvent = null;
83 85
 
84 86
         /// <summary>
87
+        /// Thread used in reception
88
+        /// </summary>
89
+        private static Thread readThread;
90
+
91
+        /// <summary>
85 92
         /// Open connection to server "host", on default port number.
86 93
         /// </summary>
87 94
         /// <returns>true if connection succeded, false otherwise</returns>
@@ -114,7 +121,12 @@ namespace monitor
114 121
 
115 122
                 // received data are stored in buffer
116 123
                 // Next reading will be done in ReadCallback method
117
-                stream.BeginRead(buffer, 0, newLength, new AsyncCallback(ReadCallback), message);
124
+                stream.BeginRead(buffer, 0, 1, new AsyncCallback(ReadCallback), message);
125
+
126
+                // Start reading thread
127
+                //message.Clear();
128
+                //readThread = new Thread(new ThreadStart(ReadCallback));
129
+                //readThread.Start();
118 130
             }
119 131
             catch (ArgumentNullException e)
120 132
             {
@@ -147,16 +159,139 @@ namespace monitor
147 159
         /// <summary>
148 160
         /// Callback call by stream.BeginRead after reception of newLength data
149 161
         /// </summary>
162
+        //private static void ReadCallback()
163
+        //{
164
+        //    char character;
165
+        //    int data;
166
+        //    byte[] buffer=new byte[4096];
167
+        //    int lengthRead;
168
+
169
+        //    while (client.Connected)
170
+        //    {
171
+        //        try
172
+        //        {
173
+        //            //data = stream.ReadByte();
174
+        //            lengthRead = stream.Read(buffer, 0, buffer.Length);
175
+        //        }
176
+        //        catch (ObjectDisposedException)
177
+        //        {
178
+        //            Console.WriteLine("Connection to server dropped (object disposed)!");
179
+        //            return;
180
+        //        }
181
+        //        catch (System.IO.IOException)
182
+        //        {
183
+        //            Console.WriteLine("Connection to server dropped (other error)");
184
+        //            return;
185
+        //        }
186
+
187
+        //        if (lengthRead > 0) // a data was read
188
+        //        {
189
+        //            //character = (char)data;
190
+        //            var str = System.Text.Encoding.Default.GetString(buffer);
191
+        //            int indexOf = str.IndexOf('\n');
192
+
193
+        //            //if (character != '\n')
194
+        //            if (indexOf == -1) // \n doesn't exists
195
+        //            {
196
+        //                message.Append(str);
197
+
198
+        //                //if (receiveBuffer == null) receiveBuffer = new byte[1];
199
+        //                //else Array.Resize<byte>(ref receiveBuffer, receiveBuffer.Length + 1); // resize currrent buffer
200
+
201
+        //                //receiveBuffer[receiveBuffer.Length - 1] = (byte)data;
202
+        //            }
203
+        //            else // end of string found
204
+        //            {
205
+        //                message.Append((str.Substring(0,indexOf)));
206
+        //                readEvent?.Invoke(message.ToString(), receiveBuffer);
207
+
208
+        //                message.Clear();
209
+        //                receiveBuffer = null;
210
+        //            }
211
+        //        }
212
+        //    }
213
+        //}
214
+
215
+        /// <summary>
216
+        /// Callback call by stream.BeginRead after reception of newLength data
217
+        /// </summary>
150 218
         /// <param name="ar">Not sure of what is it, but needed for terminate reading</param>
219
+        //private static void ReadCallback(IAsyncResult ar)
220
+        //{
221
+        //    if (client.Connected)
222
+        //    {
223
+        //        int bytesRead;
224
+
225
+        //        try
226
+        //        {
227
+        //            // Termintae read operation, and get number of byte stored in buffer
228
+        //            bytesRead = stream.EndRead(ar);
229
+        //        }
230
+        //        catch (ObjectDisposedException e)
231
+        //        {
232
+        //            Console.WriteLine("Connection to server dropped: " + e.ToString());
233
+        //            return;
234
+        //        }
235
+
236
+        //        newLength = 1;
237
+
238
+        //        // if number of byte read is not 0, concatenate string and buffer
239
+        //        if (bytesRead > 0)
240
+        //        {
241
+        //            packetCounter++;
242
+
243
+        //            if (packetCounter >= 3)
244
+        //            {
245
+        //                //Console.WriteLine("Supplementary packet " + packetCounter);
246
+        //            }
247
+
248
+        //            // Append new data to current string (expecting data are ascii)
249
+        //            message.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead));
250
+
251
+        //            // Similarly, append received bytes to current buffer 
252
+        //            if (receiveBuffer == null) receiveBuffer = new byte[bytesRead];
253
+        //            else Array.Resize<byte>(ref receiveBuffer, initialReceiveBufferIndex + bytesRead); // resize currrent buffer
254
+
255
+        //            System.Buffer.BlockCopy(buffer, 0, receiveBuffer, initialReceiveBufferIndex, bytesRead); // and add received data
256
+        //            initialReceiveBufferIndex = receiveBuffer.Length; // move last index of current buffer
257
+        //        }
258
+
259
+        //        // if it remains received data, prepare for a new reading (get another buffer to append to current one)
260
+        //        if (client.Available > 0)
261
+        //        {
262
+        //            newLength = client.Available;
263
+        //            if (newLength > BufferMaxSize) newLength = BufferMaxSize;
264
+        //            else newLength = client.Available;
265
+        //        }
266
+        //        else
267
+        //        {
268
+        //            // no more data to read, buffer and string can be send to upper level
269
+        //            readEvent?.Invoke(message.ToString(), receiveBuffer);
270
+
271
+        //            message.Clear();
272
+        //            receiveBuffer = null;
273
+        //            initialReceiveBufferIndex = 0;
274
+        //            packetCounter = 0;
275
+        //        }
276
+
277
+        //        // Prepare for reading new data
278
+        //        if (newLength> BufferMaxSize) newLength = BufferMaxSize;
279
+        //        if (newLength <= 0) newLength = 1;
280
+        //        stream.BeginRead(buffer, 0, newLength, new AsyncCallback(ReadCallback), message);
281
+        //    }
282
+        //}
283
+
151 284
         private static void ReadCallback(IAsyncResult ar)
152 285
         {
286
+            int newLength = 1;
287
+
153 288
             if (client.Connected)
154 289
             {
155 290
                 int bytesRead;
156 291
 
157 292
                 try
158 293
                 {
159
-                    // Termintae read operation, and get number of byte stored in buffer
294
+                    // Terminate read operation, and get number of byte stored in buffer
160 295
                     bytesRead = stream.EndRead(ar);
161 296
                 }
162 297
                 catch (ObjectDisposedException e)
@@ -165,27 +300,13 @@ namespace monitor
165 300
                     return;
166 301
                 }
167 302
 
168
-                newLength = 1;
303
+                //newLength = 1;
169 304
 
170 305
                 // if number of byte read is not 0, concatenate string and buffer
171 306
                 if (bytesRead > 0)
172 307
                 {
173
-                    packetCounter++;
174
-
175
-                    if (packetCounter >= 3)
176
-                    {
177
-                        //Console.WriteLine("Supplementary packet " + packetCounter);
178
-                    }
179
-
180 308
                     // Append new data to current string (expecting data are ascii)
181 309
                     message.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead));
182
-
183
-                    // Similarly, append received bytes to current buffer 
184
-                    if (receiveBuffer == null) receiveBuffer = new byte[bytesRead];
185
-                    else Array.Resize<byte>(ref receiveBuffer, initialReceiveBufferIndex + bytesRead); // resize currrent buffer
186
-
187
-                    System.Buffer.BlockCopy(buffer, 0, receiveBuffer, initialReceiveBufferIndex, bytesRead); // and add received data
188
-                    initialReceiveBufferIndex = receiveBuffer.Length; // move last index of current buffer
189 310
                 }
190 311
 
191 312
                 // if it remains received data, prepare for a new reading (get another buffer to append to current one)
@@ -198,12 +319,9 @@ namespace monitor
198 319
                 else
199 320
                 {
200 321
                     // no more data to read, buffer and string can be send to upper level
201
-                    readEvent?.Invoke(message.ToString(), receiveBuffer);
322
+                    readEvent?.Invoke(message.ToString());
202 323
 
203 324
                     message.Clear();
204
-                    receiveBuffer = null;
205
-                    initialReceiveBufferIndex = 0;
206
-                    packetCounter = 0;
207 325
                 }
208 326
 
209 327
                 // Prepare for reading new data

+ 4
- 4
software/monitor/monitor/CommandManager.cs View File

@@ -33,7 +33,7 @@ namespace monitor
33 33
         /// <summary>
34 34
         /// Callback for sending received data to upper level
35 35
         /// </summary>
36
-        public delegate void CommandReceivedEvent(string msg, byte[] buffer);
36
+        public delegate void CommandReceivedEvent(string msg);
37 37
         public CommandReceivedEvent commandReceivedEvent = null;
38 38
 
39 39
         /// <summary>
@@ -122,7 +122,7 @@ namespace monitor
122 122
         /// </summary>
123 123
         /// <param name="message">Message received from server</param>
124 124
         /// <param name="buffer">Raw buffer reived from server</param>
125
-        private void OnMessageReception(string message, byte[] buffer)
125
+        private void OnMessageReception(string message)
126 126
         {
127 127
             waitTimer.Stop(); // Stop timeout stopwatch
128 128
 
@@ -144,7 +144,7 @@ namespace monitor
144 144
                 
145 145
                 waitForAcknowledge = false;
146 146
 
147
-                this.commandReceivedEvent?.Invoke(message, buffer);
147
+                this.commandReceivedEvent?.Invoke(message);
148 148
             }
149 149
         }
150 150
 
@@ -158,7 +158,7 @@ namespace monitor
158 158
             messageReceived = null;
159 159
             // set buffer and message as null to indicate that no message was received
160 160
             // and call to OnMessagereception is due to timeout
161
-            OnMessageReception(messageReceived, null);
161
+            OnMessageReception(messageReceived);
162 162
         }
163 163
 
164 164
         /// <summary>

+ 215
- 96
software/monitor/monitor/DestijlCommandManager.cs View File

@@ -20,6 +20,7 @@
20 20
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 21
 
22 22
 using System;
23
+using System.Globalization;
23 24
 
24 25
 namespace monitor
25 26
 {
@@ -28,47 +29,84 @@ namespace monitor
28 29
     /// </summary>
29 30
     public static class DestijlCommandList
30 31
     {
31
-        public const string HeaderMtsComDmb = "COM";
32
-        public const string HeaderMtsDmbOrder = "DMB";
33
-        public const string HeaderMtsCamera = "CAM";
34
-        public const string HeaderMtsMessage = "MSG";
35
-
36
-        public const string DataComOpen = "o";
37
-        public const string DataComClose = "C";
38
-
39
-        public const string DataCamOpen = "A";
40
-        public const string DataCamClose = "I";
41
-        public const string DataCamAskArena = "y";
42
-        public const string DataCamArenaConfirm = "x";
43
-        public const string DataCamInfirm = "z";
44
-        public const string DataCamComputePosition = "p";
45
-        public const string DataCamStopComputePosition = "s";
46
-
47
-        public const string HeaderStmAck = "ACK";
48
-        public const string HeaderStmNoAck = "NAK";
49
-        public const string HeaderStmLostDmb = "LCD";
50
-        public const string HeaderStmImage = "IMG";
51
-        public const string HeaderStmPos = "POS";
52
-        public const string HeaderStmMes = "MSG";
53
-        public const string HeaderStmBat = "BAT";
32
+        public const string ANSWER_ACK = "AACK";
33
+        public const string ANSWER_NACK = "ANAK";
34
+        public const string ANSWER_COM_ERROR = "ACER";
35
+        public const string ANSWER_TIMEOUT = "ATIM";
36
+        public const string ANSWER_CMD_REJECTED = "ACRJ";
37
+        public const string MESSAGE = "MSSG";
38
+        public const string CAMERA_OPEN = "COPN";
39
+        public const string CAMERA_CLOSE = "CCLS";
40
+        public const string CAMERA_IMAGE = "CIMG";
41
+        public const string CAMERA_ARENA_ASK = "CASA";
42
+        public const string CAMERA_ARENA_INFIRM = "CAIN";
43
+        public const string CAMERA_ARENA_CONFIRM = "CACO";
44
+        public const string CAMERA_POSITION_COMPUTE = "CPCO";
45
+        public const string CAMERA_POSITION_STOP = "CPST";
46
+        public const string CAMERA_POSITION = "CPOS";
47
+        public const string ROBOT_COM_OPEN = "ROPN";
48
+        public const string ROBOT_COM_CLOSE = "RCLS";
49
+        public const string ROBOT_PING = "RPIN";
50
+        public const string ROBOT_RESET = "RRST";
51
+        public const string ROBOT_START_WITHOUT_WD = "RSOW";
52
+        public const string ROBOT_START_WITH_WD = "RSWW";
53
+        public const string ROBOT_RELOAD_WD = "RLDW";
54
+        public const string ROBOT_MOVE = "RMOV";
55
+        public const string ROBOT_TURN = "RTRN";
56
+        public const string ROBOT_GO_FORWARD = "RGFW";
57
+        public const string ROBOT_GO_BACKWARD = "RGBW";
58
+        public const string ROBOT_GO_LEFT = "RGLF";
59
+        public const string ROBOT_GO_RIGHT = "RGRI";
60
+        public const string ROBOT_STOP = "RSTP";
61
+        public const string ROBOT_POWEROFF = "RPOF";
62
+        public const string ROBOT_BATTERY_LEVEL = "RBLV";
63
+        public const string ROBOT_GET_BATTERY = "RGBT";
64
+        public const string ROBOT_GET_STATE = "RGST";
65
+        public const string ROBOT_CURRENT_STATE = "RCST";
66
+
67
+        public const char SEPARATOR_CHAR = ':';
68
+
69
+        //public const string HeaderMtsComDmb = "COM";
70
+        //public const string HeaderMtsDmbOrder = "DMB";
71
+        //public const string HeaderMtsCamera = "CAM";
72
+        //public const string HeaderMtsMessage = "MSG";
73
+
74
+        //public const string DataComOpen = "o";
75
+        //public const string DataComClose = "C";
76
+
77
+        //public const string DataCamOpen = "A";
78
+        //public const string DataCamClose = "I";
79
+        //public const string DataCamAskArena = "y";
80
+        //public const string DataCamArenaConfirm = "x";
81
+        //public const string DataCamInfirm = "z";
82
+        //public const string DataCamComputePosition = "p";
83
+        //public const string DataCamStopComputePosition = "s";
84
+
85
+        //public const string HeaderStmAck = "ACK";
86
+        //public const string HeaderStmNoAck = "NAK";
87
+        //public const string HeaderStmLostDmb = "LCD";
88
+        //public const string HeaderStmImage = "IMG";
89
+        //public const string HeaderStmPos = "POS";
90
+        //public const string HeaderStmMes = "MSG";
91
+        //public const string HeaderStmBat = "BAT";
54 92
     }
55 93
 
56 94
     /// <summary>
57 95
     /// Commands used for robot messages
58 96
     /// </summary>
59
-    public static class RobotCommandList
60
-    {
61
-        public const string RobotPing = "p";
62
-        public const string RobotReset = "r";
63
-        public const string RobotStartWithoutWatchdog = "u";
64
-        public const string RobotStartWithWatchdog = "W";
65
-        public const string RobotGetBattery = "v";
66
-        public const string RobotGetBusyState = "b";
67
-        public const string RobotMove = "M";
68
-        public const string RobotTurn = "T";
69
-        public const string RobotGetVersion = "V";
70
-        public const string RobotPowerOff = "z";
71
-    }
97
+    //public static class RobotCommandList
98
+    //{
99
+    //    public const string RobotPing = "p";
100
+    //    public const string RobotReset = "r";
101
+    //    public const string RobotStartWithoutWatchdog = "u";
102
+    //    public const string RobotStartWithWatchdog = "W";
103
+    //    public const string RobotGetBattery = "v";
104
+    //    public const string RobotGetBusyState = "b";
105
+    //    public const string RobotMove = "M";
106
+    //    public const string RobotTurn = "T";
107
+    //    public const string RobotGetVersion = "V";
108
+    //    public const string RobotPowerOff = "z";
109
+    //}
72 110
 
73 111
     /// <summary>
74 112
     /// Specialization class for command manager, which implemnent destijl protocol between monitor and server
@@ -93,7 +131,7 @@ namespace monitor
93 131
         /// <summary>
94 132
         /// Callback for sending received data to application level
95 133
         /// </summary>
96
-        public delegate void CommandReceivedEvent(string header, string data, byte[] buffer);
134
+        public delegate void CommandReceivedEvent(string header, string data);
97 135
         public CommandReceivedEvent commandReceivedEvent = null;
98 136
 
99 137
         /// <summary>
@@ -114,6 +152,34 @@ namespace monitor
114 152
             CommunicationLostWithServer
115 153
         }
116 154
 
155
+        public struct Point {
156
+            public double x;
157
+            public double y;
158
+        } 
159
+
160
+        public class Position {
161
+            public int robotID;
162
+            public double angle;
163
+            public Point centre;
164
+            public Point direction;
165
+
166
+            public Position() {
167
+                robotID = 0;
168
+                angle = 0.0;
169
+                centre.x = 0.0;
170
+                centre.y = 0.0;
171
+                direction.x = 0.0;
172
+                direction.y = 0.0;
173
+            }
174
+
175
+            public override string ToString() {
176
+                string s = "ID: " + robotID + ", Angle: " + angle +
177
+                    ", Centre (x: " + centre.x + ", y: " + centre.y +
178
+                                          "), Direction (x: " + direction.x + ", y: " + direction.y + ")";
179
+                return s;
180
+            }
181
+        }
182
+
117 183
         /// <summary>
118 184
         /// Initializes a new instance of the <see cref="monitor.DestijlCommandManager"/> class.
119 185
         /// </summary>
@@ -138,10 +204,13 @@ namespace monitor
138 204
         /// </summary>
139 205
         /// <param name="msg">String containing received message</param>
140 206
         /// <param name="buffer">Raw buffer to be used when data are not in ascii format (image for example)</param>
141
-        private void OnCommandReceived(string msg, byte[] buffer)
207
+        private void OnCommandReceived(string msg)
142 208
         {
143
-            // Firstly, split message in (at least) two part : header, and data
144
-            string[] msgs = msg.Split(':');
209
+            // Firstly, remove ending \n and everything after
210
+            string[] msgsCarriageReturn = msg.Split('\n');
211
+
212
+            // Second, split message in (at least) two part : header, and data
213
+            string[] msgs = msgsCarriageReturn[0].Split(DestijlCommandList.SEPARATOR_CHAR);
145 214
 
146 215
             // If it exist at least on element in string array, it should be command header
147 216
             if (msgs.Length >= 1) receivedHeader = msgs[0];
@@ -152,7 +221,7 @@ namespace monitor
152 221
             else receivedData = null;
153 222
 
154 223
             // when split is done, provide data to application
155
-            this.commandReceivedEvent?.Invoke(receivedHeader, receivedData, buffer);
224
+            this.commandReceivedEvent?.Invoke(receivedHeader, receivedData);
156 225
         }
157 226
 
158 227
         /// <summary>
@@ -193,7 +262,17 @@ namespace monitor
193 262
         /// <param name="data">Data part of the command</param>
194 263
         private string CreateCommand(string header, string data)
195 264
         {
196
-            return header + ":" + data;
265
+            return header + DestijlCommandList.SEPARATOR_CHAR + data+"\n";
266
+        }
267
+
268
+        /// <summary>
269
+        /// Creates the command to send to server, based on header
270
+        /// </summary>
271
+        /// <returns>The command string</returns>
272
+        /// <param name="header">Header part of the command</param>
273
+        private string CreateCommand(string header)
274
+        {
275
+            return header + DestijlCommandList.SEPARATOR_CHAR+"\n";
197 276
         }
198 277
 
199 278
         /// <summary>
@@ -215,9 +294,9 @@ namespace monitor
215 294
                 if (answer != null)
216 295
                 {
217 296
                     // if command is not acknowledged, return Rejected
218
-                    if (answer.ToUpper().Contains(DestijlCommandList.HeaderStmNoAck)) status = CommandStatus.Rejected;
297
+                    if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_NACK)) status = CommandStatus.Rejected;
219 298
                     // if communication is lost with robot, return CommunicationLostWithRobot
220
-                    else if (answer.ToUpper().Contains(DestijlCommandList.HeaderStmLostDmb)) status = CommandStatus.CommunicationLostWithRobot;
299
+                    else if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_TIMEOUT)) status = CommandStatus.CommunicationLostWithRobot;
221 300
                     // if answer is empty, communication with robot is lost
222 301
                     else if (answer.Length == 0) status = CommandStatus.CommunicationLostWithServer;
223 302
                     //else status = CommandStatus.InvalidAnswer;
@@ -237,7 +316,7 @@ namespace monitor
237 316
             string answer;
238 317
 
239 318
             localStatus = commandManager.SendCommand(
240
-                CreateCommand(DestijlCommandList.HeaderMtsComDmb, DestijlCommandList.DataComOpen),
319
+                CreateCommand(DestijlCommandList.ROBOT_COM_OPEN),
241 320
                 out answer,
242 321
                 this.timeout);
243 322
 
@@ -254,7 +333,7 @@ namespace monitor
254 333
             string answer;
255 334
 
256 335
             localStatus = commandManager.SendCommand(
257
-                CreateCommand(DestijlCommandList.HeaderMtsComDmb, DestijlCommandList.DataComClose),
336
+                CreateCommand(DestijlCommandList.ROBOT_COM_CLOSE),
258 337
                 out answer,
259 338
                 this.timeout);
260 339
 
@@ -271,7 +350,7 @@ namespace monitor
271 350
             string answer;
272 351
 
273 352
             localStatus = commandManager.SendCommand(
274
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotPing),
353
+                CreateCommand(DestijlCommandList.ROBOT_PING),
275 354
                 out answer,
276 355
                 this.timeout);
277 356
 
@@ -288,7 +367,7 @@ namespace monitor
288 367
             string answer;
289 368
 
290 369
             localStatus = commandManager.SendCommand(
291
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotReset),
370
+                CreateCommand(DestijlCommandList.ROBOT_RESET),
292 371
                 out answer,
293 372
                 0);
294 373
 
@@ -305,7 +384,7 @@ namespace monitor
305 384
             string answer;
306 385
 
307 386
             localStatus = commandManager.SendCommand(
308
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotStartWithWatchdog),
387
+                CreateCommand(DestijlCommandList.ROBOT_START_WITH_WD),
309 388
                 out answer,
310 389
                 this.timeout);
311 390
 
@@ -322,7 +401,7 @@ namespace monitor
322 401
             string answer;
323 402
 
324 403
             localStatus = commandManager.SendCommand(
325
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotStartWithoutWatchdog),
404
+                CreateCommand(DestijlCommandList.ROBOT_START_WITHOUT_WD),
326 405
                 out answer,
327 406
                 this.timeout);
328 407
 
@@ -340,7 +419,7 @@ namespace monitor
340 419
             string answer;
341 420
 
342 421
             localStatus = commandManager.SendCommand(
343
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotMove + "=" + distance),
422
+                CreateCommand(DestijlCommandList.ROBOT_MOVE, Convert.ToString(distance)),
344 423
                 out answer,
345 424
                 0);
346 425
 
@@ -358,7 +437,7 @@ namespace monitor
358 437
             string answer;
359 438
 
360 439
             localStatus = commandManager.SendCommand(
361
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotTurn + "=" + angle),
440
+                CreateCommand(DestijlCommandList.ROBOT_TURN, Convert.ToString(angle)),
362 441
                 out answer,
363 442
                 0);
364 443
 
@@ -375,7 +454,7 @@ namespace monitor
375 454
             string answer;
376 455
 
377 456
             localStatus = commandManager.SendCommand(
378
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotGetBattery),
457
+                CreateCommand(DestijlCommandList.ROBOT_GET_BATTERY),
379 458
                 out answer,
380 459
                 0);
381 460
 
@@ -383,41 +462,6 @@ namespace monitor
383 462
         }
384 463
 
385 464
         /// <summary>
386
-        /// Request robot firmware version
387
-        /// </summary>
388
-        /// <returns>Command status (see DecodeStatus)</returns>
389
-        /// <param name="version">todo</param>
390
-        public CommandStatus RobotGetVersion(out string version)
391
-        {
392
-            CommandManager.CommandManagerStatus localStatus;
393
-            CommandStatus status = CommandStatus.Success;
394
-            version = "";
395
-
396
-            string answer;
397
-
398
-            localStatus = commandManager.SendCommand(
399
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotGetVersion),
400
-                out answer,
401
-                this.timeout);
402
-
403
-            if (localStatus == CommandManager.CommandManagerStatus.AnswerReceived)
404
-            {
405
-                string[] msg = answer.Split(':');
406
-
407
-                if (msg.Length > 1)
408
-                {
409
-                    version = msg[1];
410
-                }
411
-            }
412
-            else if (localStatus == CommandManager.CommandManagerStatus.Timeout)
413
-            {
414
-                status = CommandStatus.CommunicationLostWithServer;
415
-            }
416
-
417
-            return status;
418
-        }
419
-
420
-        /// <summary>
421 465
         /// Power off robot
422 466
         /// </summary>
423 467
         /// <returns>Command status (see DecodeStatus)</returns>
@@ -427,7 +471,7 @@ namespace monitor
427 471
             string answer;
428 472
 
429 473
             localStatus = commandManager.SendCommand(
430
-                CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotPowerOff),
474
+                CreateCommand(DestijlCommandList.ROBOT_POWEROFF),
431 475
                 out answer,
432 476
                 0);
433 477
 
@@ -444,7 +488,7 @@ namespace monitor
444 488
             string answer;
445 489
 
446 490
             localStatus = commandManager.SendCommand(
447
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamOpen),
491
+                CreateCommand(DestijlCommandList.CAMERA_OPEN),
448 492
                 out answer,
449 493
                 this.timeout);
450 494
 
@@ -461,7 +505,7 @@ namespace monitor
461 505
             string answer;
462 506
 
463 507
             localStatus = commandManager.SendCommand(
464
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamClose),
508
+                CreateCommand(DestijlCommandList.CAMERA_CLOSE),
465 509
                 out answer,
466 510
                 0);
467 511
 
@@ -478,7 +522,7 @@ namespace monitor
478 522
             string answer;
479 523
 
480 524
             localStatus = commandManager.SendCommand(
481
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamAskArena),
525
+                CreateCommand(DestijlCommandList.CAMERA_ARENA_ASK),
482 526
                 out answer,
483 527
                 0);
484 528
 
@@ -495,7 +539,7 @@ namespace monitor
495 539
             string answer;
496 540
 
497 541
             localStatus = commandManager.SendCommand(
498
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamArenaConfirm),
542
+                CreateCommand(DestijlCommandList.CAMERA_ARENA_CONFIRM),
499 543
                 out answer,
500 544
                 0);
501 545
 
@@ -512,7 +556,7 @@ namespace monitor
512 556
             string answer;
513 557
 
514 558
             localStatus = commandManager.SendCommand(
515
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamInfirm),
559
+                CreateCommand(DestijlCommandList.CAMERA_ARENA_INFIRM),
516 560
                 out answer,
517 561
                 0);
518 562
 
@@ -529,7 +573,7 @@ namespace monitor
529 573
             string answer;
530 574
 
531 575
             localStatus = commandManager.SendCommand(
532
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamComputePosition),
576
+                CreateCommand(DestijlCommandList.CAMERA_POSITION_COMPUTE),
533 577
                 out answer,
534 578
                 0);
535 579
 
@@ -546,11 +590,86 @@ namespace monitor
546 590
             string answer;
547 591
 
548 592
             localStatus = commandManager.SendCommand(
549
-                CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamStopComputePosition),
593
+                CreateCommand(DestijlCommandList.CAMERA_POSITION_STOP),
550 594
                 out answer,
551 595
                 0);
552 596
 
553 597
             return DecodeStatus(localStatus, answer);
554 598
         }
599
+
600
+        public static Position DecodePosition(string data) {
601
+            Position pos = new Position();
602
+
603
+            pos.robotID = 0;
604
+            pos.angle = 0.0;
605
+            pos.centre.x = 0.0; 
606
+            pos.centre.y=0.0;
607
+            pos.direction.x = 0.0;
608
+            pos.direction.y = 0.0;
609
+
610
+            string[] parts = data.Split(';');
611
+
612
+            //for (int i = 0; i < parts.Length; i++) {
613
+            //    Console.WriteLine(parts[i]);
614
+            //}
615
+
616
+            NumberFormatInfo provider = new NumberFormatInfo();
617
+            provider.NumberDecimalSeparator = ".";
618
+            provider.NumberGroupSeparator = ",";
619
+            provider.NumberGroupSizes = new int[] { 3 };
620
+
621
+            if (parts.Length == 6) {
622
+                pos.robotID = Convert.ToInt32(parts[0]);
623
+
624
+                try
625
+                {
626
+                    pos.angle = Convert.ToDouble(parts[1]);
627
+                } catch (FormatException)
628
+                {
629
+                    pos.angle = Convert.ToDouble(parts[1],provider);
630
+                }
631
+
632
+                try
633
+                {
634
+                    pos.centre.x = Convert.ToDouble(parts[2]);
635
+                } catch (FormatException)
636
+                {
637
+                    pos.centre.x = Convert.ToDouble(parts[2], provider);
638
+                }
639
+
640
+                try
641
+                {
642
+                    pos.centre.y = Convert.ToDouble(parts[3]);
643
+                }
644
+                catch (FormatException)
645
+                {
646
+                    pos.centre.y = Convert.ToDouble(parts[3], provider);
647
+                }
648
+
649
+                try
650
+                {
651
+                    pos.direction.x = Convert.ToDouble(parts[4]);
652
+                }
653
+                catch (FormatException)
654
+                {
655
+                    pos.direction.x = Convert.ToDouble(parts[4], provider);
656
+                }
657
+
658
+                try
659
+                {
660
+                    pos.direction.y = Convert.ToDouble(parts[5]);
661
+                }
662
+                catch (FormatException)
663
+                {
664
+                    pos.direction.y = Convert.ToDouble(parts[5], provider);
665
+                }
666
+
667
+            } else {
668
+                // misformatted data, return 0 filled position
669
+                Console.WriteLine("Misformated position");
670
+            }
671
+
672
+            return pos;
673
+        }
555 674
     }
556 675
 }

+ 130
- 59
software/monitor/monitor/MonitorUI.cs View File

@@ -23,6 +23,7 @@
23 23
 using System;
24 24
 using Gtk;
25 25
 using Gdk;
26
+using Cairo;
26 27
 
27 28
 using monitor;
28 29
 
@@ -42,6 +43,11 @@ public partial class MainWindow : Gtk.Window
42 43
     private Pixbuf drawingareaCameraPixbuf;
43 44
 
44 45
     /// <summary>
46
+    /// Position used for displaying position
47
+    /// </summary>
48
+    private DestijlCommandManager.Position position=new DestijlCommandManager.Position();
49
+
50
+    /// <summary>
45 51
     /// List of availble state for the application
46 52
     /// </summary>
47 53
     enum SystemState
@@ -200,8 +206,8 @@ public partial class MainWindow : Gtk.Window
200 206
         a.RetVal = true;
201 207
     }
202 208
 
203
-    private byte[] imageComplete;
204
-    private byte[] imageInProgress;
209
+    //private byte[] imageComplete;
210
+    //private byte[] imageInProgress;
205 211
 
206 212
     /// <summary>
207 213
     /// Callback called when new message is received from server
@@ -209,17 +215,20 @@ public partial class MainWindow : Gtk.Window
209 215
     /// <param name="header">Header of message</param>
210 216
     /// <param name="data">Data of message</param>
211 217
     /// <param name="buffer">Raw buffer corresponding of received message</param>
212
-    public void OnCommandReceivedEvent(string header, string data, byte[] buffer)
218
+    public void OnCommandReceivedEvent(string header, string data)
213 219
     {
214
-        if (buffer==null)
220
+        if (header == null)
215 221
         {
216 222
             // we have lost server
217 223
             ChangeState(SystemState.NotConnected);
218 224
 
219
-            MessagePopup(MessageType.Error,
225
+            Gtk.Application.Invoke(delegate
226
+            {
227
+                MessagePopup(MessageType.Error,
220 228
                      ButtonsType.Ok, "Server lost",
221 229
                          "Server is down: disconnecting");
222
-            cmdManager.Close();
230
+                cmdManager.Close();
231
+            });
223 232
         }
224 233
 
225 234
         // if we have received a valid message
@@ -228,75 +237,104 @@ public partial class MainWindow : Gtk.Window
228 237
 #if DEBUG
229 238
             // print message content
230 239
             if (header.Length > 4)
231
-                Console.WriteLine("Bad header(" + buffer.Length + ")");
232
-            else
233
-                Console.WriteLine("Received header (" + header.Length + "): " + header);
240
+                Console.WriteLine("Bad header(" + header.Length + ")");
241
+            //else
242
+            //    Console.WriteLine("Received header (" + header.Length + "): " + header);
234 243
             //if (header.ToUpper() != DestijlCommandList.HeaderStmImage)
235 244
             //{
236 245
             //    if (data != null) Console.WriteLine("Received data (" + data.Length + "): " + data);
237 246
             //}
238 247
 #endif
239 248
             // Image management
240
-            if (header == DestijlCommandList.HeaderStmImage)
241
-            {
242
-                imageComplete = imageInProgress;
243
-                imageInProgress = buffer;
244
-            }
245
-            else
246
-            {
247
-                if (imageInProgress == null) imageInProgress = buffer;
248
-                else
249
-                {
250
-                    Array.Resize<byte>(ref imageInProgress, imageInProgress.Length + buffer.Length);
251
-                    System.Buffer.BlockCopy(buffer, 0, imageInProgress, imageInProgress.Length - buffer.Length, buffer.Length);
252
-                }
253
-            }
249
+            //if (header == DestijlCommandList.CAMERA_IMAGE)
250
+            //{
251
+            //    imageComplete = imageInProgress;
252
+            //    //TODO: Decoder le base64 pour recuperer le JPG
253
+            //    imageInProgress = buffer;
254
+            //}
255
+            //else
256
+            //{
257
+            //    if (imageInProgress == null) imageInProgress = buffer;
258
+            //    else
259
+            //    {
260
+            //        Array.Resize<byte>(ref imageInProgress, imageInProgress.Length + buffer.Length);
261
+            //        System.Buffer.BlockCopy(buffer, 0, imageInProgress, imageInProgress.Length - buffer.Length, buffer.Length);
262
+            //    }
263
+            //}
254 264
 
255 265
             // depending on message received (based on header)
256 266
             // launch correponding action
257
-            if (header.ToUpper() == DestijlCommandList.HeaderStmBat)
267
+            header = header.ToUpper();
268
+
269
+            if (header == DestijlCommandList.ROBOT_BATTERY_LEVEL)
258 270
             {
271
+                string batLevel = "";
272
+
259 273
                 switch (data[0])
260 274
                 {
261 275
                     case '2':
262
-                        labelBatteryLevel.Text = "High";
276
+                        batLevel = "High";
263 277
                         break;
264 278
                     case '1':
265
-                        labelBatteryLevel.Text = "Low";
279
+                        batLevel = "Low";
266 280
                         break;
267 281
                     case '0':
268
-                        labelBatteryLevel.Text = "Empty";
282
+                        batLevel = "Empty";
269 283
                         break;
270 284
                     default:
271
-                        labelBatteryLevel.Text = "Invalid value";
285
+                        batLevel = "Invalid value";
272 286
                         break;
273 287
                 }
288
+
289
+                Gtk.Application.Invoke(delegate
290
+                {
291
+                    labelBatteryLevel.Text = batLevel;
292
+                });
274 293
             }
275
-            else if (header.ToUpper() == DestijlCommandList.HeaderStmImage)
294
+            else if (header == DestijlCommandList.CAMERA_IMAGE)
276 295
             {
277 296
                 // if message is an image, convert it to a pixbuf
278 297
                 // that can be displayed
279
-                if (imageComplete != null)
298
+                //if (imageComplete != null)
299
+                //{
300
+                //TODO: Decoder le base64 et convertir en JPG
301
+                byte[] image = Convert.FromBase64String(data);
302
+                //byte[] image = new byte[imageComplete.Length - 4];
303
+                //System.Buffer.BlockCopy(imageComplete, 4, image, 0, image.Length);
304
+
305
+                imageReceivedCounter++;
306
+
307
+                try
280 308
                 {
281
-                    byte[] image = new byte[imageComplete.Length - 4];
282
-                    System.Buffer.BlockCopy(imageComplete, 4, image, 0, image.Length);
309
+                    drawingareaCameraPixbuf = new Pixbuf(image);
283 310
 
284
-                    imageReceivedCounter++;
285
-                    try
311
+                    Gtk.Application.Invoke(delegate
286 312
                     {
287
-                        drawingareaCameraPixbuf = new Pixbuf(image);
288 313
                         drawingAreaCamera.QueueDraw();
289
-                    }
290
-                    catch (GLib.GException)
291
-                    {
292
-                        badImageReceivedCounter++;
314
+                    });
315
+                }
316
+                catch (GLib.GException)
317
+                {
318
+                    badImageReceivedCounter++;
293 319
 #if DEBUG
294
-                        Console.WriteLine("Bad Image: " + badImageReceivedCounter +
295
-                                          " / " + imageReceivedCounter +
296
-                                          " (" + badImageReceivedCounter * 100 / imageReceivedCounter + "%)");
320
+                    Console.WriteLine("Bad Image: " + badImageReceivedCounter +
321
+                                      " / " + imageReceivedCounter +
322
+                                      " (" + badImageReceivedCounter * 100 / imageReceivedCounter + "%)");
297 323
 #endif
298
-                    }
299 324
                 }
325
+                //}
326
+            }
327
+            else if (header == DestijlCommandList.CAMERA_POSITION)
328
+            {
329
+                //Console.WriteLine("Pos data: " + data);
330
+
331
+                position = DestijlCommandManager.DecodePosition(data);
332
+                //Console.WriteLine("decoded position: " + position.ToString());
333
+
334
+                Gtk.Application.Invoke(delegate
335
+                {
336
+                    drawingAreaCamera.QueueDraw();
337
+                });
300 338
             }
301 339
         }
302 340
     }
@@ -417,10 +455,10 @@ public partial class MainWindow : Gtk.Window
417 455
         DestijlCommandManager.CommandStatus status;
418 456
 
419 457
         //if robot is not activated
420
-        if (buttonRobotActivation.Label == "Activate") 
458
+        if (buttonRobotActivation.Label == "Activate")
421 459
         {
422 460
             // if a startup with watchdog is requested
423
-            if (radioButtonWithWatchdog.Active) 
461
+            if (radioButtonWithWatchdog.Active)
424 462
             {
425 463
                 status = cmdManager.RobotStartWithWatchdog();
426 464
             }
@@ -557,9 +595,7 @@ public partial class MainWindow : Gtk.Window
557 595
         {
558 596
             if (cmdManager.CameraClose() != DestijlCommandManager.CommandStatus.Success)
559 597
             {
560
-                MessagePopup(MessageType.Error,
561
-                             ButtonsType.Ok, "Error",
562
-                             "Error when closing camera: bad answer for supervisor or timeout");
598
+                Console.WriteLine("Error when closing camera: bad answer for supervisor or timeout");
563 599
             }
564 600
         }
565 601
         else // camera is not active, switch it on
@@ -569,10 +605,8 @@ public partial class MainWindow : Gtk.Window
569 605
 
570 606
             if (cmdManager.CameraOpen() != DestijlCommandManager.CommandStatus.Success)
571 607
             {
572
-                MessagePopup(MessageType.Error,
573
-                             ButtonsType.Ok, "Error",
574
-                             "Error when opening camera: bad answer for supervisor or timeout");
575
-                checkButtonCameraOn.Active = false;
608
+                Console.WriteLine("Error when opening camera: bad answer for supervisor or timeout");
609
+                //checkButtonCameraOn.Active = false;
576 610
             }
577 611
         }
578 612
     }
@@ -589,20 +623,16 @@ public partial class MainWindow : Gtk.Window
589 623
         {
590 624
             if (cmdManager.CameraStopComputePosition() != DestijlCommandManager.CommandStatus.Success)
591 625
             {
592
-                MessagePopup(MessageType.Error,
593
-                             ButtonsType.Ok, "Error",
594
-                             "Error when stopping position reception: bad answer for supervisor or timeout");
626
+                Console.WriteLine("Error when stopping position reception: bad answer for supervisor or timeout");
595 627
             }
596 628
         }
597 629
         else // start reception of robot position
598 630
         {
599 631
             if (cmdManager.CameraComputePosition() != DestijlCommandManager.CommandStatus.Success)
600 632
             {
601
-                MessagePopup(MessageType.Error,
602
-                             ButtonsType.Ok, "Error",
603
-                             "Error when starting getting robot position: bad answer for supervisor or timeout");
633
+                Console.WriteLine("Error when starting getting robot position: bad answer for supervisor or timeout");
604 634
 
605
-                checkButtonRobotPosition.Active = false;
635
+                //checkButtonRobotPosition.Active = false;
606 636
             }
607 637
         }
608 638
     }
@@ -657,6 +687,47 @@ public partial class MainWindow : Gtk.Window
657 687
                                   (areaHeight - displayPixbuf.Height) / 2,
658 688
                                   displayPixbuf.Width, displayPixbuf.Height,
659 689
                                   RgbDither.Normal, 0, 0);
690
+
691
+        if (checkButtonRobotPosition.Active) {
692
+            Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
693
+            Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
694
+
695
+            cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
696
+            cr.SetSourceColor(textFontColor);
697
+            cr.SetFontSize(16);
698
+
699
+            double space = 0.0;
700
+            string text = "Direction (" + position.direction.x.ToString("0.##") + " ; " + position.direction.y.ToString("0.##") +")";
701
+            TextExtents te = cr.TextExtents(text);
702
+            cr.MoveTo(areaWidth - te.Width-5,
703
+                      areaHeight - te.Height -5);
704
+            space = te.Height;
705
+            cr.ShowText(text);
706
+
707
+            text = "Centre (" + position.centre.x.ToString("0.##") + " ; " + position.centre.y.ToString("0.##") + ")";
708
+            te = cr.TextExtents(text);
709
+            cr.MoveTo(areaWidth - te.Width - 5,
710
+                      areaHeight - te.Height - 5 - space-5);
711
+            space = space+ te.Height+5;
712
+            cr.ShowText(text);
713
+
714
+            text = "Angle: " + position.angle.ToString("0.##");
715
+            te = cr.TextExtents(text);
716
+            cr.MoveTo(areaWidth - te.Width - 5,
717
+                      areaHeight - te.Height - 5 - space - 5);
718
+            space = space+ te.Height+5;
719
+            cr.ShowText(text);
720
+
721
+            text = "ID: " + position.robotID;
722
+            te = cr.TextExtents(text);
723
+            cr.MoveTo(areaWidth - te.Width - 5,
724
+                      areaHeight - te.Height - 5 - space-5);
725
+
726
+            cr.ShowText(text);
727
+
728
+            ((IDisposable)cr.GetTarget()).Dispose();
729
+            ((IDisposable)cr).Dispose();
730
+        }
660 731
     }
661 732
 
662 733
     /// <summary>

BIN
software/monitor/monitor/monitor View File


+ 0
- 5
software/raspberry/superviseur-robot/.dep.inc View File

@@ -1,5 +0,0 @@
1
-# This code depends on make tool being used
2
-DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
3
-ifneq (${DEPFILES},)
4
-include ${DEPFILES}
5
-endif

+ 0
- 1
software/raspberry/superviseur-robot/.idea/.name View File

@@ -1 +0,0 @@
1
-ProjDestijl

+ 0
- 29
software/raspberry/superviseur-robot/.idea/codeStyles/Project.xml View File

@@ -1,29 +0,0 @@
1
-<component name="ProjectCodeStyleConfiguration">
2
-  <code_scheme name="Project" version="173">
3
-    <Objective-C-extensions>
4
-      <file>
5
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
6
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
7
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
8
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
9
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
10
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
11
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
12
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
13
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
14
-      </file>
15
-      <class>
16
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
17
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
18
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
19
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
20
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
21
-        <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
22
-      </class>
23
-      <extensions>
24
-        <pair source="cpp" header="h" fileNamingConvention="NONE" />
25
-        <pair source="c" header="h" fileNamingConvention="NONE" />
26
-      </extensions>
27
-    </Objective-C-extensions>
28
-  </code_scheme>
29
-</component>

+ 0
- 7
software/raspberry/superviseur-robot/.idea/misc.xml View File

@@ -1,7 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
4
-  <component name="JavaScriptSettings">
5
-    <option name="languageLevel" value="ES6" />
6
-  </component>
7
-</project>

+ 0
- 8
software/raspberry/superviseur-robot/.idea/modules.xml View File

@@ -1,8 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="ProjectModuleManager">
4
-    <modules>
5
-      <module fileurl="file://$PROJECT_DIR$/.idea/superviseur-robot.iml" filepath="$PROJECT_DIR$/.idea/superviseur-robot.iml" />
6
-    </modules>
7
-  </component>
8
-</project>

+ 0
- 2
software/raspberry/superviseur-robot/.idea/superviseur-robot.iml View File

@@ -1,2 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<module classpath="CMake" type="CPP_MODULE" version="4" />

+ 0
- 6
software/raspberry/superviseur-robot/.idea/vcs.xml View File

@@ -1,6 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="VcsDirectoryMappings">
4
-    <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
5
-  </component>
6
-</project>

+ 0
- 864
software/raspberry/superviseur-robot/.idea/workspace.xml View File

@@ -1,864 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true">
4
-    <generated>
5
-      <config projectName="ProjDestijl" targetName="superviseur" />
6
-      <config projectName="ProjDestijl" targetName="destijl" />
7
-    </generated>
8
-  </component>
9
-  <component name="CMakeSettings" AUTO_RELOAD="true">
10
-    <configurations>
11
-      <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
12
-    </configurations>
13
-  </component>
14
-  <component name="ChangeListManager">
15
-    <list default="true" id="4c044020-a391-4234-8366-64abd3f0f464" name="Default Changelist" comment="">
16
-      <change afterPath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" afterDir="false" />
17
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
18
-      <change afterPath="$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt" afterDir="false" />
19
-      <change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Program.cpp" afterDir="false" />
20
-      <change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp" afterDir="false" />
21
-      <change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Tasks.h" afterDir="false" />
22
-      <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
23
-      <change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
24
-      <change beforePath="$PROJECT_DIR$/destijl_init/Makefile" beforeDir="false" />
25
-      <change beforePath="$PROJECT_DIR$/examples/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/examples/CMakeLists.txt" afterDir="false" />
26
-      <change beforePath="$PROJECT_DIR$/lib/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/lib/CMakeLists.txt" afterDir="false" />
27
-      <change beforePath="$PROJECT_DIR$/lib/Robot.h" beforeDir="false" />
28
-      <change beforePath="$PROJECT_DIR$/lib/Serial.h" beforeDir="false" />
29
-      <change beforePath="$PROJECT_DIR$/lib/TcpServer.h" beforeDir="false" />
30
-      <change beforePath="$PROJECT_DIR$/lib/definitions.h" beforeDir="false" />
31
-      <change beforePath="$PROJECT_DIR$/lib/image.h" beforeDir="false" />
32
-      <change beforePath="$PROJECT_DIR$/lib/message.h" beforeDir="false" />
33
-      <change beforePath="$PROJECT_DIR$/lib/monitor.h" beforeDir="false" />
34
-      <change beforePath="$PROJECT_DIR$/lib/src/Robot.cpp" beforeDir="false" />
35
-      <change beforePath="$PROJECT_DIR$/lib/src/Serial.cpp" beforeDir="false" />
36
-      <change beforePath="$PROJECT_DIR$/lib/src/TcpServer.cpp" beforeDir="false" />
37
-      <change beforePath="$PROJECT_DIR$/lib/src/image.cpp" beforeDir="false" />
38
-      <change beforePath="$PROJECT_DIR$/lib/src/message.cpp" beforeDir="false" />
39
-      <change beforePath="$PROJECT_DIR$/lib/src/monitor.cpp" beforeDir="false" />
40
-      <change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp" beforeDir="false" />
41
-      <change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp" beforeDir="false" />
42
-      <change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h" beforeDir="false" />
43
-    </list>
44
-    <ignored path="$PROJECT_DIR$/cmake-build-debug/" />
45
-    <ignored path="$PROJECT_DIR$/CMakeFiles/" />
46
-    <ignored path="$PROJECT_DIR$/superviseur/CMakeFiles/" />
47
-    <ignored path="$PROJECT_DIR$/lib/CMakeFiles/" />
48
-    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
49
-    <option name="SHOW_DIALOG" value="false" />
50
-    <option name="HIGHLIGHT_CONFLICTS" value="true" />
51
-    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
52
-    <option name="LAST_RESOLUTION" value="IGNORE" />
53
-  </component>
54
-  <component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
55
-  <component name="FUSProjectUsageTrigger">
56
-    <session id="-329952360">
57
-      <usages-collector id="statistics.lifecycle.project">
58
-        <counts>
59
-          <entry key="project.closed" value="2" />
60
-          <entry key="project.open.time.3" value="1" />
61
-          <entry key="project.open.time.9" value="1" />
62
-          <entry key="project.opened" value="2" />
63
-        </counts>
64
-      </usages-collector>
65
-      <usages-collector id="statistics.file.extensions.open">
66
-        <counts>
67
-          <entry key="cmake" value="1" />
68
-          <entry key="cpp" value="36" />
69
-          <entry key="gitignore" value="1" />
70
-          <entry key="h" value="18" />
71
-          <entry key="txt" value="20" />
72
-        </counts>
73
-      </usages-collector>
74
-      <usages-collector id="statistics.file.types.open">
75
-        <counts>
76
-          <entry key="CMakeLists.txt" value="21" />
77
-          <entry key="ObjectiveC" value="54" />
78
-          <entry key="PLAIN_TEXT" value="1" />
79
-        </counts>
80
-      </usages-collector>
81
-      <usages-collector id="statistics.file.extensions.edit">
82
-        <counts>
83
-          <entry key="cpp" value="3165" />
84
-          <entry key="gitignore" value="19" />
85
-          <entry key="h" value="1381" />
86
-          <entry key="txt" value="1035" />
87
-        </counts>
88
-      </usages-collector>
89
-      <usages-collector id="statistics.file.types.edit">
90
-        <counts>
91
-          <entry key="CMakeLists.txt" value="1035" />
92
-          <entry key="Doxygen file" value="2" />
93
-          <entry key="ObjectiveC" value="4544" />
94
-          <entry key="PLAIN_TEXT" value="19" />
95
-        </counts>
96
-      </usages-collector>
97
-    </session>
98
-  </component>
99
-  <component name="FileEditorManager">
100
-    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
101
-      <file pinned="false" current-in-tab="false">
102
-        <entry file="file://$PROJECT_DIR$/lib/CMakeLists.txt">
103
-          <provider selected="true" editor-type-id="text-editor">
104
-            <state>
105
-              <caret column="81" selection-start-column="81" selection-end-column="81" />
106
-            </state>
107
-          </provider>
108
-        </entry>
109
-      </file>
110
-      <file pinned="false" current-in-tab="false">
111
-        <entry file="file://$PROJECT_DIR$/lib/image.h">
112
-          <provider selected="true" editor-type-id="text-editor">
113
-            <state relative-caret-position="209">
114
-              <caret line="17" selection-start-line="17" selection-end-line="17" />
115
-              <folding>
116
-                <element signature="e#566#599#0" expanded="true" />
117
-                <element signature="e#635#673#0" expanded="true" />
118
-                <element signature="e#865#890#0" expanded="true" />
119
-                <element signature="e#935#962#0" expanded="true" />
120
-              </folding>
121
-            </state>
122
-          </provider>
123
-        </entry>
124
-      </file>
125
-      <file pinned="false" current-in-tab="false">
126
-        <entry file="file://$PROJECT_DIR$/lib/src/message.cpp">
127
-          <provider selected="true" editor-type-id="text-editor">
128
-            <state relative-caret-position="405">
129
-              <caret line="27" column="32" selection-start-line="27" selection-start-column="32" selection-end-line="27" selection-end-column="32" />
130
-            </state>
131
-          </provider>
132
-        </entry>
133
-      </file>
134
-      <file pinned="false" current-in-tab="false">
135
-        <entry file="file://$PROJECT_DIR$/lib/monitor.h">
136
-          <provider selected="true" editor-type-id="text-editor">
137
-            <state relative-caret-position="389">
138
-              <caret line="64" column="94" selection-start-line="64" selection-start-column="94" selection-end-line="64" selection-end-column="94" />
139
-            </state>
140
-          </provider>
141
-        </entry>
142
-      </file>
143
-      <file pinned="false" current-in-tab="false">
144
-        <entry file="file://$PROJECT_DIR$/lib/src/monitor.cpp">
145
-          <provider selected="true" editor-type-id="text-editor">
146
-            <state relative-caret-position="338">
147
-              <caret line="104" column="23" selection-start-line="104" selection-start-column="23" selection-end-line="104" selection-end-column="23" />
148
-            </state>
149
-          </provider>
150
-        </entry>
151
-      </file>
152
-      <file pinned="false" current-in-tab="false">
153
-        <entry file="file://$PROJECT_DIR$/CMakeLists.txt">
154
-          <provider selected="true" editor-type-id="text-editor">
155
-            <state relative-caret-position="330">
156
-              <caret line="22" selection-start-line="22" selection-end-line="22" />
157
-            </state>
158
-          </provider>
159
-        </entry>
160
-      </file>
161
-      <file pinned="false" current-in-tab="false">
162
-        <entry file="file://$PROJECT_DIR$/superviseur/CMakeLists.txt">
163
-          <provider selected="true" editor-type-id="text-editor">
164
-            <state relative-caret-position="135">
165
-              <caret line="9" selection-start-line="9" selection-end-line="9" />
166
-            </state>
167
-          </provider>
168
-        </entry>
169
-      </file>
170
-      <file pinned="false" current-in-tab="false">
171
-        <entry file="file://$PROJECT_DIR$/superviseur/src/main.cpp">
172
-          <provider selected="true" editor-type-id="text-editor">
173
-            <state relative-caret-position="75">
174
-              <caret line="89" column="13" selection-start-line="89" selection-start-column="13" selection-end-line="89" selection-end-column="13" />
175
-              <folding>
176
-                <element signature="e#88#106#0" expanded="true" />
177
-              </folding>
178
-            </state>
179
-          </provider>
180
-        </entry>
181
-      </file>
182
-      <file pinned="false" current-in-tab="false">
183
-        <entry file="file://$PROJECT_DIR$/superviseur/src/functions.h">
184
-          <provider selected="true" editor-type-id="text-editor">
185
-            <state relative-caret-position="180">
186
-              <caret line="51" column="21" selection-start-line="51" selection-start-column="12" selection-end-line="51" selection-end-column="21" />
187
-              <folding>
188
-                <element signature="e#319#337#0" expanded="true" />
189
-              </folding>
190
-            </state>
191
-          </provider>
192
-        </entry>
193
-      </file>
194
-      <file pinned="false" current-in-tab="true">
195
-        <entry file="file://$PROJECT_DIR$/superviseur/src/functions.cpp">
196
-          <provider selected="true" editor-type-id="text-editor">
197
-            <state relative-caret-position="300">
198
-              <caret line="20" column="19" selection-start-line="20" selection-start-column="19" selection-end-line="20" selection-end-column="19" />
199
-            </state>
200
-          </provider>
201
-        </entry>
202
-      </file>
203
-    </leaf>
204
-  </component>
205
-  <component name="Git.Settings">
206
-    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
207
-  </component>
208
-  <component name="IdeDocumentHistory">
209
-    <option name="CHANGED_PATHS">
210
-      <list>
211
-        <option value="$PROJECT_DIR$/.gitignore" />
212
-        <option value="$PROJECT_DIR$/lib/Definition.h" />
213
-        <option value="$PROJECT_DIR$/lib/src/Robot.cpp" />
214
-        <option value="$PROJECT_DIR$/lib/Image.h" />
215
-        <option value="$PROJECT_DIR$/lib/Camera.h" />
216
-        <option value="$PROJECT_DIR$/lib/src/Camera.cpp" />
217
-        <option value="$PROJECT_DIR$/lib/src/Image.cpp" />
218
-        <option value="$PROJECT_DIR$/destijl_init/CMakeLists.txt" />
219
-        <option value="$PROJECT_DIR$/monitor/CMakeLists.txt" />
220
-        <option value="$PROJECT_DIR$/monitor/src/functions.h" />
221
-        <option value="$PROJECT_DIR$/monitor/src/main.cpp" />
222
-        <option value="$PROJECT_DIR$/monitor-pc/CMakeLists.txt" />
223
-        <option value="$PROJECT_DIR$/monitor-pc/src/functions.cpp" />
224
-        <option value="$PROJECT_DIR$/monitor-pc/src/functions.h" />
225
-        <option value="$PROJECT_DIR$/monitor-pc/src/main.cpp" />
226
-        <option value="$PROJECT_DIR$/monitor-pthread/CMakeLists.txt" />
227
-        <option value="$PROJECT_DIR$/superviseur-pthread/src/Functions.h" />
228
-        <option value="$PROJECT_DIR$/superviseur-pthread/src/Functions.cpp" />
229
-        <option value="$PROJECT_DIR$/lib/src/TcpServer.cpp" />
230
-        <option value="$PROJECT_DIR$/lib/TcpServer.h" />
231
-        <option value="$PROJECT_DIR$/lib/src/Messages.cpp" />
232
-        <option value="$PROJECT_DIR$/lib/Messages.h" />
233
-        <option value="$PROJECT_DIR$/superviseur-pthread/src/Tasks.h" />
234
-        <option value="$PROJECT_DIR$/superviseur-pthread/src/Program.cpp" />
235
-        <option value="$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp" />
236
-        <option value="$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt" />
237
-        <option value="$PROJECT_DIR$/examples/CMakeLists.txt" />
238
-        <option value="$PROJECT_DIR$/superviseur-xenomai/CMakeLists.txt" />
239
-        <option value="$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp" />
240
-        <option value="$PROJECT_DIR$/lib/MsgManager.h" />
241
-        <option value="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp" />
242
-        <option value="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h" />
243
-        <option value="$PROJECT_DIR$/lib/CMakeLists.txt" />
244
-        <option value="$PROJECT_DIR$/lib/image.h" />
245
-        <option value="$PROJECT_DIR$/lib/src/message.cpp" />
246
-        <option value="$PROJECT_DIR$/lib/monitor.h" />
247
-        <option value="$PROJECT_DIR$/lib/src/monitor.cpp" />
248
-        <option value="$PROJECT_DIR$/superviseur/src/functions.h" />
249
-        <option value="$PROJECT_DIR$/superviseur/src/functions.cpp" />
250
-        <option value="$PROJECT_DIR$/CMakeLists.txt" />
251
-        <option value="$PROJECT_DIR$/superviseur/src/main.cpp" />
252
-        <option value="$PROJECT_DIR$/superviseur/CMakeLists.txt" />
253
-      </list>
254
-    </option>
255
-  </component>
256
-  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
257
-  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
258
-  <component name="JsGulpfileManager">
259
-    <detection-done>true</detection-done>
260
-    <sorting>DEFINITION_ORDER</sorting>
261
-  </component>
262
-  <component name="OCFindUsagesOptions" text="true" ivars="false" properties="true" derivedClasses="false" />
263
-  <component name="ProjectFrameBounds">
264
-    <option name="x" value="260" />
265
-    <option name="y" value="101" />
266
-    <option name="width" value="1660" />
267
-    <option name="height" value="1088" />
268
-  </component>
269
-  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
270
-  <component name="ProjectView">
271
-    <navigator proportions="" version="1">
272
-      <foldersAlwaysOnTop value="true" />
273
-    </navigator>
274
-    <panes>
275
-      <pane id="Scope" />
276
-      <pane id="ProjectPane">
277
-        <subPane>
278
-          <expand>
279
-            <path>
280
-              <item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
281
-              <item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
282
-            </path>
283
-            <path>
284
-              <item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
285
-              <item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
286
-              <item name="lib" type="462c0819:PsiDirectoryNode" />
287
-            </path>
288
-            <path>
289
-              <item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
290
-              <item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
291
-              <item name="superviseur" type="462c0819:PsiDirectoryNode" />
292
-            </path>
293
-            <path>
294
-              <item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
295
-              <item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
296
-              <item name="superviseur" type="462c0819:PsiDirectoryNode" />
297
-              <item name="src" type="462c0819:PsiDirectoryNode" />
298
-            </path>
299
-            <path>
300
-              <item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
301
-              <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
302
-            </path>
303
-          </expand>
304
-          <select />
305
-        </subPane>
306
-      </pane>
307
-    </panes>
308
-  </component>
309
-  <component name="PropertiesComponent">
310
-    <property name="WebServerToolWindowFactoryState" value="false" />
311
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/superviseur/bin/superviseur" />
312
-    <property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors.General" />
313
-  </component>
314
-  <component name="RecentsManager">
315
-    <key name="CopyFile.RECENT_KEYS">
316
-      <recent name="$PROJECT_DIR$/destijl_init" />
317
-    </key>
318
-    <key name="MoveFile.RECENT_KEYS">
319
-      <recent name="$PROJECT_DIR$/lib" />
320
-      <recent name="$PROJECT_DIR$/destijl_init/src" />
321
-    </key>
322
-  </component>
323
-  <component name="RunDashboard">
324
-    <option name="ruleStates">
325
-      <list>
326
-        <RuleState>
327
-          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
328
-        </RuleState>
329
-        <RuleState>
330
-          <option name="name" value="StatusDashboardGroupingRule" />
331
-        </RuleState>
332
-      </list>
333
-    </option>
334
-  </component>
335
-  <component name="RunManager" selected="Application.superviseur">
336
-    <configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" EXPLICIT_BUILD_TARGET_NAME="all">
337
-      <method v="2">
338
-        <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
339
-      </method>
340
-    </configuration>
341
-    <configuration name="destijl" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ProjDestijl" TARGET_NAME="destijl" CONFIG_NAME="Debug">
342
-      <method v="2">
343
-        <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
344
-      </method>
345
-    </configuration>
346
-    <configuration name="superviseur" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ProjDestijl" TARGET_NAME="superviseur" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="ProjDestijl" RUN_TARGET_NAME="superviseur">
347
-      <method v="2">
348
-        <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
349
-      </method>
350
-    </configuration>
351
-    <list>
352
-      <item itemvalue="Application.Build All" />
353
-      <item itemvalue="Application.destijl" />
354
-      <item itemvalue="Application.superviseur" />
355
-    </list>
356
-  </component>
357
-  <component name="SvnConfiguration">
358
-    <configuration />
359
-  </component>
360
-  <component name="TaskManager">
361
-    <task active="true" id="Default" summary="Default task">
362
-      <changelist id="4c044020-a391-4234-8366-64abd3f0f464" name="Default Changelist" comment="" />
363
-      <created>1539692092358</created>
364
-      <option name="number" value="Default" />
365
-      <option name="presentableId" value="Default" />
366
-      <updated>1539692092358</updated>
367
-      <workItem from="1539692095452" duration="3090000" />
368
-      <workItem from="1539698076207" duration="43886000" />
369
-    </task>
370
-    <servers />
371
-  </component>
372
-  <component name="TimeTrackingManager">
373
-    <option name="totallyTimeSpent" value="46976000" />
374
-  </component>
375
-  <component name="ToolWindowManager">
376
-    <frame x="260" y="101" width="1660" height="1088" extended-state="0" />
377
-    <layout>
378
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21277915" />
379
-      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
380
-      <window_info id="Favorites" order="2" side_tool="true" />
381
-      <window_info anchor="bottom" id="Message" order="0" />
382
-      <window_info anchor="bottom" id="Find" order="1" weight="0.2114165" />
383
-      <window_info anchor="bottom" id="Run" order="2" />
384
-      <window_info anchor="bottom" id="Debug" order="3" weight="0.39957717" />
385
-      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
386
-      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
387
-      <window_info anchor="bottom" id="TODO" order="6" />
388
-      <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
389
-      <window_info anchor="bottom" id="Messages" order="8" weight="0.3118393" />
390
-      <window_info anchor="bottom" id="Terminal" order="9" weight="0.32980973" />
391
-      <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
392
-      <window_info anchor="bottom" id="Version Control" order="11" show_stripe_button="false" />
393
-      <window_info anchor="bottom" id="CMake" order="12" weight="0.32980973" />
394
-      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
395
-      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
396
-      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
397
-      <window_info anchor="right" id="Database" order="3" />
398
-    </layout>
399
-  </component>
400
-  <component name="TypeScriptGeneratedFilesManager">
401
-    <option name="version" value="1" />
402
-  </component>
403
-  <component name="VcsContentAnnotationSettings">
404
-    <option name="myLimit" value="2678400000" />
405
-  </component>
406
-  <component name="XDebuggerManager">
407
-    <breakpoint-manager>
408
-      <breakpoints>
409
-        <line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
410
-          <url>file://$PROJECT_DIR$/examples/src/serverTest.cpp</url>
411
-          <line>28</line>
412
-          <option name="timeStamp" value="1" />
413
-        </line-breakpoint>
414
-        <line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
415
-          <url>file://$PROJECT_DIR$/superviseur/src/functions.cpp</url>
416
-          <line>16</line>
417
-          <option name="timeStamp" value="6" />
418
-        </line-breakpoint>
419
-      </breakpoints>
420
-    </breakpoint-manager>
421
-  </component>
422
-  <component name="editorHistoryManager">
423
-    <entry file="file://$PROJECT_DIR$/destijl_init/src/functions.h">
424
-      <provider selected="true" editor-type-id="text-editor" />
425
-    </entry>
426
-    <entry file="file://$PROJECT_DIR$/destijl_init/src/main.cpp">
427
-      <provider selected="true" editor-type-id="text-editor" />
428
-    </entry>
429
-    <entry file="file://$PROJECT_DIR$/lib/src/Camera.cpp">
430
-      <provider selected="true" editor-type-id="text-editor">
431
-        <state relative-caret-position="795">
432
-          <caret line="53" column="19" selection-start-line="53" selection-start-column="19" selection-end-line="53" selection-end-column="19" />
433
-          <folding>
434
-            <element signature="e#43#62#0" expanded="true" />
435
-          </folding>
436
-        </state>
437
-      </provider>
438
-    </entry>
439
-    <entry file="file://$PROJECT_DIR$/lib/Image.h">
440
-      <provider selected="true" editor-type-id="text-editor">
441
-        <state relative-caret-position="525">
442
-          <caret line="35" column="52" selection-start-line="35" selection-start-column="52" selection-end-line="35" selection-end-column="52" />
443
-          <folding>
444
-            <element signature="e#80#99#0" expanded="true" />
445
-          </folding>
446
-        </state>
447
-      </provider>
448
-    </entry>
449
-    <entry file="file://$PROJECT_DIR$/lib/Definition.h">
450
-      <provider selected="true" editor-type-id="text-editor">
451
-        <state relative-caret-position="330">
452
-          <caret line="22" column="10" selection-start-line="22" selection-start-column="10" selection-end-line="22" selection-end-column="10" />
453
-          <folding>
454
-            <element signature="e#90#128#0" expanded="true" />
455
-          </folding>
456
-        </state>
457
-      </provider>
458
-    </entry>
459
-    <entry file="file://$PROJECT_DIR$/lib/Camera.h">
460
-      <provider selected="true" editor-type-id="text-editor">
461
-        <state relative-caret-position="435">
462
-          <caret line="29" selection-start-line="29" selection-end-line="29" />
463
-          <folding>
464
-            <element signature="e#82#120#0" expanded="true" />
465
-          </folding>
466
-        </state>
467
-      </provider>
468
-    </entry>
469
-    <entry file="file://$PROJECT_DIR$/destijl_init/CMakeLists.txt">
470
-      <provider selected="true" editor-type-id="text-editor">
471
-        <state relative-caret-position="90">
472
-          <caret line="6" column="21" selection-start-line="6" selection-start-column="21" selection-end-line="6" selection-end-column="21" />
473
-        </state>
474
-      </provider>
475
-    </entry>
476
-    <entry file="file://$PROJECT_DIR$/monitor/CMakeLists.txt">
477
-      <provider selected="true" editor-type-id="text-editor">
478
-        <state relative-caret-position="135">
479
-          <caret line="9" selection-start-line="9" selection-end-line="9" />
480
-        </state>
481
-      </provider>
482
-    </entry>
483
-    <entry file="file://$PROJECT_DIR$/monitor/src/functions.cpp">
484
-      <provider selected="true" editor-type-id="text-editor">
485
-        <state relative-caret-position="615">
486
-          <caret line="41" column="41" selection-start-line="41" selection-start-column="41" selection-end-line="41" selection-end-column="41" />
487
-          <folding>
488
-            <element signature="e#1028#1087#0" expanded="true" />
489
-          </folding>
490
-        </state>
491
-      </provider>
492
-    </entry>
493
-    <entry file="file://$PROJECT_DIR$/monitor/src/functions.h">
494
-      <provider selected="true" editor-type-id="text-editor">
495
-        <state relative-caret-position="203">
496
-          <caret line="33" selection-start-line="24" selection-end-line="33" />
497
-          <folding>
498
-            <element signature="e#319#337#0" expanded="true" />
499
-            <element signature="e#446#577#0" expanded="true" />
500
-            <element signature="e#588#616#0" expanded="true" />
501
-          </folding>
502
-        </state>
503
-      </provider>
504
-    </entry>
505
-    <entry file="file://$PROJECT_DIR$/build/CMakeFiles/Makefile.cmake">
506
-      <provider selected="true" editor-type-id="text-editor">
507
-        <state relative-caret-position="90">
508
-          <caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
509
-        </state>
510
-      </provider>
511
-    </entry>
512
-    <entry file="file://$PROJECT_DIR$/monitor-pc/CMakeLists.txt">
513
-      <provider selected="true" editor-type-id="text-editor">
514
-        <state>
515
-          <caret column="68" selection-start-column="68" selection-end-column="68" />
516
-        </state>
517
-      </provider>
518
-    </entry>
519
-    <entry file="file://$PROJECT_DIR$/monitor/src/main.cpp">
520
-      <provider selected="true" editor-type-id="text-editor">
521
-        <state relative-caret-position="-1185">
522
-          <caret line="20" selection-start-line="20" selection-end-line="20" />
523
-          <folding>
524
-            <element signature="e#88#106#0" expanded="true" />
525
-            <element signature="e#308#328#0" expanded="true" />
526
-          </folding>
527
-        </state>
528
-      </provider>
529
-    </entry>
530
-    <entry file="file://$PROJECT_DIR$/monitor-pc/src/functions.h">
531
-      <provider selected="true" editor-type-id="text-editor">
532
-        <state relative-caret-position="434">
533
-          <caret line="68" lean-forward="true" selection-start-line="30" selection-end-line="68" />
534
-          <folding>
535
-            <element signature="e#319#337#0" expanded="true" />
536
-          </folding>
537
-        </state>
538
-      </provider>
539
-    </entry>
540
-    <entry file="file://$PROJECT_DIR$/monitor-pc/src/main.cpp">
541
-      <provider selected="true" editor-type-id="text-editor">
542
-        <state relative-caret-position="-510">
543
-          <caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" />
544
-        </state>
545
-      </provider>
546
-    </entry>
547
-    <entry file="file://$PROJECT_DIR$/monitor-pc/src/functions.cpp">
548
-      <provider selected="true" editor-type-id="text-editor">
549
-        <state relative-caret-position="824">
550
-          <caret line="214" column="11" lean-forward="true" selection-start-line="214" selection-start-column="11" selection-end-line="214" selection-end-column="11" />
551
-        </state>
552
-      </provider>
553
-    </entry>
554
-    <entry file="file://$PROJECT_DIR$/src.sav/image.cpp">
555
-      <provider selected="true" editor-type-id="text-editor">
556
-        <state relative-caret-position="-1260">
557
-          <caret line="12" selection-start-line="12" selection-end-line="12" />
558
-          <folding>
559
-            <element signature="e#494#512#0" expanded="true" />
560
-          </folding>
561
-        </state>
562
-      </provider>
563
-    </entry>
564
-    <entry file="file://$PROJECT_DIR$/src.sav/image.h">
565
-      <provider selected="true" editor-type-id="text-editor">
566
-        <state relative-caret-position="-810" />
567
-      </provider>
568
-    </entry>
569
-    <entry file="file://$PROJECT_DIR$/monitor-pthread/CMakeLists.txt">
570
-      <provider selected="true" editor-type-id="text-editor">
571
-        <state relative-caret-position="30">
572
-          <caret line="2" column="43" lean-forward="true" selection-start-line="2" selection-start-column="43" selection-end-line="2" selection-end-column="43" />
573
-        </state>
574
-      </provider>
575
-    </entry>
576
-    <entry file="file://$PROJECT_DIR$/monitor-pthread/src/functions.cpp">
577
-      <provider selected="true" editor-type-id="text-editor">
578
-        <state relative-caret-position="-2655" />
579
-      </provider>
580
-    </entry>
581
-    <entry file="file://$PROJECT_DIR$/src.sav/monitor.h">
582
-      <provider selected="true" editor-type-id="text-editor">
583
-        <state relative-caret-position="1680">
584
-          <caret line="112" lean-forward="true" selection-start-line="19" selection-end-line="112" />
585
-          <folding>
586
-            <element signature="e#82#104#0" expanded="true" />
587
-          </folding>
588
-        </state>
589
-      </provider>
590
-    </entry>
591
-    <entry file="file://$PROJECT_DIR$/src.sav/message.h">
592
-      <provider selected="true" editor-type-id="text-editor">
593
-        <state relative-caret-position="135">
594
-          <caret line="9" column="2" lean-forward="true" selection-start-line="9" selection-start-column="2" selection-end-line="9" selection-end-column="2" />
595
-          <folding>
596
-            <element signature="e#312#330#0" expanded="true" />
597
-          </folding>
598
-        </state>
599
-      </provider>
600
-    </entry>
601
-    <entry file="file://$PROJECT_DIR$/lib/src/Serial.cpp">
602
-      <provider selected="true" editor-type-id="text-editor">
603
-        <state relative-caret-position="-1080" />
604
-      </provider>
605
-    </entry>
606
-    <entry file="file://$PROJECT_DIR$/src.sav/message.cpp">
607
-      <provider selected="true" editor-type-id="text-editor">
608
-        <state relative-caret-position="405">
609
-          <caret line="27" column="36" lean-forward="true" selection-start-line="26" selection-start-column="4" selection-end-line="27" selection-end-column="36" />
610
-        </state>
611
-      </provider>
612
-    </entry>
613
-    <entry file="file://$PROJECT_DIR$/src.sav/monitor.cpp">
614
-      <provider selected="true" editor-type-id="text-editor">
615
-        <state relative-caret-position="433">
616
-          <caret line="151" column="1" selection-start-line="146" selection-end-line="151" selection-end-column="1" />
617
-          <folding>
618
-            <element signature="e#1030#1072#0" expanded="true" />
619
-            <element signature="e#1814#1860#0" expanded="true" />
620
-            <element signature="e#1973#2002#0" expanded="true" />
621
-          </folding>
622
-        </state>
623
-      </provider>
624
-    </entry>
625
-    <entry file="file://$PROJECT_DIR$/lib/src/TcpServer.cpp">
626
-      <provider selected="true" editor-type-id="text-editor">
627
-        <state relative-caret-position="299">
628
-          <caret line="76" selection-start-line="76" selection-end-line="76" />
629
-          <folding>
630
-            <element signature="e#648#670#0" expanded="true" />
631
-          </folding>
632
-        </state>
633
-      </provider>
634
-    </entry>
635
-    <entry file="file://$PROJECT_DIR$/lib/Robot.h">
636
-      <provider selected="true" editor-type-id="text-editor">
637
-        <state relative-caret-position="-495" />
638
-      </provider>
639
-    </entry>
640
-    <entry file="file://$PROJECT_DIR$/lib/TcpServer.h">
641
-      <provider selected="true" editor-type-id="text-editor">
642
-        <state relative-caret-position="195">
643
-          <caret line="14" column="17" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
644
-        </state>
645
-      </provider>
646
-    </entry>
647
-    <entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Program.cpp">
648
-      <provider selected="true" editor-type-id="text-editor">
649
-        <state relative-caret-position="419">
650
-          <caret line="107" selection-start-line="107" selection-end-line="107" />
651
-          <folding>
652
-            <element signature="e#90#108#0" expanded="true" />
653
-          </folding>
654
-        </state>
655
-      </provider>
656
-    </entry>
657
-    <entry file="file://$PROJECT_DIR$/examples/CMakeLists.txt">
658
-      <provider selected="true" editor-type-id="text-editor">
659
-        <state relative-caret-position="135">
660
-          <caret line="9" column="22" selection-start-line="9" selection-start-column="22" selection-end-line="9" selection-end-column="22" />
661
-        </state>
662
-      </provider>
663
-    </entry>
664
-    <entry file="file://$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt">
665
-      <provider selected="true" editor-type-id="text-editor">
666
-        <state relative-caret-position="105">
667
-          <caret line="7" column="60" selection-start-line="7" selection-start-column="60" selection-end-line="7" selection-end-column="60" />
668
-        </state>
669
-      </provider>
670
-    </entry>
671
-    <entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Tasks.h">
672
-      <provider selected="true" editor-type-id="text-editor">
673
-        <state relative-caret-position="405">
674
-          <caret line="33" column="40" selection-start-line="33" selection-start-column="40" selection-end-line="33" selection-end-column="40" />
675
-          <folding>
676
-            <element signature="e#319#338#0" expanded="true" />
677
-          </folding>
678
-        </state>
679
-      </provider>
680
-    </entry>
681
-    <entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp">
682
-      <provider selected="true" editor-type-id="text-editor">
683
-        <state relative-caret-position="509">
684
-          <caret line="245" column="27" selection-start-line="245" selection-start-column="27" selection-end-line="245" selection-end-column="27" />
685
-          <folding>
686
-            <element signature="e#0#18#0" expanded="true" />
687
-          </folding>
688
-        </state>
689
-      </provider>
690
-    </entry>
691
-    <entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp">
692
-      <provider selected="true" editor-type-id="text-editor">
693
-        <state relative-caret-position="373">
694
-          <caret line="148" column="7" selection-start-line="145" selection-start-column="6" selection-end-line="148" selection-end-column="7" />
695
-          <folding>
696
-            <element signature="e#88#106#0" expanded="true" />
697
-          </folding>
698
-        </state>
699
-      </provider>
700
-    </entry>
701
-    <entry file="file://$PROJECT_DIR$/lib/src/Robot.cpp">
702
-      <provider selected="true" editor-type-id="text-editor">
703
-        <state relative-caret-position="165">
704
-          <caret line="29" column="19" selection-start-line="29" selection-start-column="19" selection-end-line="29" selection-end-column="19" />
705
-          <folding>
706
-            <element signature="e#891#909#0" expanded="true" />
707
-          </folding>
708
-        </state>
709
-      </provider>
710
-    </entry>
711
-    <entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h">
712
-      <provider selected="true" editor-type-id="text-editor">
713
-        <state relative-caret-position="748">
714
-          <caret line="84" column="60" selection-start-line="84" selection-start-column="60" selection-end-line="84" selection-end-column="60" />
715
-          <folding>
716
-            <element signature="e#316#341#0" expanded="true" />
717
-          </folding>
718
-        </state>
719
-      </provider>
720
-    </entry>
721
-    <entry file="file://$PROJECT_DIR$/lib/MsgManager.h">
722
-      <provider selected="true" editor-type-id="text-editor">
723
-        <state relative-caret-position="-151">
724
-          <caret line="20" column="8" selection-start-line="20" selection-start-column="8" selection-end-line="20" selection-end-column="8" />
725
-          <folding>
726
-            <element signature="e#86#105#0" expanded="true" />
727
-          </folding>
728
-        </state>
729
-      </provider>
730
-    </entry>
731
-    <entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp">
732
-      <provider selected="true" editor-type-id="text-editor">
733
-        <state relative-caret-position="410">
734
-          <caret line="92" column="35" lean-forward="true" selection-start-line="92" selection-start-column="35" selection-end-line="92" selection-end-column="35" />
735
-          <folding>
736
-            <element signature="e#0#19#0" expanded="true" />
737
-            <element signature="e#876#929#0" expanded="true" />
738
-            <element signature="e#1024#1083#0" expanded="true" />
739
-            <element signature="e#1218#1293#0" expanded="true" />
740
-            <element signature="e#1799#1852#0" expanded="true" />
741
-            <element signature="e#1939#2002#0" expanded="true" />
742
-            <element signature="e#2104#2194#0" expanded="true" />
743
-            <element signature="e#2383#2442#0" expanded="true" />
744
-            <element signature="e#2683#2730#0" expanded="true" />
745
-            <element signature="e#3232#3297#0" expanded="true" />
746
-            <element signature="e#3735#3816#0" expanded="true" />
747
-            <element signature="e#3922#3978#0" expanded="true" />
748
-            <element signature="e#6217#6275#0" expanded="true" />
749
-          </folding>
750
-        </state>
751
-      </provider>
752
-    </entry>
753
-    <entry file="file://$PROJECT_DIR$/lib/src/Image.cpp">
754
-      <provider selected="true" editor-type-id="text-editor">
755
-        <state relative-caret-position="419">
756
-          <caret line="51" column="6" selection-start-line="51" selection-start-column="6" selection-end-line="51" selection-end-column="26" />
757
-        </state>
758
-      </provider>
759
-    </entry>
760
-    <entry file="file://$PROJECT_DIR$/lib/src/MsgManager.cpp">
761
-      <provider selected="true" editor-type-id="text-editor">
762
-        <state relative-caret-position="339">
763
-          <caret line="136" column="23" selection-start-line="136" selection-start-column="23" selection-end-line="136" selection-end-column="23" />
764
-          <folding>
765
-            <element signature="e#44#64#0" expanded="true" />
766
-            <element signature="e#751#793#0" expanded="true" />
767
-            <element signature="e#832#878#0" expanded="true" />
768
-            <element signature="e#938#967#0" expanded="true" />
769
-            <element signature="e#1253#1282#0" expanded="true" />
770
-          </folding>
771
-        </state>
772
-      </provider>
773
-    </entry>
774
-    <entry file="file://$PROJECT_DIR$/superviseur-xenomai/CMakeLists.txt">
775
-      <provider selected="true" editor-type-id="text-editor">
776
-        <state relative-caret-position="60">
777
-          <caret line="4" column="82" selection-start-line="4" selection-start-column="82" selection-end-line="4" selection-end-column="82" />
778
-        </state>
779
-      </provider>
780
-    </entry>
781
-    <entry file="file://$PROJECT_DIR$/lib/image.h">
782
-      <provider selected="true" editor-type-id="text-editor">
783
-        <state relative-caret-position="209">
784
-          <caret line="17" selection-start-line="17" selection-end-line="17" />
785
-          <folding>
786
-            <element signature="e#566#599#0" expanded="true" />
787
-            <element signature="e#635#673#0" expanded="true" />
788
-            <element signature="e#865#890#0" expanded="true" />
789
-            <element signature="e#935#962#0" expanded="true" />
790
-          </folding>
791
-        </state>
792
-      </provider>
793
-    </entry>
794
-    <entry file="file://$PROJECT_DIR$/lib/src/message.cpp">
795
-      <provider selected="true" editor-type-id="text-editor">
796
-        <state relative-caret-position="405">
797
-          <caret line="27" column="32" selection-start-line="27" selection-start-column="32" selection-end-line="27" selection-end-column="32" />
798
-        </state>
799
-      </provider>
800
-    </entry>
801
-    <entry file="file://$PROJECT_DIR$/lib/monitor.h">
802
-      <provider selected="true" editor-type-id="text-editor">
803
-        <state relative-caret-position="389">
804
-          <caret line="64" column="94" selection-start-line="64" selection-start-column="94" selection-end-line="64" selection-end-column="94" />
805
-        </state>
806
-      </provider>
807
-    </entry>
808
-    <entry file="file://$PROJECT_DIR$/lib/src/monitor.cpp">
809
-      <provider selected="true" editor-type-id="text-editor">
810
-        <state relative-caret-position="338">
811
-          <caret line="104" column="23" selection-start-line="104" selection-start-column="23" selection-end-line="104" selection-end-column="23" />
812
-        </state>
813
-      </provider>
814
-    </entry>
815
-    <entry file="file://$PROJECT_DIR$/superviseur/src/functions.h">
816
-      <provider selected="true" editor-type-id="text-editor">
817
-        <state relative-caret-position="180">
818
-          <caret line="51" column="21" selection-start-line="51" selection-start-column="12" selection-end-line="51" selection-end-column="21" />
819
-          <folding>
820
-            <element signature="e#319#337#0" expanded="true" />
821
-          </folding>
822
-        </state>
823
-      </provider>
824
-    </entry>
825
-    <entry file="file://$PROJECT_DIR$/CMakeLists.txt">
826
-      <provider selected="true" editor-type-id="text-editor">
827
-        <state relative-caret-position="330">
828
-          <caret line="22" selection-start-line="22" selection-end-line="22" />
829
-        </state>
830
-      </provider>
831
-    </entry>
832
-    <entry file="file://$PROJECT_DIR$/lib/CMakeLists.txt">
833
-      <provider selected="true" editor-type-id="text-editor">
834
-        <state>
835
-          <caret column="81" selection-start-column="81" selection-end-column="81" />
836
-        </state>
837
-      </provider>
838
-    </entry>
839
-    <entry file="file://$PROJECT_DIR$/superviseur/CMakeLists.txt">
840
-      <provider selected="true" editor-type-id="text-editor">
841
-        <state relative-caret-position="135">
842
-          <caret line="9" selection-start-line="9" selection-end-line="9" />
843
-        </state>
844
-      </provider>
845
-    </entry>
846
-    <entry file="file://$PROJECT_DIR$/superviseur/src/main.cpp">
847
-      <provider selected="true" editor-type-id="text-editor">
848
-        <state relative-caret-position="75">
849
-          <caret line="89" column="13" selection-start-line="89" selection-start-column="13" selection-end-line="89" selection-end-column="13" />
850
-          <folding>
851
-            <element signature="e#88#106#0" expanded="true" />
852
-          </folding>
853
-        </state>
854
-      </provider>
855
-    </entry>
856
-    <entry file="file://$PROJECT_DIR$/superviseur/src/functions.cpp">
857
-      <provider selected="true" editor-type-id="text-editor">
858
-        <state relative-caret-position="300">
859
-          <caret line="20" column="19" selection-start-line="20" selection-start-column="19" selection-end-line="20" selection-end-column="19" />
860
-        </state>
861
-      </provider>
862
-    </entry>
863
-  </component>
864
-</project>

BIN
software/raspberry/superviseur-robot/dist/Debug__Pthread_/GNU-Linux/superviseur-robot View File


+ 2
- 0
software/raspberry/superviseur-robot/lib/base64/.gitignore View File

@@ -0,0 +1,2 @@
1
+*.swp
2
+test-base64

+ 19
- 0
software/raspberry/superviseur-robot/lib/base64/LICENSE View File

@@ -0,0 +1,19 @@
1
+Copyright © 2004-2017 by René Nyffenegger
2
+
3
+This source code is provided 'as-is', without any express or implied
4
+warranty. In no event will the author be held liable for any damages
5
+arising from the use of this software.
6
+                                                                              
7
+Permission is granted to anyone to use this software for any purpose,
8
+including commercial applications, and to alter it and redistribute it
9
+freely, subject to the following restrictions:
10
+                                                                              
11
+1. The origin of this source code must not be misrepresented; you must not
12
+   claim that you wrote the original source code. If you use this source code
13
+   in a product, an acknowledgment in the product documentation would be
14
+   appreciated but is not required.
15
+                                                                              
16
+2. Altered source versions must be plainly marked as such, and must not be
17
+   misrepresented as being the original source code.
18
+                                                                              
19
+3. This notice may not be removed or altered from any source distribution.

+ 7
- 0
software/raspberry/superviseur-robot/lib/base64/README.md View File

@@ -0,0 +1,7 @@
1
+# base64 (C++)
2
+
3
+Base64 encoding and decoding with c++
4
+
5
+## See also
6
+
7
+https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp

+ 122
- 0
software/raspberry/superviseur-robot/lib/base64/base64.cpp View File

@@ -0,0 +1,122 @@
1
+/* 
2
+   base64.cpp and base64.h
3
+
4
+   base64 encoding and decoding with C++.
5
+
6
+   Version: 1.01.00
7
+
8
+   Copyright (C) 2004-2017 René Nyffenegger
9
+
10
+   This source code is provided 'as-is', without any express or implied
11
+   warranty. In no event will the author be held liable for any damages
12
+   arising from the use of this software.
13
+
14
+   Permission is granted to anyone to use this software for any purpose,
15
+   including commercial applications, and to alter it and redistribute it
16
+   freely, subject to the following restrictions:
17
+
18
+   1. The origin of this source code must not be misrepresented; you must not
19
+      claim that you wrote the original source code. If you use this source code
20
+      in a product, an acknowledgment in the product documentation would be
21
+      appreciated but is not required.
22
+
23
+   2. Altered source versions must be plainly marked as such, and must not be
24
+      misrepresented as being the original source code.
25
+
26
+   3. This notice may not be removed or altered from any source distribution.
27
+
28
+   René Nyffenegger rene.nyffenegger@adp-gmbh.ch
29
+
30
+*/
31
+
32
+#include "base64.h"
33
+#include <iostream>
34
+
35
+static const std::string base64_chars = 
36
+             "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
37
+             "abcdefghijklmnopqrstuvwxyz"
38
+             "0123456789+/";
39
+
40
+
41
+static inline bool is_base64(unsigned char c) {
42
+  return (isalnum(c) || (c == '+') || (c == '/'));
43
+}
44
+
45
+std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
46
+  std::string ret;
47
+  int i = 0;
48
+  int j = 0;
49
+  unsigned char char_array_3[3];
50
+  unsigned char char_array_4[4];
51
+
52
+  while (in_len--) {
53
+    char_array_3[i++] = *(bytes_to_encode++);
54
+    if (i == 3) {
55
+      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
56
+      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
57
+      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
58
+      char_array_4[3] = char_array_3[2] & 0x3f;
59
+
60
+      for(i = 0; (i <4) ; i++)
61
+        ret += base64_chars[char_array_4[i]];
62
+      i = 0;
63
+    }
64
+  }
65
+
66
+  if (i)
67
+  {
68
+    for(j = i; j < 3; j++)
69
+      char_array_3[j] = '\0';
70
+
71
+    char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
72
+    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
73
+    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
74
+
75
+    for (j = 0; (j < i + 1); j++)
76
+      ret += base64_chars[char_array_4[j]];
77
+
78
+    while((i++ < 3))
79
+      ret += '=';
80
+
81
+  }
82
+
83
+  return ret;
84
+
85
+}
86
+
87
+std::string base64_decode(std::string const& encoded_string) {
88
+  int in_len = encoded_string.size();
89
+  int i = 0;
90
+  int j = 0;
91
+  int in_ = 0;
92
+  unsigned char char_array_4[4], char_array_3[3];
93
+  std::string ret;
94
+
95
+  while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
96
+    char_array_4[i++] = encoded_string[in_]; in_++;
97
+    if (i ==4) {
98
+      for (i = 0; i <4; i++)
99
+        char_array_4[i] = base64_chars.find(char_array_4[i]);
100
+
101
+      char_array_3[0] = ( char_array_4[0] << 2       ) + ((char_array_4[1] & 0x30) >> 4);
102
+      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
103
+      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) +   char_array_4[3];
104
+
105
+      for (i = 0; (i < 3); i++)
106
+        ret += char_array_3[i];
107
+      i = 0;
108
+    }
109
+  }
110
+
111
+  if (i) {
112
+    for (j = 0; j < i; j++)
113
+      char_array_4[j] = base64_chars.find(char_array_4[j]);
114
+
115
+    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
116
+    char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
117
+
118
+    for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
119
+  }
120
+
121
+  return ret;
122
+}

+ 14
- 0
software/raspberry/superviseur-robot/lib/base64/base64.h View File

@@ -0,0 +1,14 @@
1
+//
2
+//  base64 encoding and decoding with C++.
3
+//  Version: 1.01.00
4
+//
5
+
6
+#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
7
+#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
8
+
9
+#include <string>
10
+
11
+std::string base64_encode(unsigned char const* , unsigned int len);
12
+std::string base64_decode(std::string const& s);
13
+
14
+#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */

+ 2
- 0
software/raspberry/superviseur-robot/lib/base64/compile-and-run-test View File

@@ -0,0 +1,2 @@
1
+g++ test.cpp base64.cpp -o test-base64
2
+./test-base64

+ 56
- 0
software/raspberry/superviseur-robot/lib/base64/test.cpp View File

@@ -0,0 +1,56 @@
1
+#include "base64.h"
2
+#include <iostream>
3
+
4
+int main() {
5
+  const std::string s = 
6
+    "René Nyffenegger\n"
7
+    "http://www.renenyffenegger.ch\n"
8
+    "passion for data\n";
9
+
10
+  std::string encoded = base64_encode(reinterpret_cast<const unsigned char*>(s.c_str()), s.length());
11
+  std::string decoded = base64_decode(encoded);
12
+
13
+  std::cout << "encoded: " << std::endl << encoded << std::endl << std::endl;
14
+  std::cout << "decoded: " << std::endl << decoded << std::endl;
15
+
16
+
17
+  // Test all possibilites of fill bytes (none, one =, two ==)
18
+  // References calculated with: https://www.base64encode.org/
19
+
20
+  std::string rest0_original = "abc";
21
+  std::string rest0_reference = "YWJj";
22
+
23
+  std::string rest0_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest0_original.c_str()),
24
+    rest0_original.length());
25
+  std::string rest0_decoded = base64_decode(rest0_encoded);
26
+
27
+  std::cout << "encoded:   " << rest0_encoded << std::endl;
28
+  std::cout << "reference: " << rest0_reference << std::endl;
29
+  std::cout << "decoded:   " << rest0_decoded << std::endl << std::endl;
30
+
31
+
32
+  std::string rest1_original = "abcd";
33
+  std::string rest1_reference = "YWJjZA==";
34
+
35
+  std::string rest1_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest1_original.c_str()),
36
+    rest1_original.length());
37
+  std::string rest1_decoded = base64_decode(rest1_encoded);
38
+
39
+  std::cout << "encoded:   " << rest1_encoded << std::endl;
40
+  std::cout << "reference: " << rest1_reference << std::endl;
41
+  std::cout << "decoded:   " << rest1_decoded << std::endl << std::endl;
42
+
43
+
44
+  std::string rest2_original = "abcde";
45
+  std::string rest2_reference = "YWJjZGU=";
46
+
47
+  std::string rest2_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest2_original.c_str()),
48
+    rest2_original.length());
49
+  std::string rest2_decoded = base64_decode(rest2_encoded);
50
+
51
+  std::cout << "encoded:   " << rest2_encoded << std::endl;
52
+  std::cout << "reference: " << rest2_reference << std::endl;
53
+  std::cout << "decoded:   " << rest2_decoded << std::endl << std::endl;
54
+
55
+  return 0;
56
+}

+ 23
- 23
software/raspberry/superviseur-robot/lib/camera.cpp View File

@@ -20,8 +20,24 @@
20 20
 
21 21
 using namespace cv;
22 22
 
23
-void Camera::setSize(int size) {
23
+Camera::Camera(int size) {
24
+    this->SetSize(size);
25
+    this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
26
+    this->cap.set(CV_CAP_PROP_FRAME_WIDTH,width);
27
+    this->cap.set(CV_CAP_PROP_FRAME_HEIGHT,height);
28
+}
29
+
30
+bool Camera::Open() {
31
+    this->cap.open(0);
32
+}
33
+
34
+void Camera::Close() {
35
+    this->cap.release();
36
+}
37
+
38
+void Camera::SetSize(int size) {
24 39
     this->size = size;
40
+    
25 41
     switch (size){
26 42
         case xs:
27 43
             this->width = 480;
@@ -46,40 +62,24 @@ void Camera::setSize(int size) {
46 62
     }
47 63
 }
48 64
 
49
-
50
-int Camera::open_camera() {
51
-    this->cap.open(0);
52
-}
53
-
54
-Camera::Camera(int size) {
55
-    this->setSize(size);
56
-    this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
57
-    this->cap.set(CV_CAP_PROP_FRAME_WIDTH,width);
58
-    this->cap.set(CV_CAP_PROP_FRAME_HEIGHT,height);
59
-}
60
-
61
-int Camera::close_camera() {
62
-    cap.release();
63
-    return 0;
64
-}
65
-
66
-Img Camera::grab_image() {
65
+Img Camera::Grab() {
67 66
     ImageMat frame;
67
+    
68 68
     cap >> frame;
69 69
     Img capture = Img(frame);
70
+    
70 71
     return capture;
71 72
 }
72 73
 
73
-
74
-bool Camera::isOpen() {
74
+bool Camera::IsOpen() {
75 75
     return cap.isOpened();
76 76
 }
77 77
 
78
-int Camera::getWidth() const {
78
+int Camera::GetWidth() const {
79 79
     return width;
80 80
 }
81 81
 
82
-int Camera::getHeight() const {
82
+int Camera::GetHeight() const {
83 83
     return height;
84 84
 }
85 85
 

+ 8
- 10
software/raspberry/superviseur-robot/lib/camera.h View File

@@ -27,20 +27,18 @@ enum captureSize {xs, sm, md, lg};
27 27
 
28 28
 class Camera {
29 29
 public:
30
-
31 30
     Camera(int size);
32 31
 
33
-    int open_camera();
34
-
35
-    int getWidth() const;
36
-
37
-    int getHeight() const;
32
+    bool Open();
33
+    void Close();
34
+    
35
+    int GetWidth() const;
36
+    int GetHeight() const;
38 37
 
39
-    bool isOpen();
40
-    void setSize(int size);
38
+    bool IsOpen();
39
+    void SetSize(int size);
41 40
 
42
-    int close_camera();
43
-    Img grab_image();
41
+    Img Grab();
44 42
     
45 43
 private:
46 44
     cv::VideoCapture cap;

+ 34
- 14
software/raspberry/superviseur-robot/lib/commonitor.cpp View File

@@ -28,6 +28,8 @@
28 28
 #include <stdexcept>
29 29
 #include <string>
30 30
 
31
+#include "base64/base64.h"
32
+
31 33
 /*
32 34
  * @brief Constants used for sending commands to monitor
33 35
  */
@@ -41,7 +43,7 @@ const string LABEL_MONITOR_CAMERA_OPEN = "COPN";
41 43
 const string LABEL_MONITOR_CAMERA_CLOSE = "CCLS";
42 44
 const string LABEL_MONITOR_CAMERA_IMAGE = "CIMG";
43 45
 const string LABEL_MONITOR_CAMERA_ARENA_ASK = "CASA";
44
-const string LABEL_MONITOR_CAMERA_ARENA_INFIRME = "CAIN";
46
+const string LABEL_MONITOR_CAMERA_ARENA_INFIRM = "CAIN";
45 47
 const string LABEL_MONITOR_CAMERA_ARENA_CONFIRM = "CACO";
46 48
 const string LABEL_MONITOR_CAMERA_POSITION_COMPUTE = "CPCO";
47 49
 const string LABEL_MONITOR_CAMERA_POSITION_STOP = "CPST";
@@ -83,6 +85,12 @@ int ComMonitor::Open(int port) {
83 85
         throw std::runtime_error{"Can not create socket"};
84 86
     }
85 87
 
88
+    int enable = 1;
89
+    if (setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) {
90
+        cerr<<"setsockopt(SO_REUSEADDR) failed"<<endl<<flush;
91
+    }
92
+    
93
+    bzero((char *) &server, sizeof(server));
86 94
     server.sin_addr.s_addr = INADDR_ANY;
87 95
     server.sin_family = AF_INET;
88 96
     server.sin_port = htons(port);
@@ -130,9 +138,9 @@ int ComMonitor::AcceptClient() {
130 138
  * @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
131 139
  * @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously  
132 140
  */
133
-void ComMonitor::Write(Message &msg) {
141
+void ComMonitor::Write(Message *msg) {
134 142
     string str;
135
-
143
+    
136 144
     // Call user method before Write
137 145
     Write_Pre();
138 146
 
@@ -142,8 +150,10 @@ void ComMonitor::Write(Message &msg) {
142 150
     //cout << "Message sent to monitor: " << str->c_str() << endl;
143 151
     write(clientID, str.c_str(), str.length());
144 152
 
145
-    delete(&msg);
146
-
153
+    if (!msg->CompareID(MESSAGE_CAM_IMAGE)) {
154
+        delete(msg);
155
+    }
156
+   
147 157
     // Call user method after write
148 158
     Write_Post();
149 159
 }
@@ -191,13 +201,17 @@ Message *ComMonitor::Read() {
191 201
  * @param msg Message to be converted
192 202
  * @return A string, image of the message
193 203
  */
194
-string ComMonitor::MessageToString(Message &msg) {
204
+string ComMonitor::MessageToString(Message *msg) {
195 205
     int id;
196 206
     string str;
197
-    Message *localMsg = &msg;
207
+    //Message *localMsg = msg;
198 208
     Position pos;
199 209
 
200
-    id = msg.GetID();
210
+    Img *image;
211
+    Jpg jpeg ;
212
+    string s;
213
+                    
214
+    id = msg->GetID();
201 215
 
202 216
     switch (id) {
203 217
         case MESSAGE_ANSWER_ACK :
@@ -219,17 +233,23 @@ string ComMonitor::MessageToString(Message &msg) {
219 233
             str.append(LABEL_MONITOR_ANSWER_COM_ERROR);
220 234
             break;
221 235
         case MESSAGE_CAM_POSITION:
222
-            pos = ((MessagePosition*) & msg)->GetPosition();
236
+            pos = ((MessagePosition*) msg)->GetPosition();
223 237
 
224 238
             str.append(LABEL_MONITOR_CAMERA_POSITION + LABEL_SEPARATOR_CHAR + to_string(pos.robotId) + ";" +
225 239
                     to_string(pos.angle) + ";" + to_string(pos.center.x) + ";" + to_string(pos.center.y) + ";" +
226 240
                     to_string(pos.direction.x) + ";" + to_string(pos.direction.y));
227 241
             break;
228 242
         case MESSAGE_CAM_IMAGE:
229
-            str.append(LABEL_MONITOR_CAMERA_IMAGE + LABEL_SEPARATOR_CHAR + ((MessageImg*) & msg)->GetImage()->ToBase64());
243
+            image=((MessageImg*) msg)->GetImage();
244
+            jpeg = image->ToJpg();
245
+            
246
+            cout << "Jpeg size: " << to_string(jpeg.size())<<endl<<flush;
247
+            
248
+            s = base64_encode(jpeg.data(), jpeg.size());
249
+            str.append(LABEL_MONITOR_CAMERA_IMAGE + LABEL_SEPARATOR_CHAR + s);
230 250
             break;
231 251
         case MESSAGE_ROBOT_BATTERY_LEVEL:
232
-            str.append(LABEL_MONITOR_ROBOT_BATTERY_LEVEL + LABEL_SEPARATOR_CHAR + to_string(((MessageBattery*) & msg)->GetLevel()));
252
+            str.append(LABEL_MONITOR_ROBOT_BATTERY_LEVEL + LABEL_SEPARATOR_CHAR + to_string(((MessageBattery*) msg)->GetLevel()));
233 253
             break;
234 254
         case MESSAGE_ROBOT_STATE_BUSY:
235 255
             str.append(LABEL_MONITOR_ROBOT_CURRENT_STATE + LABEL_SEPARATOR_CHAR + "1");
@@ -238,13 +258,13 @@ string ComMonitor::MessageToString(Message &msg) {
238 258
             str.append(LABEL_MONITOR_ROBOT_CURRENT_STATE + LABEL_SEPARATOR_CHAR + "0");
239 259
             break;
240 260
         case MESSAGE_LOG:
241
-            str.append(LABEL_MONITOR_MESSAGE + LABEL_SEPARATOR_CHAR + ((MessageString*) & msg)->GetString());
261
+            str.append(LABEL_MONITOR_MESSAGE + LABEL_SEPARATOR_CHAR + ((MessageString*) msg)->GetString());
242 262
             break;
243 263
         case MESSAGE_EMPTY:
244 264
             str.append(""); //empty string
245 265
             break;
246 266
         default:
247
-            cerr<<"["<<__PRETTY_FUNCTION__<<"] (from ComMonitor::Write): Invalid message to send ("<<msg.ToString()<<")"<<endl<<flush;
267
+            cerr<<"["<<__PRETTY_FUNCTION__<<"] (from ComMonitor::Write): Invalid message to send ("<<msg->ToString()<<")"<<endl<<flush;
248 268
             throw std::runtime_error {"Invalid message to send"};
249 269
     }
250 270
 
@@ -291,7 +311,7 @@ Message *ComMonitor::StringToMessage(string &s) {
291 311
         msg = new Message(MESSAGE_CAM_ASK_ARENA);
292 312
     } else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_CONFIRM) != string::npos) {
293 313
         msg = new Message(MESSAGE_CAM_ARENA_CONFIRM);
294
-    } else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_INFIRME) != string::npos) {
314
+    } else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_INFIRM) != string::npos) {
295 315
         msg = new Message(MESSAGE_CAM_ARENA_INFIRM);
296 316
     } else if (tokenCmd.find(LABEL_MONITOR_CAMERA_CLOSE) != string::npos) {
297 317
         msg = new Message(MESSAGE_CAM_CLOSE);

+ 3
- 3
software/raspberry/superviseur-robot/lib/commonitor.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 using namespace std;
25 25
      
26
-#define SERVER_PORT 1234
26
+#define SERVER_PORT 5544
27 27
 
28 28
 /**
29 29
  * Class used for generating a server and communicating through it with monitor
@@ -71,7 +71,7 @@ public:
71 71
      * @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
72 72
      * @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously  
73 73
      */
74
-    void Write(Message &msg);
74
+    void Write(Message *msg);
75 75
     
76 76
     /**
77 77
      * Function called at beginning of Write method
@@ -121,7 +121,7 @@ protected:
121 121
      * @param msg Message to be converted
122 122
      * @return A string, image of the message
123 123
      */
124
-    string MessageToString(Message &msg);
124
+    string MessageToString(Message *msg);
125 125
     
126 126
     /**
127 127
      * Method used internally to convert a string received over TCP to a message 

+ 30
- 34
software/raspberry/superviseur-robot/lib/img.cpp View File

@@ -17,8 +17,8 @@
17 17
 
18 18
 #include "img.h"
19 19
 
20
-bool Arene::empty() {
21
-    if ((this->arene.height==0) || (this->arene.width==0)) return true;
20
+bool Arena::IsEmpty() {
21
+    if ((this->arena.height==0) || (this->arena.width==0)) return true;
22 22
     else return false;
23 23
 }
24 24
 
@@ -29,23 +29,19 @@ Img::Img(ImageMat imgMatrice) {
29 29
 string Img::ToString() {
30 30
     return "Image size: "+to_string(this->img.cols)+"x"+to_string(this->img.rows)+" (dim="+to_string(this->img.dims)+")";
31 31
 }
32
-    
33
-string Img::ToBase64() {
34
-    return "";
35
-}
36 32
 
37 33
 Img* Img::Copy() {
38 34
     return new Img(this->img);
39 35
 }
40 36
     
41
-float Img::calculAngle(Position robot) {
37
+float Img::CalculAngle(Position robot) {
42 38
     float a = robot.direction.x - robot.center.x;
43 39
     float b = robot.direction.y - robot.center.y ;
44 40
     float angle = atan2(b,a);
45 41
     return angle * 180.f/M_PI;
46 42
 }
47 43
 
48
-float Img::calculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
44
+float Img::CalculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
49 45
     float a = pt1.x - pt2.x;
50 46
     float b = pt1.y - pt2.y ;
51 47
     float angle = atan2(b,a);
@@ -61,7 +57,7 @@ cv::Point2f Img::find_aruco_direction(std::vector<cv::Point2f> aruco) {
61 57
     return ((aruco[0]+aruco[1])/2);;
62 58
 }
63 59
 
64
-std::list<Position> Img::search_aruco(Arene monArene) {
60
+std::list<Position> Img::search_aruco(Arena monArene) {
65 61
     ImageMat imgTraitment;
66 62
     std::list<Position> positionList;
67 63
     cv::Point2f areneCoor;
@@ -93,12 +89,12 @@ std::list<Position> Img::search_aruco(Arene monArene) {
93 89
 }
94 90
 #endif // __WITH_ARUCO__
95 91
 
96
-float Img::euclideanDist(cv::Point2f p, cv::Point2f q) {
92
+float Img::EuclideanDistance(cv::Point2f p, cv::Point2f q) {
97 93
     cv::Point diff = p - q;
98 94
     return cv::sqrt(diff.x*diff.x + diff.y*diff.y);
99 95
 }
100 96
 
101
-Jpg Img::toJpg() {
97
+Jpg Img::ToJpg() {
102 98
     Jpg imgJpg;
103 99
     cv::imencode(".jpg",this->img,imgJpg);
104 100
     return imgJpg;
@@ -112,7 +108,7 @@ Jpg Img::toJpg() {
112 108
 //    return imgBase64;
113 109
 //}
114 110
 
115
-std::list<Position> Img::search_robot(Arene monArene) {
111
+std::list<Position> Img::SearchRobot(Arena monArene) {
116 112
 
117 113
     std::list<Position> robotsFind;
118 114
     std::vector<std::vector<cv::Point2f> > contours;
@@ -121,10 +117,10 @@ std::list<Position> Img::search_robot(Arene monArene) {
121 117
 
122 118
     ImageMat imgTraitment;
123 119
 
124
-    if(monArene.empty())
120
+    if(monArene.IsEmpty())
125 121
         imgTraitment=this->img.clone();
126 122
     else
127
-        imgTraitment = cropArena(monArene);
123
+        imgTraitment = CropArena(monArene);
128 124
 
129 125
     cvtColor(imgTraitment,imgTraitment,CV_RGB2GRAY);
130 126
     threshold(imgTraitment,imgTraitment,128,255,CV_THRESH_BINARY);
@@ -145,14 +141,14 @@ std::list<Position> Img::search_robot(Arene monArene) {
145 141
             c = approx[2];
146 142
 
147 143
 
148
-            if(!monArene.empty()) // ajout de l'offset de l'arène
144
+            if(!monArene.IsEmpty()) // ajout de l'offset de l'arène
149 145
             {
150
-                a.x += monArene.arene.x;
151
-                a.y += monArene.arene.y;
152
-                b.x += monArene.arene.x;
153
-                b.y += monArene.arene.y;
154
-                c.x += monArene.arene.x;
155
-                c.y += monArene.arene.y;
146
+                a.x += monArene.arena.x;
147
+                a.y += monArene.arena.y;
148
+                b.x += monArene.arena.x;
149
+                b.y += monArene.arena.y;
150
+                c.x += monArene.arena.x;
151
+                c.y += monArene.arena.y;
156 152
             }
157 153
 
158 154
             center.x = (a.x + b.x + c.x)/3;
@@ -160,13 +156,13 @@ std::list<Position> Img::search_robot(Arene monArene) {
160 156
             Position newPos;
161 157
             newPos.center=center;
162 158
 
163
-            if(euclideanDist(center,b) > euclideanDist(center,a) && euclideanDist(center,b) > euclideanDist(center,c) )
159
+            if(EuclideanDistance(center,b) > EuclideanDistance(center,a) && EuclideanDistance(center,b) > EuclideanDistance(center,c) )
164 160
             {
165 161
 
166 162
                 newPos.direction=b;
167 163
                 //line(img,center,b,Scalar(0,125,0),2,8,0);
168 164
             }
169
-            else if(euclideanDist(center,a) > euclideanDist(center,c))
165
+            else if(EuclideanDistance(center,a) > EuclideanDistance(center,c))
170 166
             {
171 167
                 newPos.direction=a;
172 168
                 //line(img,center,a,Scalar(0,125,0),2,8,0);
@@ -177,14 +173,14 @@ std::list<Position> Img::search_robot(Arene monArene) {
177 173
                 newPos.direction=c;
178 174
                 //line(img,center,c,Scalar(0,125,0),2,8,0);
179 175
             }
180
-            newPos.angle=calculAngle(newPos);
176
+            newPos.angle=CalculAngle(newPos);
181 177
             robotsFind.push_back(newPos);
182 178
         }
183 179
     }
184 180
     return robotsFind;
185 181
 }
186 182
 
187
-Arene Img::search_arena() {
183
+Arena Img::SearchArena() {
188 184
     std::vector<std::vector<cv::Point> > contours;
189 185
     std::vector<cv::Point> approx;
190 186
     std::vector<cv::Vec4i> hierarchy;
@@ -200,31 +196,31 @@ Arene Img::search_arena() {
200 196
         approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true)*0.1, true);
201 197
         if(approx.size()==4 && fabs(cv::contourArea(contours[i])) > 100000)
202 198
         {
203
-            Arene rectangle;
204
-            rectangle.arene = cv::boundingRect(ImageMat(contours[i]));
199
+            Arena rectangle;
200
+            rectangle.arena = cv::boundingRect(ImageMat(contours[i]));
205 201
             return rectangle;
206 202
         }
207 203
     }
208
-    return Arene();
204
+    return Arena();
209 205
 }
210 206
 
211
-int Img::draw_robot(Position robot) {
207
+int Img::DrawRobot(Position robot) {
212 208
     cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0,0,255),3,8,0);
213 209
     return 0;
214 210
 }
215 211
 
216
-int Img::draw_all_robots(std::list<Position> robots) {
212
+int Img::DrawAllRobots(std::list<Position> robots) {
217 213
     for(Position robot  : robots){
218 214
         cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0,0,255),3,8,0);
219 215
     }
220 216
     return robots.size();
221 217
 }
222 218
 
223
-int Img::draw_arena(Arene areneToDraw) {
224
-    cv::rectangle(this->img,areneToDraw.arene.tl(),areneToDraw.arene.br(),cv::Scalar(0,0,125),2,8,0);
219
+int Img::DrawArena(Arena areneToDraw) {
220
+    cv::rectangle(this->img,areneToDraw.arena.tl(),areneToDraw.arena.br(),cv::Scalar(0,0,125),2,8,0);
225 221
     return 0;
226 222
 }
227 223
 
228
-ImageMat Img::cropArena(Arene arene) {
229
-    return this->img(arene.arene);
224
+ImageMat Img::CropArena(Arena arene) {
225
+    return this->img(arene.arena);
230 226
 }

+ 15
- 16
software/raspberry/superviseur-robot/lib/img.h View File

@@ -47,12 +47,12 @@ typedef struct {
47 47
     int robotId;
48 48
 } Position;
49 49
 
50
-class Arene {
50
+class Arena {
51 51
 public:
52
-    Arene() {}
52
+    Arena() {}
53 53
     
54
-    cv::Rect arene;
55
-    bool empty();
54
+    cv::Rect arena;
55
+    bool IsEmpty();
56 56
 };
57 57
 
58 58
 class Img {
@@ -62,18 +62,17 @@ public:
62 62
     string ToString();
63 63
     Img* Copy();
64 64
     
65
-    Jpg toJpg();
66
-    string ToBase64();
67
-    Arene search_arena();
65
+    Jpg ToJpg();
66
+    Arena SearchArena();
68 67
 
69
-    int draw_robot(Position robot);
70
-    int draw_all_robots(std::list<Position> robots);
71
-    int draw_arena(Arene areneToDraw);
72
-    std::list<Position> search_robot(Arene monArene);
68
+    int DrawRobot(Position robot);
69
+    int DrawAllRobots(std::list<Position> robots);
70
+    int DrawArena(Arena areneToDraw);
71
+    std::list<Position> SearchRobot(Arena myArena);
73 72
     
74 73
     
75 74
 #ifdef __WITH_ARUCO__    
76
-    list<Position> search_aruco(Arene monArene = NULL);
75
+    list<Position> search_aruco(Arena monArene = NULL);
77 76
 #endif // __WITH_ARUCO__
78 77
 private:
79 78
     ImageMat img;
@@ -84,10 +83,10 @@ private:
84 83
     cv::Point2f find_aruco_direction(std::vector<cv::Point2f> aruco);
85 84
 #endif // __WITH_ARUCO__
86 85
     
87
-    float calculAngle(Position robots);
88
-    float calculAngle2(cv::Point2f pt1, cv::Point2f pt2);
89
-    float euclideanDist(cv::Point2f p, cv::Point2f q);
90
-    ImageMat cropArena(Arene arene);
86
+    float CalculAngle(Position robots);
87
+    float CalculAngle2(cv::Point2f pt1, cv::Point2f pt2);
88
+    float EuclideanDistance(cv::Point2f p, cv::Point2f q);
89
+    ImageMat CropArena(Arena arene);
91 90
 };
92 91
 
93 92
 #endif //__IMG_H__

+ 3
- 3
software/raspberry/superviseur-robot/lib/messages.cpp View File

@@ -291,7 +291,7 @@ MessageImg::MessageImg() {
291 291
  * @param image Image
292 292
  * @throw std::runtime_error if message ID is incompatible with image
293 293
  */
294
-MessageImg::MessageImg(MessageID id, Img* image) {
294
+MessageImg::MessageImg(MessageID id, Img *image) {
295 295
     MessageImg::SetID(id);
296 296
     MessageImg::SetImage(image);
297 297
 }
@@ -322,7 +322,8 @@ void MessageImg::SetID(MessageID id) {
322 322
  * @param image Reference to image object
323 323
  */
324 324
 void MessageImg::SetImage(Img* image) {
325
-    this->image = image->Copy();
325
+    //this->image = image->Copy();
326
+    this->image = image;
326 327
 }
327 328
 
328 329
 /**
@@ -341,7 +342,6 @@ string MessageImg::ToString() {
341 342
  * @return A message, copy of current
342 343
  */
343 344
 Message* MessageImg::Copy() {
344
-    
345 345
     return new MessageImg(this->messageID, this->image->Copy());
346 346
 }
347 347
 

+ 5
- 5
software/raspberry/superviseur-robot/lib/messages.h View File

@@ -39,14 +39,14 @@ typedef enum {
39 39
     MESSAGE_ANSWER_ROBOT_UNKNOWN_COMMAND,
40 40
     MESSAGE_ANSWER_ROBOT_ERROR,
41 41
     MESSAGE_ANSWER_COM_ERROR,
42
-           
42
+      
43
+    // Messages specific to server
44
+    MESSAGE_MONITOR_LOST,
45
+    
43 46
     // messages for serial communication with robot
44 47
     MESSAGE_ROBOT_COM_OPEN,
45 48
     MESSAGE_ROBOT_COM_CLOSE,
46 49
          
47
-    // Messages specific to server
48
-    MESSAGE_MONITOR_LOST,
49
-    
50 50
     // Messages for camera   
51 51
     MESSAGE_CAM_OPEN,
52 52
     MESSAGE_CAM_CLOSE,
@@ -373,7 +373,7 @@ public:
373 373
      * @param image Pointer to image
374 374
      * @throw std::runtime_error if message ID is incompatible with image message
375 375
      */
376
-    MessageImg(MessageID id, Img* image);
376
+    MessageImg(MessageID id, Img *image);
377 377
 
378 378
     /**
379 379
      * Destroy Image message

+ 4
- 3
software/raspberry/superviseur-robot/main.cpp View File

@@ -38,15 +38,16 @@ int main(int argc, char **argv) {
38 38
 
39 39
     tasks.Init();
40 40
     
41
-    /*if (tasks.AcceptClient()) {
41
+    if (tasks.AcceptClient()) {
42
+        cout << "Rock'n'Roll baby, client accepted!"<<endl<<flush;
42 43
         tasks.Run();
43 44
         
44 45
         tasks.Join();
45 46
     }
46 47
     
47
-    tasks.Stop();*/
48
+    tasks.Stop();
48 49
     
49
-    tasks.Run();
50
+    //tasks.Run();
50 51
 
51 52
     return 0;
52 53
 }

+ 6
- 0
software/raspberry/superviseur-robot/nbproject/Makefile-Debug.mk View File

@@ -42,6 +42,7 @@ OBJECTFILES= \
42 42
 	${OBJECTDIR}/lib/server.o \
43 43
 	${OBJECTDIR}/main.o \
44 44
 	${OBJECTDIR}/tasks.o \
45
+	${OBJECTDIR}/_ext/a7f31ab4/base64.o \
45 46
 	${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
46 47
 	${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
47 48
 	${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@@ -108,6 +109,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
108 109
 	${RM} "$@.d"
109 110
 	$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
110 111
 
112
+${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
113
+	${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
114
+	${RM} "$@.d"
115
+	$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
116
+
111 117
 ${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
112 118
 	${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
113 119
 	${RM} "$@.d"

+ 6
- 0
software/raspberry/superviseur-robot/nbproject/Makefile-Debug__Pthread_.mk View File

@@ -37,6 +37,7 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
37 37
 OBJECTFILES= \
38 38
 	${OBJECTDIR}/lib/messages.o \
39 39
 	${OBJECTDIR}/main.o \
40
+	${OBJECTDIR}/_ext/a7f31ab4/base64.o \
40 41
 	${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
41 42
 	${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
42 43
 	${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@@ -78,6 +79,11 @@ ${OBJECTDIR}/main.o: main.cpp
78 79
 	${RM} "$@.d"
79 80
 	$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_PTHREAD__ -I./ -I./lib `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
80 81
 
82
+${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
83
+	${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
84
+	${RM} "$@.d"
85
+	$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_PTHREAD__ -I./ -I./lib `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
86
+
81 87
 ${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
82 88
 	${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
83 89
 	${RM} "$@.d"

+ 6
- 0
software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk View File

@@ -43,6 +43,7 @@ OBJECTFILES= \
43 43
 	${OBJECTDIR}/lib/server.o \
44 44
 	${OBJECTDIR}/main.o \
45 45
 	${OBJECTDIR}/tasks.o \
46
+	${OBJECTDIR}/_ext/a7f31ab4/base64.o \
46 47
 	${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
47 48
 	${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
48 49
 	${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@@ -114,6 +115,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
114 115
 	${RM} "$@.d"
115 116
 	$(COMPILE.cc) -g -D_WITH_TRACE_ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
116 117
 
118
+${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
119
+	${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
120
+	${RM} "$@.d"
121
+	$(COMPILE.cc) -g -D_WITH_TRACE_ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
122
+
117 123
 ${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
118 124
 	${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
119 125
 	${RM} "$@.d"

+ 6
- 0
software/raspberry/superviseur-robot/nbproject/Makefile-Release.mk View File

@@ -43,6 +43,7 @@ OBJECTFILES= \
43 43
 	${OBJECTDIR}/lib/server.o \
44 44
 	${OBJECTDIR}/main.o \
45 45
 	${OBJECTDIR}/tasks.o \
46
+	${OBJECTDIR}/_ext/a7f31ab4/base64.o \
46 47
 	${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
47 48
 	${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
48 49
 	${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@@ -114,6 +115,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
114 115
 	${RM} "$@.d"
115 116
 	$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
116 117
 
118
+${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
119
+	${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
120
+	${RM} "$@.d"
121
+	$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
122
+
117 123
 ${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
118 124
 	${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
119 125
 	${RM} "$@.d"

+ 42
- 0
software/raspberry/superviseur-robot/nbproject/configurations.xml View File

@@ -4,6 +4,7 @@
4 4
     <logicalFolder name="HeaderFiles"
5 5
                    displayName="Header Files"
6 6
                    projectFiles="true">
7
+      <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h</itemPath>
7 8
       <itemPath>./lib/camera.h</itemPath>
8 9
       <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</itemPath>
9 10
       <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</itemPath>
@@ -26,6 +27,7 @@
26 27
     <logicalFolder name="SourceFiles"
27 28
                    displayName="Source Files"
28 29
                    projectFiles="true">
30
+      <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp</itemPath>
29 31
       <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp</itemPath>
30 32
       <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</itemPath>
31 33
       <itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp</itemPath>
@@ -127,6 +129,16 @@
127 129
       </item>
128 130
       <item path="./tasks.h" ex="false" tool="3" flavor2="0">
129 131
       </item>
132
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
133
+            ex="false"
134
+            tool="1"
135
+            flavor2="0">
136
+      </item>
137
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
138
+            ex="false"
139
+            tool="3"
140
+            flavor2="0">
141
+      </item>
130 142
       <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
131 143
             ex="false"
132 144
             tool="1"
@@ -220,6 +232,16 @@
220 232
       </item>
221 233
       <item path="./tasks.h" ex="false" tool="3" flavor2="0">
222 234
       </item>
235
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
236
+            ex="false"
237
+            tool="1"
238
+            flavor2="0">
239
+      </item>
240
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
241
+            ex="false"
242
+            tool="3"
243
+            flavor2="0">
244
+      </item>
223 245
       <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
224 246
             ex="false"
225 247
             tool="1"
@@ -330,6 +352,16 @@
330 352
       </item>
331 353
       <item path="./tasks.h" ex="false" tool="3" flavor2="0">
332 354
       </item>
355
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
356
+            ex="false"
357
+            tool="1"
358
+            flavor2="0">
359
+      </item>
360
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
361
+            ex="false"
362
+            tool="3"
363
+            flavor2="0">
364
+      </item>
333 365
       <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
334 366
             ex="false"
335 367
             tool="1"
@@ -434,6 +466,16 @@
434 466
       </item>
435 467
       <item path="./tasks.cpp" ex="true" tool="1" flavor2="9">
436 468
       </item>
469
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
470
+            ex="false"
471
+            tool="1"
472
+            flavor2="0">
473
+      </item>
474
+      <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
475
+            ex="false"
476
+            tool="3"
477
+            flavor2="0">
478
+      </item>
437 479
       <item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
438 480
             ex="false"
439 481
             tool="1"

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

@@ -7,10 +7,9 @@
7 7
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
8 8
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
9 9
         <group>
10
-            <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
11
-            <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</file>
12 10
             <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/tasks_pthread.h</file>
13 11
             <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</file>
12
+            <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/img.h</file>
14 13
             <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/main.cpp</file>
15 14
             <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/messages.h</file>
16 15
             <file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>

+ 112
- 38
software/raspberry/superviseur-robot/tasks_pthread.cpp View File

@@ -52,7 +52,7 @@ void Tasks::Init() {
52 52
     
53 53
     /* Open com port with STM32 */
54 54
     cout << "Open serial com (";
55
-    status = robot.Open("/dev/ttyUSB1");
55
+    status = robot.Open("/dev/ttyUSB0");
56 56
     cout << status;
57 57
     cout << ")" << endl;
58 58
 
@@ -72,41 +72,40 @@ void Tasks::Init() {
72 72
 }
73 73
 
74 74
 void Tasks::Run() {
75
-    Message *msgRcv;
76
-    Message *msgSend;
77
-    int counter = 3;
78
-
79
-    //    threadServer=new thread((void (*)(void*)) &Tasks::ServerTask,this);
75
+    
76
+    threadTimer=new thread((void (*)(void*)) &Tasks::TimerTask,this);
77
+    threadServer=new thread((void (*)(void*)) &Tasks::ServerTask,this);
80 78
     //    threadSendToMon=new thread((void (*)(void*)) &Tasks::SendToMonTask,this);
81
-    //    threadTimer=new thread((void (*)(void*)) &Tasks::TimerTask,this);
82
-
83
-    msgSend = ComRobot::Ping();
84
-    cout << "Send => " << msgSend->ToString() << endl << flush;
85
-    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
86
-    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
87
-
88
-    delete(msgRcv);
89
-
90
-    msgSend = ComRobot::StartWithoutWD();
91
-    cout << "Send => " << msgSend->ToString() << endl << flush;
92
-    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
93
-    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
94
-
95
-    delete(msgRcv);
96
-
97
-    msgSend = ComRobot::Move(1000);
98
-    cout << "Send => " << msgSend->ToString() << endl << flush;
99
-    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
100
-    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
101
-
102
-    delete(msgRcv);
103
-
104
-    msgSend = ComRobot::GetBattery();
105
-    cout << "Send => " << msgSend->ToString() << endl << flush;
106
-    msgRcv = robot.SendCommand(msgSend, MESSAGE_ROBOT_BATTERY_LEVEL, 3);
107
-    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
79
+    
108 80
 
109
-    delete(msgRcv);
81
+//    msgSend = ComRobot::Ping();
82
+//    cout << "Send => " << msgSend->ToString() << endl << flush;
83
+//    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
84
+//    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
85
+//
86
+//    delete(msgRcv);
87
+//
88
+//    msgSend = ComRobot::StartWithoutWD();
89
+//    cout << "Send => " << msgSend->ToString() << endl << flush;
90
+//    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
91
+//    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
92
+//
93
+//    delete(msgRcv);
94
+//
95
+//    msgSend = ComRobot::Move(1000);
96
+//    cout << "Send => " << msgSend->ToString() << endl << flush;
97
+//    msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
98
+//    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
99
+//
100
+//    delete(msgRcv);
101
+//
102
+//    msgSend = ComRobot::GetBattery();
103
+//    cout << "Send => " << msgSend->ToString() << endl << flush;
104
+//    msgRcv = robot.SendCommand(msgSend, MESSAGE_ROBOT_BATTERY_LEVEL, 3);
105
+//    cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
106
+//
107
+//    delete(msgRcv);
108
+    cout<<"Tasks launched"<<endl<<flush; 
110 109
 }
111 110
 
112 111
 void Tasks::Stop() {
@@ -115,20 +114,69 @@ void Tasks::Stop() {
115 114
 }
116 115
 
117 116
 void Tasks::ServerTask(void *arg) {
118
-    int err;
117
+    Message *msgRcv;
118
+    Message *msgSend;
119
+    bool isActive=true;
120
+    
119 121
     cout << "Start " << __PRETTY_FUNCTION__ <<endl<<flush;
120 122
     
121
-    while (1) {
123
+    while (isActive) {
124
+        msgRcv=NULL;
125
+        msgSend=NULL;
126
+        
127
+        msgRcv = monitor.Read();
128
+        cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
129
+
130
+        if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) msgSend = new Message(MESSAGE_ANSWER_ACK);
131
+        if (msgRcv->CompareID(MESSAGE_ROBOT_COM_CLOSE)) msgSend = new Message(MESSAGE_ANSWER_ACK);
132
+
133
+        if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITH_WD)) msgSend = new Message(MESSAGE_ANSWER_ACK);
134
+        if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) msgSend = new Message(MESSAGE_ANSWER_ACK);
135
+        
136
+        if (msgRcv->CompareID(MESSAGE_ROBOT_COM_CLOSE)) isActive = false;
137
+
138
+        if (msgRcv->CompareID(MESSAGE_CAM_OPEN)) {
139
+            sendImage=true;
140
+            msgSend = new Message(MESSAGE_ANSWER_ACK);
141
+        }
142
+        
143
+        if (msgRcv->CompareID(MESSAGE_CAM_CLOSE)) {
144
+            sendImage=false;
145
+            msgSend = new Message(MESSAGE_ANSWER_ACK);
146
+        }
147
+        
148
+        if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_START)) {
149
+            sendPosition=true;
150
+            msgSend = new Message(MESSAGE_ANSWER_ACK);
151
+        }
122 152
         
153
+        if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_STOP)) {
154
+            sendPosition=false;
155
+            msgSend = new Message(MESSAGE_ANSWER_ACK);
156
+        }
157
+        
158
+        if (msgRcv->CompareID(MESSAGE_ROBOT_BATTERY_GET)) msgSend = new MessageBattery(MESSAGE_ROBOT_BATTERY_LEVEL,BATTERY_FULL);
159
+        
160
+        if (msgSend != NULL) monitor.Write(msgSend);
161
+        delete(msgRcv);
123 162
     }
124 163
 }
125 164
 
126 165
 void Tasks::TimerTask(void* arg) {
127 166
     struct timespec tim, tim2;
167
+    Message *msgSend;
168
+    int counter;
169
+    
128 170
     tim.tv_sec = 0;
129
-    tim.tv_nsec = 100000000;
171
+    tim.tv_nsec = 50000000; // 50ms (20fps)
130 172
     
131 173
     cout << "Start " << __PRETTY_FUNCTION__ <<endl<<flush;
174
+    
175
+    Camera camera=Camera(sm);
176
+    cout << "Try opening camera"<<endl<<flush;
177
+    if (camera.Open()) cout<<"Camera opened successfully"<<endl<<flush;
178
+    else cout<<"Failed to open camera"<<endl<<flush;
179
+    
132 180
     while (1) {
133 181
         //std::this_thread::sleep_for(std::chrono::seconds )
134 182
         //sleep(1);
@@ -137,7 +185,33 @@ void Tasks::TimerTask(void* arg) {
137 185
             return;
138 186
         }
139 187
         
140
-        mutexTimer.unlock();
188
+        //mutexTimer.unlock();
189
+        if (sendImage==true) {
190
+            counter++;
191
+            
192
+            if (counter>=1) {
193
+                counter=0;
194
+                Img image=camera.Grab();
195
+                
196
+                cout << image.ToString()<<endl<<flush;
197
+                MessageImg *msg=new MessageImg(MESSAGE_CAM_IMAGE, &image);
198
+                
199
+                monitor.Write(msg);
200
+                cout << "Image sent"<<endl<<flush;
201
+            }
202
+        }
203
+        
204
+        if (sendPosition==true) {
205
+            Position pos;
206
+            pos.angle=0.0;
207
+            pos.robotId=1;
208
+            pos.center=cv::Point2f(0.5,0.5);
209
+            pos.direction=cv::Point2f(1.0,2.5);
210
+            
211
+            MessagePosition *msgp=new MessagePosition(MESSAGE_CAM_POSITION, pos);
212
+            monitor.Write(msgp);
213
+            cout << "Position sent"<<endl<<flush;
214
+        }
141 215
     }
142 216
 }
143 217
 

+ 3
- 0
software/raspberry/superviseur-robot/tasks_pthread.h View File

@@ -90,6 +90,9 @@ private:
90 90
     ComMonitor monitor;
91 91
     ComRobot robot;
92 92
     
93
+    bool sendImage=false;
94
+    bool sendPosition=false;
95
+    
93 96
     thread *threadServer;
94 97
     thread *threadSendToMon;
95 98
     thread *threadTimer;

Loading…
Cancel
Save