Browse Source

rajouts des commentaires (Demande #35)

Creation d'une classe imageWidget dans le moniteur (demande #43)
modifications du comportement des fleches dans le moniteur (demande #41)
Suppression de relicats anciens
Sébastien DI MERCURIO 5 years ago
parent
commit
a18aaca4d7
68 changed files with 964 additions and 4069 deletions
  1. 2
    0
      aruco_markers/.gitignore
  2. 23
    0
      aruco_markers/generate_markers.sh
  3. BIN
      aruco_markers/markers_board.odt
  4. BIN
      aruco_markers/markers_board.pdf
  5. 0
    19
      software/monitor/monitor/Client.cs
  6. 74
    49
      software/monitor/monitor/DestijlCommandManager.cs
  7. 304
    0
      software/monitor/monitor/ImageWidget.cs
  8. 42
    169
      software/monitor/monitor/MonitorUI.cs
  9. 95
    71
      software/monitor/monitor/gtk-gui/MainWindow.cs
  10. 31
    4
      software/monitor/monitor/gtk-gui/gui.stetic
  11. BIN
      software/monitor/monitor/monitor
  12. 2
    0
      software/monitor/monitor/monitor.csproj
  13. BIN
      software/monitor/monitor/ressources/hand-filled-32.png
  14. 3
    0
      software/raspberry/superviseur-robot/.gitignore
  15. 0
    23
      software/raspberry/superviseur-robot/CMakeLists.txt
  16. 0
    142
      software/raspberry/superviseur-robot/ProjDestijl.cbp
  17. 0
    32
      software/raspberry/superviseur-robot/compile_commands.json
  18. BIN
      software/raspberry/superviseur-robot/dist/Debug__Pthread_/GNU-Linux/superviseur-robot
  19. 0
    5
      software/raspberry/superviseur-robot/lib/CMakeLists.txt
  20. 53
    23
      software/raspberry/superviseur-robot/lib/camera.cpp
  21. 57
    0
      software/raspberry/superviseur-robot/lib/camera.h
  22. 2
    0
      software/raspberry/superviseur-robot/lib/commonitor.cpp
  23. 0
    70
      software/raspberry/superviseur-robot/lib/definitions.h
  24. 0
    260
      software/raspberry/superviseur-robot/lib/image.cpp
  25. 0
    140
      software/raspberry/superviseur-robot/lib/image.h
  26. 100
    23
      software/raspberry/superviseur-robot/lib/img.cpp
  27. 124
    7
      software/raspberry/superviseur-robot/lib/img.h
  28. 0
    49
      software/raspberry/superviseur-robot/lib/message.cpp
  29. 0
    61
      software/raspberry/superviseur-robot/lib/message.h
  30. 19
    19
      software/raspberry/superviseur-robot/lib/messages.h
  31. 0
    103
      software/raspberry/superviseur-robot/lib/monitor.cpp
  32. 0
    108
      software/raspberry/superviseur-robot/lib/monitor.h
  33. 0
    251
      software/raspberry/superviseur-robot/lib/robot.cpp
  34. 0
    79
      software/raspberry/superviseur-robot/lib/robot.h
  35. 0
    136
      software/raspberry/superviseur-robot/lib/server.cpp
  36. 0
    105
      software/raspberry/superviseur-robot/lib/server.h
  37. 0
    24
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug.mk
  38. 8
    8
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug__Pthread_.mk
  39. 8
    8
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug__Pthread__RPI.mk
  40. 0
    30
      software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk
  41. 0
    30
      software/raspberry/superviseur-robot/nbproject/Makefile-Release.mk
  42. 0
    119
      software/raspberry/superviseur-robot/nbproject/configurations.xml
  43. 8
    4
      software/raspberry/superviseur-robot/nbproject/private/private.xml
  44. 3
    3
      software/raspberry/superviseur-robot/nbproject/private/timestamps-10.105.1.13-pi-22
  45. 3
    3
      software/raspberry/superviseur-robot/superviseur.doxygen
  46. 3
    4
      software/raspberry/superviseur-robot/tasks_pthread.cpp
  47. 0
    5
      software/raspberry/testeur/testeur/.dep.inc
  48. 0
    8
      software/raspberry/testeur/testeur/.gitignore
  49. 0
    128
      software/raspberry/testeur/testeur/Makefile
  50. 0
    307
      software/raspberry/testeur/testeur/main.cpp
  51. 0
    107
      software/raspberry/testeur/testeur/nbproject/Makefile-Debug-rpi.mk
  52. 0
    107
      software/raspberry/testeur/testeur/nbproject/Makefile-Debug.mk
  53. 0
    107
      software/raspberry/testeur/testeur/nbproject/Makefile-Release.mk
  54. 0
    133
      software/raspberry/testeur/testeur/nbproject/Makefile-impl.mk
  55. 0
    43
      software/raspberry/testeur/testeur/nbproject/Makefile-variables.mk
  56. 0
    76
      software/raspberry/testeur/testeur/nbproject/Package-Debug-rpi.bash
  57. 0
    76
      software/raspberry/testeur/testeur/nbproject/Package-Debug.bash
  58. 0
    76
      software/raspberry/testeur/testeur/nbproject/Package-Release.bash
  59. 0
    275
      software/raspberry/testeur/testeur/nbproject/configurations.xml
  60. 0
    8
      software/raspberry/testeur/testeur/nbproject/private/Makefile-variables.mk
  61. 0
    75
      software/raspberry/testeur/testeur/nbproject/private/c_standard_headers_indexer.c
  62. 0
    107
      software/raspberry/testeur/testeur/nbproject/private/configurations.xml
  63. 0
    135
      software/raspberry/testeur/testeur/nbproject/private/cpp_standard_headers_indexer.cpp
  64. 0
    0
      software/raspberry/testeur/testeur/nbproject/private/downloads-10.105.1.13-pi-22
  65. 0
    42
      software/raspberry/testeur/testeur/nbproject/private/launcher.properties
  66. 0
    13
      software/raspberry/testeur/testeur/nbproject/private/private.xml
  67. 0
    26
      software/raspberry/testeur/testeur/nbproject/private/timestamps-10.105.1.13-pi-22
  68. 0
    34
      software/raspberry/testeur/testeur/nbproject/project.xml

+ 2
- 0
aruco_markers/.gitignore View File

@@ -0,0 +1,2 @@
1
+*.png
2
+*.jpg

+ 23
- 0
aruco_markers/generate_markers.sh View File

@@ -0,0 +1,23 @@
1
+#!/bin/sh
2
+
3
+echo "Generating 20 markers"
4
+example_aruco_create_marker -d=3 --id=1 --ms=100 marker_4X4_1000_1.png
5
+example_aruco_create_marker -d=3 --id=2 --ms=100 marker_4X4_1000_2.png
6
+example_aruco_create_marker -d=3 --id=3 --ms=100 marker_4X4_1000_3.png
7
+example_aruco_create_marker -d=3 --id=4 --ms=100 marker_4X4_1000_4.png
8
+example_aruco_create_marker -d=3 --id=5 --ms=100 marker_4X4_1000_5.png
9
+example_aruco_create_marker -d=3 --id=6 --ms=100 marker_4X4_1000_6.png
10
+example_aruco_create_marker -d=3 --id=7 --ms=100 marker_4X4_1000_7.png
11
+example_aruco_create_marker -d=3 --id=8 --ms=100 marker_4X4_1000_8.png
12
+example_aruco_create_marker -d=3 --id=9 --ms=100 marker_4X4_1000_9.png
13
+example_aruco_create_marker -d=3 --id=10 --ms=100 marker_4X4_1000_10.png
14
+example_aruco_create_marker -d=3 --id=11 --ms=100 marker_4X4_1000_11.png
15
+example_aruco_create_marker -d=3 --id=12 --ms=100 marker_4X4_1000_12.png
16
+example_aruco_create_marker -d=3 --id=13 --ms=100 marker_4X4_1000_13.png
17
+example_aruco_create_marker -d=3 --id=14 --ms=100 marker_4X4_1000_14.png
18
+example_aruco_create_marker -d=3 --id=15 --ms=100 marker_4X4_1000_15.png
19
+example_aruco_create_marker -d=3 --id=16 --ms=100 marker_4X4_1000_16.png
20
+example_aruco_create_marker -d=3 --id=17 --ms=100 marker_4X4_1000_17.png
21
+example_aruco_create_marker -d=3 --id=18 --ms=100 marker_4X4_1000_18.png
22
+example_aruco_create_marker -d=3 --id=19 --ms=100 marker_4X4_1000_19.png
23
+example_aruco_create_marker -d=3 --id=20 --ms=100 marker_4X4_1000_20.png

BIN
aruco_markers/markers_board.odt View File


BIN
aruco_markers/markers_board.pdf View File


+ 0
- 19
software/monitor/monitor/Client.cs View File

@@ -63,19 +63,9 @@ namespace monitor
63 63
         private static byte[] buffer = new byte[BufferMaxSize];
64 64
 
65 65
         /// <summary>
66
-        /// buffer containing received message from TCP server
67
-        /// Used to concatenate internal buffers into one
68
-        /// </summary>
69
-        //private static byte[] receiveBuffer;
70
-
71
-        //private static int initialReceiveBufferIndex = 0;
72
-
73
-        /// <summary>
74 66
         /// String containing received message from tcp server
75 67
         /// </summary>
76 68
         private static StringBuilder message = new StringBuilder();
77
-        //private static int newLength = 1;
78
-        //private static int packetCounter = 0;
79 69
 
80 70
         /// <summary>
81 71
         /// Callback to send received message to upper level
@@ -117,11 +107,6 @@ namespace monitor
117 107
                 // received data are stored in buffer
118 108
                 // Next reading will be done in ReadCallback method
119 109
                 stream.BeginRead(buffer, 0, 1, new AsyncCallback(ReadCallback), message);
120
-
121
-                // Start reading thread
122
-                //message.Clear();
123
-                //readThread = new Thread(new ThreadStart(ReadCallback));
124
-                //readThread.Start();
125 110
             }
126 111
             catch (ArgumentNullException e)
127 112
             {
@@ -207,7 +192,6 @@ namespace monitor
207 192
                 {
208 193
                     string s = message.ToString();
209 194
 
210
-                    //Console.WriteLine("Message received (" + s.Length + ")");
211 195
                     // no more data to read, buffer and string can be send to upper level
212 196
                     readEvent?.Invoke(s);
213 197
 
@@ -215,9 +199,6 @@ namespace monitor
215 199
 
216 200
                     if (index != bytesRead - 1)
217 201
                     {
218
-                        //Console.WriteLine("Index not at end (" + index + "/" + bytesRead + ")");
219
-                        //Console.WriteLine("1=" + (char)buffer[index + 1] + " 2=" + (char)buffer[index + 2]);
220
-
221 202
                         byte[] trailing=new byte[BufferMaxSize];
222 203
 
223 204
                         Array.Copy(buffer, index + 1, trailing, 0, bytesRead - index - 1);

+ 74
- 49
software/monitor/monitor/DestijlCommandManager.cs View File

@@ -19,6 +19,9 @@
19 19
 //  You should have received a copy of the GNU General Public License
20 20
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 21
 
22
+// 15/01/2019 dimercur
23
+// Demande #41: Modifier les messages envoyés par les flèches de direction
24
+
22 25
 using System;
23 26
 using System.Globalization;
24 27
 
@@ -65,50 +68,9 @@ namespace monitor
65 68
         public const string ROBOT_CURRENT_STATE = "RCST";
66 69
 
67 70
         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";
92 71
     }
93 72
 
94 73
     /// <summary>
95
-    /// Commands used for robot messages
96
-    /// </summary>
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
-    //}
110
-
111
-    /// <summary>
112 74
     /// Specialization class for command manager, which implemnent destijl protocol between monitor and server
113 75
     /// </summary>
114 76
     public class DestijlCommandManager
@@ -409,17 +371,84 @@ namespace monitor
409 371
         }
410 372
 
411 373
         /// <summary>
412
-        /// Move robot forward or backward, for a distance expressed in millimeter
374
+        /// Move robot forward for an unlimited distance
375
+        /// </summary>
376
+        /// <returns>Command status (see DecodeStatus)</returns>
377
+        public CommandStatus RobotGoForward()
378
+        {
379
+            CommandManager.CommandManagerStatus localStatus;
380
+            string answer;
381
+
382
+            localStatus = commandManager.SendCommand(
383
+                CreateCommand(DestijlCommandList.ROBOT_GO_FORWARD),
384
+                out answer,
385
+                0);
386
+
387
+            return DecodeStatus(localStatus, answer);
388
+        }
389
+
390
+        /// <summary>
391
+        /// Move robot backward for an unlimited distance
392
+        /// </summary>
393
+        /// <returns>Command status (see DecodeStatus)</returns>
394
+        public CommandStatus RobotGoBackward()
395
+        {
396
+            CommandManager.CommandManagerStatus localStatus;
397
+            string answer;
398
+
399
+            localStatus = commandManager.SendCommand(
400
+                CreateCommand(DestijlCommandList.ROBOT_GO_BACKWARD),
401
+                out answer,
402
+                0);
403
+
404
+            return DecodeStatus(localStatus, answer);
405
+        }
406
+
407
+        /// <summary>
408
+        /// Turn robot to the left for an unlimited number of turn
409
+        /// </summary>
410
+        /// <returns>Command status (see DecodeStatus)</returns>
411
+        public CommandStatus RobotGoLeft()
412
+        {
413
+            CommandManager.CommandManagerStatus localStatus;
414
+            string answer;
415
+
416
+            localStatus = commandManager.SendCommand(
417
+                CreateCommand(DestijlCommandList.ROBOT_GO_LEFT),
418
+                out answer,
419
+                0);
420
+
421
+            return DecodeStatus(localStatus, answer);
422
+        }
423
+
424
+        /// <summary>
425
+        /// Turn robot to the right for an unlimited number of turn
413 426
         /// </summary>
414 427
         /// <returns>Command status (see DecodeStatus)</returns>
415
-        /// <param name="distance">Distance of mouvment, in millimeter</param>
416
-        public CommandStatus RobotMove(int distance)
428
+        public CommandStatus RobotGoRight()
417 429
         {
418 430
             CommandManager.CommandManagerStatus localStatus;
419 431
             string answer;
420 432
 
421 433
             localStatus = commandManager.SendCommand(
422
-                CreateCommand(DestijlCommandList.ROBOT_MOVE, Convert.ToString(distance)),
434
+                CreateCommand(DestijlCommandList.ROBOT_GO_RIGHT),
435
+                out answer,
436
+                0);
437
+
438
+            return DecodeStatus(localStatus, answer);
439
+        }
440
+
441
+        /// <summary>
442
+        /// Stop robot mouvement
443
+        /// </summary>
444
+        /// <returns>Command status (see DecodeStatus)</returns>
445
+        public CommandStatus RobotStop()
446
+        {
447
+            CommandManager.CommandManagerStatus localStatus;
448
+            string answer;
449
+
450
+            localStatus = commandManager.SendCommand(
451
+                CreateCommand(DestijlCommandList.ROBOT_STOP),
423 452
                 out answer,
424 453
                 0);
425 454
 
@@ -609,10 +638,6 @@ namespace monitor
609 638
 
610 639
             string[] parts = data.Split(';');
611 640
 
612
-            //for (int i = 0; i < parts.Length; i++) {
613
-            //    Console.WriteLine(parts[i]);
614
-            //}
615
-
616 641
             NumberFormatInfo provider = new NumberFormatInfo();
617 642
             provider.NumberDecimalSeparator = ".";
618 643
             provider.NumberGroupSeparator = ",";

+ 304
- 0
software/monitor/monitor/ImageWidget.cs View File

@@ -0,0 +1,304 @@
1
+//
2
+//  ImageWidget.cs
3
+//
4
+//  Author:
5
+//       Di MERCURIO Sébastien <dimercur@insa-toulouse.fr>
6
+//
7
+//  Copyright (c) 2019 INSA - DGEI
8
+//
9
+//  This program is free software: you can redistribute it and/or modify
10
+//  it under the terms of the GNU General Public License as published by
11
+//  the Free Software Foundation, either version 3 of the License, or
12
+//  (at your option) any later version.
13
+//
14
+//  This program is distributed in the hope that it will be useful,
15
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+//  GNU General Public License for more details.
18
+//
19
+//  You should have received a copy of the GNU General Public License
20
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+
22
+// 15/10/2019 dimercur
23
+// Demande #43: Migrer le code lié à la gestion des images dans sa propre classe widget
24
+
25
+using System;
26
+using Gtk;
27
+using Cairo;
28
+using Gdk;
29
+
30
+using System.Timers;
31
+
32
+namespace monitor
33
+{
34
+    /// <summary>
35
+    /// Class used for video display
36
+    /// </summary>
37
+    public class ImageWidget
38
+    {
39
+        /// <summary>
40
+        /// Reference to GTK base widget
41
+        /// </summary>
42
+        private DrawingArea drawingArea;
43
+
44
+        /// <summary>
45
+        /// Pixbuffer used for displaying image
46
+        /// </summary>
47
+        private Pixbuf drawingareaCameraPixbuf;
48
+
49
+        /// <summary>
50
+        /// Indicate if position must be displayed or not
51
+        /// </summary>
52
+        public bool showPosition;
53
+
54
+        /// <summary>
55
+        /// Indicate if FPS must be displayed or not
56
+        /// </summary>
57
+        private bool showFPS;
58
+        public bool ShowFPS
59
+        {
60
+            get
61
+            {
62
+                return showFPS;
63
+            }
64
+
65
+            set
66
+            {
67
+                showFPS = value;
68
+
69
+                if (value == true)
70
+                {
71
+                    imageFPS = 0;
72
+                    imageFPScounter = 0;
73
+
74
+                    fpsTimer.Start();
75
+                }
76
+                else
77
+                {
78
+                    fpsTimer.Stop();
79
+
80
+                    Refresh();
81
+                }
82
+            }
83
+        }
84
+
85
+        /// <summary>
86
+        /// Counter used for FPS computation
87
+        /// </summary>
88
+        private int imageFPS = 0;
89
+        private int imageFPScounter = 0;
90
+
91
+        /// <summary>
92
+        /// Timer for FPS request
93
+        /// </summary>
94
+        private System.Timers.Timer fpsTimer;
95
+
96
+        /// <summary>
97
+        /// Hold position to be displayed
98
+        /// </summary>
99
+        private DestijlCommandManager.Position position;
100
+        public DestijlCommandManager.Position Position
101
+        {
102
+            get
103
+            {
104
+                return position;
105
+            }
106
+
107
+            set 
108
+            {
109
+                position = value; 
110
+                Refresh();
111
+            }
112
+        }
113
+
114
+        /// <summary>
115
+        /// Request a refresh of drawing area
116
+        /// </summary>
117
+        private void Refresh() 
118
+        {
119
+            Gtk.Application.Invoke(delegate
120
+            {
121
+                drawingArea.QueueDraw();
122
+            });
123
+        }
124
+
125
+        /// <summary>
126
+        /// Initializes a new instance of ImageWidget class.
127
+        /// </summary>
128
+        /// <param name="area">Reference to GTK drawing area widget</param>
129
+        public ImageWidget(DrawingArea area)
130
+        {
131
+            this.drawingArea = area;
132
+            // create new timer for FPS , every 1s
133
+            fpsTimer = new System.Timers.Timer(1000.0);
134
+            fpsTimer.Elapsed += OnFpsTimerElapsed;
135
+
136
+            showPosition = false;
137
+            showFPS = false;
138
+
139
+            drawingArea.ExposeEvent += OnDrawingAreaCameraExposeEvent;
140
+        }
141
+
142
+        /// <summary>
143
+        /// Show an image from a ressource
144
+        /// </summary>
145
+        /// <param name="ressource">Ressource path</param>
146
+        public void ShowImage(string ressource) 
147
+        {
148
+            drawingareaCameraPixbuf = Pixbuf.LoadFromResource("monitor.ressources.missing_picture.png");
149
+            imageFPScounter++;
150
+
151
+            Refresh();
152
+        }
153
+
154
+        /// <summary>
155
+        /// Show an image from a byte array
156
+        /// </summary>
157
+        /// <param name="image">Byte array containing a valid image</param>
158
+        public void ShowImage(byte[] image)
159
+        {
160
+            drawingareaCameraPixbuf = new Pixbuf(image);
161
+            imageFPScounter++;
162
+
163
+            Refresh();
164
+        }
165
+
166
+        /// <summary>
167
+        /// Callback called when drawingarea need refresh
168
+        /// </summary>
169
+        /// <param name="o">Sender object</param>
170
+        /// <param name="args">Expose arguments</param>
171
+        protected void OnDrawingAreaCameraExposeEvent(object o, ExposeEventArgs args)
172
+        {
173
+            //Console.WriteLine("Event expose. Args = " + args.ToString());
174
+
175
+            DrawingArea area = (DrawingArea)o;
176
+            Gdk.Pixbuf displayPixbuf;
177
+            int areaWidth, areaHeight;
178
+
179
+            // Get graphic context for background
180
+            Gdk.GC gc = area.Style.BackgroundGC(Gtk.StateType.Normal);
181
+
182
+            // get size of drawingarea widget
183
+            area.GdkWindow.GetSize(out areaWidth, out areaHeight);
184
+            int width = drawingareaCameraPixbuf.Width;
185
+            int height = drawingareaCameraPixbuf.Height;
186
+            float ratio = (float)width / (float)height;
187
+
188
+            // if widget is smaller than image, reduce it
189
+            if (areaWidth <= width)
190
+            {
191
+                width = areaWidth;
192
+                height = (int)(width / ratio);
193
+            }
194
+
195
+            // if image is smaller than widget, enlarge it
196
+            if (width > areaWidth)
197
+            {
198
+                width = areaWidth;
199
+            }
200
+
201
+            if (height > areaHeight)
202
+            {
203
+                height = areaHeight;
204
+            }
205
+
206
+            //scale original picture and copy result in local pixbuf
207
+            displayPixbuf = drawingareaCameraPixbuf.ScaleSimple(width, height, InterpType.Bilinear);
208
+
209
+            // draw local pixbuff centered on drawingarea
210
+            area.GdkWindow.DrawPixbuf(gc, displayPixbuf,
211
+                                      0, 0,
212
+                                      (areaWidth - displayPixbuf.Width) / 2,
213
+                                      (areaHeight - displayPixbuf.Height) / 2,
214
+                                      displayPixbuf.Width, displayPixbuf.Height,
215
+                                      RgbDither.Normal, 0, 0);
216
+
217
+            if (showPosition)
218
+            {
219
+                Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
220
+                Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
221
+
222
+                cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
223
+                cr.SetSourceColor(textFontColor);
224
+                cr.SetFontSize(16);
225
+
226
+                if (position != null)
227
+                {
228
+                    double space = 0.0;
229
+
230
+                    string text = "Direction (" + position.direction.x.ToString("0.##") + " ; " + position.direction.y.ToString("0.##") + ")";
231
+                    TextExtents te = cr.TextExtents(text);
232
+                    cr.MoveTo(areaWidth - te.Width - 5,
233
+                              areaHeight - te.Height - 5);
234
+                    space = te.Height;
235
+                    cr.ShowText(text);
236
+
237
+                    text = "Centre (" + position.centre.x.ToString("0.##") + " ; " + position.centre.y.ToString("0.##") + ")";
238
+                    te = cr.TextExtents(text);
239
+                    cr.MoveTo(areaWidth - te.Width - 5,
240
+                              areaHeight - te.Height - 5 - space - 5);
241
+                    space = space + te.Height + 5;
242
+                    cr.ShowText(text);
243
+
244
+                    text = "Angle: " + position.angle.ToString("0.##");
245
+                    te = cr.TextExtents(text);
246
+                    cr.MoveTo(areaWidth - te.Width - 5,
247
+                              areaHeight - te.Height - 5 - space - 5);
248
+                    space = space + te.Height + 5;
249
+                    cr.ShowText(text);
250
+
251
+                    text = "ID: " + position.robotID;
252
+                    te = cr.TextExtents(text);
253
+                    cr.MoveTo(areaWidth - te.Width - 5,
254
+                              areaHeight - te.Height - 5 - space - 5);
255
+
256
+                    cr.ShowText(text);
257
+                }
258
+                else
259
+                {
260
+                    string text = "Position (NULL)";
261
+                    TextExtents te = cr.TextExtents(text);
262
+                    cr.MoveTo(areaWidth - te.Width - 5,
263
+                              areaHeight - te.Height - 5);
264
+                    
265
+                    cr.ShowText(text);
266
+                }
267
+
268
+                ((IDisposable)cr.GetTarget()).Dispose();
269
+                ((IDisposable)cr).Dispose();
270
+            }
271
+
272
+            if (showFPS)
273
+            {
274
+                Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
275
+                Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
276
+
277
+                cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
278
+                cr.SetSourceColor(textFontColor);
279
+                cr.SetFontSize(16);
280
+
281
+                string text = "FPS= " + imageFPS.ToString();
282
+                TextExtents te = cr.TextExtents(text);
283
+                cr.MoveTo(10, 10 + te.Height);
284
+                cr.ShowText(text);
285
+
286
+                ((IDisposable)cr.GetTarget()).Dispose();
287
+                ((IDisposable)cr).Dispose();
288
+            }
289
+        }
290
+    
291
+        /// <summary>
292
+        /// Timer used for FPS computation
293
+        /// </summary>
294
+        /// <param name="sender">Sender object</param>
295
+        /// <param name="e">unused parameter</param>
296
+        private void OnFpsTimerElapsed(object sender, ElapsedEventArgs e)
297
+        {
298
+            imageFPS = imageFPScounter;
299
+            imageFPScounter = 0;
300
+
301
+            Refresh();
302
+        }
303
+    }
304
+}

+ 42
- 169
software/monitor/monitor/MonitorUI.cs View File

@@ -19,6 +19,11 @@
19 19
 //  You should have received a copy of the GNU General Public License
20 20
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 21
 
22
+// 15/01/2019 dimercur
23
+// Demande #41: Modifier les messages envoyés par les flèches de direction
24
+
25
+// 15/10/2019 dimercur
26
+// Demande #43: Migrer le code lié à la gestion des images dans sa propre classe widget
22 27
 
23 28
 using System;
24 29
 using Gtk;
@@ -39,11 +44,6 @@ public partial class MainWindow : Gtk.Window
39 44
     private DestijlCommandManager cmdManager;
40 45
 
41 46
     /// <summary>
42
-    /// Pixbuffer used for displaying image
43
-    /// </summary>
44
-    private Pixbuf drawingareaCameraPixbuf;
45
-
46
-    /// <summary>
47 47
     /// Position used for displaying position
48 48
     /// </summary>
49 49
     private DestijlCommandManager.Position position=new DestijlCommandManager.Position();
@@ -64,19 +64,20 @@ public partial class MainWindow : Gtk.Window
64 64
     private SystemState systemState = SystemState.NotConnected;
65 65
 
66 66
     /// <summary>
67
+    /// Object used for displaying image on a valid DrawingArea widget
68
+    /// </summary>
69
+    private ImageWidget imageWidget;
70
+
71
+    /// <summary>
67 72
     /// Timer for battery request
68 73
     /// </summary>
69 74
     private System.Timers.Timer batteryTimer;
70 75
 
71
-    private int imageReceivedCounter = 0;
72
-    private int badImageReceivedCounter = 0;
73
-    private int imageFPS = 0;
74
-    private int imageFPScounter = 0;
75
-
76 76
     /// <summary>
77
-    /// Timer for FPS request
77
+    /// Counter for image reception and detecting bad picture ratio
78 78
     /// </summary>
79
-    private System.Timers.Timer fpsTimer;
79
+    private int imageReceivedCounter = 0;
80
+    private int badImageReceivedCounter = 0;
80 81
 
81 82
     /// <summary>
82 83
     /// Initializes a new instance of the <see cref="MainWindow"/> class.
@@ -87,14 +88,13 @@ public partial class MainWindow : Gtk.Window
87 88
 
88 89
         cmdManager = new DestijlCommandManager(OnCommandReceivedEvent);
89 90
 
91
+        // Init of image widget
92
+        imageWidget = new ImageWidget(drawingAreaCamera);
93
+
90 94
         // create new timer for battery request, every 10s
91 95
         batteryTimer = new System.Timers.Timer(10000.0);
92 96
         batteryTimer.Elapsed += OnBatteryTimerElapsed;
93 97
 
94
-        // create new timer for FPS , every 1s
95
-        fpsTimer = new System.Timers.Timer(1000.0);
96
-        fpsTimer.Elapsed += OnFpsTimerElapsed;
97
-
98 98
         // Customize controls
99 99
         AdjustControls();
100 100
     }
@@ -108,7 +108,7 @@ public partial class MainWindow : Gtk.Window
108 108
         ChangeState(SystemState.NotConnected);
109 109
 
110 110
         // Load "no picture" image from disque
111
-        drawingareaCameraPixbuf = Pixbuf.LoadFromResource("monitor.ressources.missing_picture.png");
111
+        imageWidget.ShowImage("monitor.ressources.missing_picture.png");
112 112
 
113 113
         // setup server controls
114 114
         entryServerName.Text = Client.defaultIP;
@@ -140,6 +140,9 @@ public partial class MainWindow : Gtk.Window
140 140
                 checkButtonRobotPosition.Active = false;
141 141
                 checkButtonFPS.Active = false;
142 142
 
143
+                imageWidget.ShowFPS = false;
144
+                imageWidget.showPosition = false;
145
+
143 146
                 if (cmdManager != null) cmdManager.Close();
144 147
 
145 148
                 batteryTimer.Stop();
@@ -181,6 +184,9 @@ public partial class MainWindow : Gtk.Window
181 184
                 checkButtonRobotPosition.Active = false;
182 185
                 checkButtonFPS.Active = false;
183 186
 
187
+                imageWidget.ShowFPS = false;
188
+                imageWidget.showPosition = false;
189
+
184 190
                 systemState = SystemState.NotConnected;
185 191
 
186 192
                 return;
@@ -295,13 +301,7 @@ public partial class MainWindow : Gtk.Window
295 301
 
296 302
                 try
297 303
                 {
298
-                    drawingareaCameraPixbuf = new Pixbuf(image);
299
-                    imageFPScounter++;
300
-
301
-                    Gtk.Application.Invoke(delegate
302
-                    {
303
-                        drawingAreaCamera.QueueDraw();
304
-                    });
304
+                    imageWidget.ShowImage(image);
305 305
                 }
306 306
                 catch (GLib.GException)
307 307
                 {
@@ -316,12 +316,7 @@ public partial class MainWindow : Gtk.Window
316 316
             }
317 317
             else if (header == DestijlCommandList.CAMERA_POSITION)
318 318
             {
319
-                position = DestijlCommandManager.DecodePosition(data);
320
-
321
-                Gtk.Application.Invoke(delegate
322
-                {
323
-                    drawingAreaCamera.QueueDraw();
324
-                });
319
+                imageWidget.Position = DestijlCommandManager.DecodePosition(data);
325 320
             }
326 321
         }
327 322
     }
@@ -336,6 +331,7 @@ public partial class MainWindow : Gtk.Window
336 331
         Console.WriteLine("Bye bye 2");
337 332
         if (cmdManager != null) cmdManager.Close();
338 333
         this.Destroy();
334
+
339 335
         Application.Quit();
340 336
     }
341 337
 
@@ -506,19 +502,23 @@ public partial class MainWindow : Gtk.Window
506 502
         // depending on button clicked, launch appropriate action
507 503
         if (sender == buttonRight)
508 504
         {
509
-            cmdManager.RobotTurn(90);
505
+            cmdManager.RobotGoRight();
510 506
         }
511 507
         else if (sender == buttonLeft)
512 508
         {
513
-            cmdManager.RobotTurn(-90);
509
+            cmdManager.RobotGoLeft();
514 510
         }
515 511
         else if (sender == buttonForward)
516 512
         {
517
-            cmdManager.RobotMove(100);
513
+            cmdManager.RobotGoForward();
518 514
         }
519 515
         else if (sender == buttonDown)
520 516
         {
521
-            cmdManager.RobotMove(-100);
517
+            cmdManager.RobotGoBackward();
518
+        }
519
+        else if (sender == buttonStop)
520
+        {
521
+            cmdManager.RobotStop();
522 522
         }
523 523
         else
524 524
         {
@@ -622,116 +622,8 @@ public partial class MainWindow : Gtk.Window
622 622
                 //checkButtonRobotPosition.Active = false;
623 623
             }
624 624
         }
625
-    }
626
-
627
-    /// <summary>
628
-    /// Callback called when drawingarea need refresh
629
-    /// </summary>
630
-    /// <param name="o">Sender object</param>
631
-    /// <param name="args">Expose arguments</param>
632
-    protected void OnDrawingAreaCameraExposeEvent(object o, ExposeEventArgs args)
633
-    {
634
-        //Console.WriteLine("Event expose. Args = " + args.ToString());
635
-
636
-        DrawingArea area = (DrawingArea)o;
637
-        Gdk.Pixbuf displayPixbuf;
638
-        int areaWidth, areaHeight;
639
-
640
-        // Get graphic context for background
641
-        Gdk.GC gc = area.Style.BackgroundGC(Gtk.StateType.Normal);
642 625
 
643
-        // get size of drawingarea widget
644
-        area.GdkWindow.GetSize(out areaWidth, out areaHeight);
645
-        int width = drawingareaCameraPixbuf.Width;
646
-        int height = drawingareaCameraPixbuf.Height;
647
-        float ratio = (float)width / (float)height;
648
-
649
-        // if widget is smaller than image, reduce it
650
-        if (areaWidth <= width)
651
-        {
652
-            width = areaWidth;
653
-            height = (int)(width / ratio);
654
-        }
655
-
656
-        // if image is smaller than widget, enlarge it
657
-        if (width > areaWidth)
658
-        {
659
-            width = areaWidth;
660
-        }
661
-
662
-        if (height > areaHeight)
663
-        {
664
-            height = areaHeight;
665
-        }
666
-
667
-        //scale original picture and copy result in local pixbuf
668
-        displayPixbuf = drawingareaCameraPixbuf.ScaleSimple(width, height, InterpType.Bilinear);
669
-
670
-        // draw local pixbuff centered on drawingarea
671
-        area.GdkWindow.DrawPixbuf(gc, displayPixbuf,
672
-                                  0, 0,
673
-                                  (areaWidth - displayPixbuf.Width) / 2,
674
-                                  (areaHeight - displayPixbuf.Height) / 2,
675
-                                  displayPixbuf.Width, displayPixbuf.Height,
676
-                                  RgbDither.Normal, 0, 0);
677
-
678
-        if (checkButtonRobotPosition.Active) {
679
-            Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
680
-            Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
681
-
682
-            cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
683
-            cr.SetSourceColor(textFontColor);
684
-            cr.SetFontSize(16);
685
-
686
-            double space = 0.0;
687
-            string text = "Direction (" + position.direction.x.ToString("0.##") + " ; " + position.direction.y.ToString("0.##") +")";
688
-            TextExtents te = cr.TextExtents(text);
689
-            cr.MoveTo(areaWidth - te.Width-5,
690
-                      areaHeight - te.Height -5);
691
-            space = te.Height;
692
-            cr.ShowText(text);
693
-
694
-            text = "Centre (" + position.centre.x.ToString("0.##") + " ; " + position.centre.y.ToString("0.##") + ")";
695
-            te = cr.TextExtents(text);
696
-            cr.MoveTo(areaWidth - te.Width - 5,
697
-                      areaHeight - te.Height - 5 - space-5);
698
-            space = space+ te.Height+5;
699
-            cr.ShowText(text);
700
-
701
-            text = "Angle: " + position.angle.ToString("0.##");
702
-            te = cr.TextExtents(text);
703
-            cr.MoveTo(areaWidth - te.Width - 5,
704
-                      areaHeight - te.Height - 5 - space - 5);
705
-            space = space+ te.Height+5;
706
-            cr.ShowText(text);
707
-
708
-            text = "ID: " + position.robotID;
709
-            te = cr.TextExtents(text);
710
-            cr.MoveTo(areaWidth - te.Width - 5,
711
-                      areaHeight - te.Height - 5 - space-5);
712
-
713
-            cr.ShowText(text);
714
-
715
-            ((IDisposable)cr.GetTarget()).Dispose();
716
-            ((IDisposable)cr).Dispose();
717
-        }
718
-
719
-        if (checkButtonFPS.Active) {
720
-            Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
721
-            Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
722
-
723
-            cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
724
-            cr.SetSourceColor(textFontColor);
725
-            cr.SetFontSize(16);
726
-
727
-            string text = "FPS= " + imageFPS.ToString() ;
728
-            TextExtents te = cr.TextExtents(text);
729
-            cr.MoveTo( 10,10 + te.Height);
730
-            cr.ShowText(text);
731
-
732
-            ((IDisposable)cr.GetTarget()).Dispose();
733
-            ((IDisposable)cr).Dispose();
734
-        }
626
+        imageWidget.showPosition = checkButtonRobotPosition.Active;
735 627
     }
736 628
 
737 629
     /// <summary>
@@ -766,7 +658,7 @@ public partial class MainWindow : Gtk.Window
766 658
     }
767 659
 
768 660
     /// <summary>
769
-    /// Callback called when "detect Arena " button is clicked
661
+    /// Callback called when "Detect Arena" button is clicked
770 662
     /// </summary>
771 663
     /// <param name="sender">Sender object</param>
772 664
     /// <param name="e">Event</param>
@@ -785,32 +677,13 @@ public partial class MainWindow : Gtk.Window
785 677
         DetectArena();
786 678
     }
787 679
 
680
+    /// <summary>
681
+    /// Callback function for FPS checkbutton
682
+    /// </summary>
683
+    /// <param name="sender">Sender object</param>
684
+    /// <param name="e">unused paramter</param>
788 685
     protected void OnCheckButtonFPSToggled(object sender, EventArgs e)
789 686
     {
790
-        if (checkButtonFPS.Active) { // User ask for FPS
791
-            imageFPS = 0;
792
-            imageFPScounter = 0;
793
-
794
-            fpsTimer.Start();
795
-        }
796
-        else { // stop computing FPS
797
-            fpsTimer.Stop();
798
-
799
-            Gtk.Application.Invoke(delegate
800
-            {
801
-                drawingAreaCamera.QueueDraw();
802
-            });
803
-        }
804
-    }
805
-
806
-    private void OnFpsTimerElapsed(object sender, ElapsedEventArgs e)
807
-    {
808
-        imageFPS = imageFPScounter;
809
-        imageFPScounter = 0;
810
-
811
-        Gtk.Application.Invoke(delegate
812
-        {
813
-            drawingAreaCamera.QueueDraw();
814
-        });
687
+        imageWidget.ShowFPS = checkButtonFPS.Active;
815 688
     }
816 689
 }

+ 95
- 71
software/monitor/monitor/gtk-gui/MainWindow.cs View File

@@ -117,6 +117,8 @@ public partial class MainWindow
117 117
 
118 118
 	private global::Gtk.Button buttonRight;
119 119
 
120
+	private global::Gtk.Button buttonStop;
121
+
120 122
 	private global::Gtk.Table table3;
121 123
 
122 124
 	private global::Gtk.Label label3;
@@ -528,70 +530,92 @@ public partial class MainWindow
528 530
 		this.table4.ColumnSpacing = ((uint)(6));
529 531
 		// Container child table4.Gtk.Table+TableChild
530 532
 		this.buttonDown = new global::Gtk.Button();
533
+		global::Gtk.Tooltips w40 = new Gtk.Tooltips();
534
+		w40.SetTip(this.buttonDown, "Move robot backward", "Move robot backward");
531 535
 		this.buttonDown.CanFocus = true;
532 536
 		this.buttonDown.Name = "buttonDown";
533 537
 		this.buttonDown.UseUnderline = true;
534
-		global::Gtk.Image w40 = new global::Gtk.Image();
535
-		w40.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-down-symbolic.symbolic.png");
536
-		this.buttonDown.Image = w40;
538
+		global::Gtk.Image w41 = new global::Gtk.Image();
539
+		w41.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-down-symbolic.symbolic.png");
540
+		this.buttonDown.Image = w41;
537 541
 		this.table4.Add(this.buttonDown);
538
-		global::Gtk.Table.TableChild w41 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonDown]));
539
-		w41.TopAttach = ((uint)(2));
540
-		w41.BottomAttach = ((uint)(3));
541
-		w41.LeftAttach = ((uint)(1));
542
-		w41.RightAttach = ((uint)(2));
543
-		w41.XOptions = ((global::Gtk.AttachOptions)(4));
544
-		w41.YOptions = ((global::Gtk.AttachOptions)(4));
542
+		global::Gtk.Table.TableChild w42 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonDown]));
543
+		w42.TopAttach = ((uint)(2));
544
+		w42.BottomAttach = ((uint)(3));
545
+		w42.LeftAttach = ((uint)(1));
546
+		w42.RightAttach = ((uint)(2));
547
+		w42.XOptions = ((global::Gtk.AttachOptions)(4));
548
+		w42.YOptions = ((global::Gtk.AttachOptions)(4));
545 549
 		// Container child table4.Gtk.Table+TableChild
546 550
 		this.buttonForward = new global::Gtk.Button();
551
+		w40.SetTip(this.buttonForward, "Move robot forward", "Move robot forward");
547 552
 		this.buttonForward.CanFocus = true;
548 553
 		this.buttonForward.Name = "buttonForward";
549 554
 		this.buttonForward.UseUnderline = true;
550
-		global::Gtk.Image w42 = new global::Gtk.Image();
551
-		w42.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-up-symbolic.symbolic.png");
552
-		this.buttonForward.Image = w42;
555
+		global::Gtk.Image w43 = new global::Gtk.Image();
556
+		w43.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-up-symbolic.symbolic.png");
557
+		this.buttonForward.Image = w43;
553 558
 		this.table4.Add(this.buttonForward);
554
-		global::Gtk.Table.TableChild w43 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonForward]));
555
-		w43.LeftAttach = ((uint)(1));
556
-		w43.RightAttach = ((uint)(2));
557
-		w43.XOptions = ((global::Gtk.AttachOptions)(4));
558
-		w43.YOptions = ((global::Gtk.AttachOptions)(4));
559
+		global::Gtk.Table.TableChild w44 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonForward]));
560
+		w44.LeftAttach = ((uint)(1));
561
+		w44.RightAttach = ((uint)(2));
562
+		w44.XOptions = ((global::Gtk.AttachOptions)(4));
563
+		w44.YOptions = ((global::Gtk.AttachOptions)(4));
559 564
 		// Container child table4.Gtk.Table+TableChild
560 565
 		this.buttonLeft = new global::Gtk.Button();
566
+		w40.SetTip(this.buttonLeft, "Turn robot to the left", "Turn robot to the left");
561 567
 		this.buttonLeft.CanFocus = true;
562 568
 		this.buttonLeft.Name = "buttonLeft";
563 569
 		this.buttonLeft.UseUnderline = true;
564
-		global::Gtk.Image w44 = new global::Gtk.Image();
565
-		w44.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-start-symbolic.symbolic.png");
566
-		this.buttonLeft.Image = w44;
570
+		global::Gtk.Image w45 = new global::Gtk.Image();
571
+		w45.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-start-symbolic.symbolic.png");
572
+		this.buttonLeft.Image = w45;
567 573
 		this.table4.Add(this.buttonLeft);
568
-		global::Gtk.Table.TableChild w45 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonLeft]));
569
-		w45.TopAttach = ((uint)(1));
570
-		w45.BottomAttach = ((uint)(2));
571
-		w45.XOptions = ((global::Gtk.AttachOptions)(4));
572
-		w45.YOptions = ((global::Gtk.AttachOptions)(4));
574
+		global::Gtk.Table.TableChild w46 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonLeft]));
575
+		w46.TopAttach = ((uint)(1));
576
+		w46.BottomAttach = ((uint)(2));
577
+		w46.XOptions = ((global::Gtk.AttachOptions)(4));
578
+		w46.YOptions = ((global::Gtk.AttachOptions)(4));
573 579
 		// Container child table4.Gtk.Table+TableChild
574 580
 		this.buttonRight = new global::Gtk.Button();
581
+		w40.SetTip(this.buttonRight, "Turn robot to the right", "Turn robot to the right");
575 582
 		this.buttonRight.CanFocus = true;
576 583
 		this.buttonRight.Name = "buttonRight";
577 584
 		this.buttonRight.UseUnderline = true;
578
-		global::Gtk.Image w46 = new global::Gtk.Image();
579
-		w46.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-end-symbolic.symbolic.png");
580
-		this.buttonRight.Image = w46;
585
+		global::Gtk.Image w47 = new global::Gtk.Image();
586
+		w47.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.pan-end-symbolic.symbolic.png");
587
+		this.buttonRight.Image = w47;
581 588
 		this.table4.Add(this.buttonRight);
582
-		global::Gtk.Table.TableChild w47 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonRight]));
583
-		w47.TopAttach = ((uint)(1));
584
-		w47.BottomAttach = ((uint)(2));
585
-		w47.LeftAttach = ((uint)(2));
586
-		w47.RightAttach = ((uint)(3));
587
-		w47.XOptions = ((global::Gtk.AttachOptions)(4));
588
-		w47.YOptions = ((global::Gtk.AttachOptions)(4));
589
+		global::Gtk.Table.TableChild w48 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonRight]));
590
+		w48.TopAttach = ((uint)(1));
591
+		w48.BottomAttach = ((uint)(2));
592
+		w48.LeftAttach = ((uint)(2));
593
+		w48.RightAttach = ((uint)(3));
594
+		w48.XOptions = ((global::Gtk.AttachOptions)(4));
595
+		w48.YOptions = ((global::Gtk.AttachOptions)(4));
596
+		// Container child table4.Gtk.Table+TableChild
597
+		this.buttonStop = new global::Gtk.Button();
598
+		w40.SetTip(this.buttonStop, "Stop robot movements", "Stop robot movements");
599
+		this.buttonStop.CanFocus = true;
600
+		this.buttonStop.Name = "buttonStop";
601
+		this.buttonStop.UseUnderline = true;
602
+		global::Gtk.Image w49 = new global::Gtk.Image();
603
+		w49.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("monitor.ressources.hand-filled-32.png");
604
+		this.buttonStop.Image = w49;
605
+		this.table4.Add(this.buttonStop);
606
+		global::Gtk.Table.TableChild w50 = ((global::Gtk.Table.TableChild)(this.table4[this.buttonStop]));
607
+		w50.TopAttach = ((uint)(1));
608
+		w50.BottomAttach = ((uint)(2));
609
+		w50.LeftAttach = ((uint)(1));
610
+		w50.RightAttach = ((uint)(2));
611
+		w50.XOptions = ((global::Gtk.AttachOptions)(4));
612
+		w50.YOptions = ((global::Gtk.AttachOptions)(4));
589 613
 		this.alignment8.Add(this.table4);
590 614
 		this.vbox9.Add(this.alignment8);
591
-		global::Gtk.Box.BoxChild w49 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.alignment8]));
592
-		w49.Position = 0;
593
-		w49.Expand = false;
594
-		w49.Fill = false;
615
+		global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.alignment8]));
616
+		w52.Position = 0;
617
+		w52.Expand = false;
618
+		w52.Fill = false;
595 619
 		// Container child vbox9.Gtk.Box+BoxChild
596 620
 		this.table3 = new global::Gtk.Table(((uint)(1)), ((uint)(2)), false);
597 621
 		this.table3.Name = "table3";
@@ -604,10 +628,10 @@ public partial class MainWindow
604 628
 		this.label3.LabelProp = global::Mono.Unix.Catalog.GetString("Battery level:");
605 629
 		this.label3.Justify = ((global::Gtk.Justification)(1));
606 630
 		this.table3.Add(this.label3);
607
-		global::Gtk.Table.TableChild w50 = ((global::Gtk.Table.TableChild)(this.table3[this.label3]));
608
-		w50.YPadding = ((uint)(10));
609
-		w50.XOptions = ((global::Gtk.AttachOptions)(4));
610
-		w50.YOptions = ((global::Gtk.AttachOptions)(4));
631
+		global::Gtk.Table.TableChild w53 = ((global::Gtk.Table.TableChild)(this.table3[this.label3]));
632
+		w53.YPadding = ((uint)(10));
633
+		w53.XOptions = ((global::Gtk.AttachOptions)(4));
634
+		w53.YOptions = ((global::Gtk.AttachOptions)(4));
611 635
 		// Container child table3.Gtk.Table+TableChild
612 636
 		this.labelBatteryLevel = new global::Gtk.Label();
613 637
 		this.labelBatteryLevel.Name = "labelBatteryLevel";
@@ -615,15 +639,15 @@ public partial class MainWindow
615 639
 		this.labelBatteryLevel.Xalign = 0F;
616 640
 		this.labelBatteryLevel.LabelProp = global::Mono.Unix.Catalog.GetString("Unknown");
617 641
 		this.table3.Add(this.labelBatteryLevel);
618
-		global::Gtk.Table.TableChild w51 = ((global::Gtk.Table.TableChild)(this.table3[this.labelBatteryLevel]));
619
-		w51.LeftAttach = ((uint)(1));
620
-		w51.RightAttach = ((uint)(2));
621
-		w51.YOptions = ((global::Gtk.AttachOptions)(4));
642
+		global::Gtk.Table.TableChild w54 = ((global::Gtk.Table.TableChild)(this.table3[this.labelBatteryLevel]));
643
+		w54.LeftAttach = ((uint)(1));
644
+		w54.RightAttach = ((uint)(2));
645
+		w54.YOptions = ((global::Gtk.AttachOptions)(4));
622 646
 		this.vbox9.Add(this.table3);
623
-		global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.table3]));
624
-		w52.Position = 2;
625
-		w52.Expand = false;
626
-		w52.Fill = false;
647
+		global::Gtk.Box.BoxChild w55 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.table3]));
648
+		w55.Position = 2;
649
+		w55.Expand = false;
650
+		w55.Fill = false;
627 651
 		// Container child vbox9.Gtk.Box+BoxChild
628 652
 		this.checkButtonGetBattery = new global::Gtk.CheckButton();
629 653
 		this.checkButtonGetBattery.CanFocus = true;
@@ -633,31 +657,31 @@ public partial class MainWindow
633 657
 		this.checkButtonGetBattery.DrawIndicator = true;
634 658
 		this.checkButtonGetBattery.UseUnderline = true;
635 659
 		this.vbox9.Add(this.checkButtonGetBattery);
636
-		global::Gtk.Box.BoxChild w53 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.checkButtonGetBattery]));
637
-		w53.Position = 3;
638
-		w53.Expand = false;
639
-		w53.Fill = false;
660
+		global::Gtk.Box.BoxChild w56 = ((global::Gtk.Box.BoxChild)(this.vbox9[this.checkButtonGetBattery]));
661
+		w56.Position = 3;
662
+		w56.Expand = false;
663
+		w56.Fill = false;
640 664
 		this.gtkAlignmentRobotControl.Add(this.vbox9);
641 665
 		this.vbox12.Add(this.gtkAlignmentRobotControl);
642
-		global::Gtk.Box.BoxChild w55 = ((global::Gtk.Box.BoxChild)(this.vbox12[this.gtkAlignmentRobotControl]));
643
-		w55.Position = 1;
666
+		global::Gtk.Box.BoxChild w58 = ((global::Gtk.Box.BoxChild)(this.vbox12[this.gtkAlignmentRobotControl]));
667
+		w58.Position = 1;
644 668
 		this.vbox5.Add(this.vbox12);
645
-		global::Gtk.Box.BoxChild w56 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.vbox12]));
646
-		w56.Position = 4;
669
+		global::Gtk.Box.BoxChild w59 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.vbox12]));
670
+		w59.Position = 4;
647 671
 		this.alignment3.Add(this.vbox5);
648 672
 		this.hbox3.Add(this.alignment3);
649
-		global::Gtk.Box.BoxChild w58 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.alignment3]));
650
-		w58.Position = 1;
651
-		w58.Expand = false;
652
-		w58.Fill = false;
673
+		global::Gtk.Box.BoxChild w61 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.alignment3]));
674
+		w61.Position = 1;
675
+		w61.Expand = false;
676
+		w61.Fill = false;
653 677
 		this.hbox1.Add(this.hbox3);
654
-		global::Gtk.Box.BoxChild w59 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.hbox3]));
655
-		w59.Position = 1;
656
-		w59.Expand = false;
657
-		w59.Fill = false;
678
+		global::Gtk.Box.BoxChild w62 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.hbox3]));
679
+		w62.Position = 1;
680
+		w62.Expand = false;
681
+		w62.Fill = false;
658 682
 		this.vbox1.Add(this.hbox1);
659
-		global::Gtk.Box.BoxChild w60 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
660
-		w60.Position = 1;
683
+		global::Gtk.Box.BoxChild w63 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
684
+		w63.Position = 1;
661 685
 		this.Add(this.vbox1);
662 686
 		if ((this.Child != null))
663 687
 		{
@@ -673,9 +697,9 @@ public partial class MainWindow
673 697
 		this.checkButtonRobotPosition.Clicked += new global::System.EventHandler(this.OnCheckButtonRobotPositionClicked);
674 698
 		this.checkButtonFPS.Toggled += new global::System.EventHandler(this.OnCheckButtonFPSToggled);
675 699
 		this.buttonAskArena.Clicked += new global::System.EventHandler(this.OnButtonAskArenaClicked);
676
-		this.drawingAreaCamera.ExposeEvent += new global::Gtk.ExposeEventHandler(this.OnDrawingAreaCameraExposeEvent);
677 700
 		this.buttonServerConnection.Clicked += new global::System.EventHandler(this.OnButtonServerConnectionClicked);
678 701
 		this.buttonRobotActivation.Clicked += new global::System.EventHandler(this.OnButtonRobotActivationClicked);
702
+		this.buttonStop.Clicked += new global::System.EventHandler(this.OnButtonMouvClicked);
679 703
 		this.buttonRight.Clicked += new global::System.EventHandler(this.OnButtonMouvClicked);
680 704
 		this.buttonLeft.Clicked += new global::System.EventHandler(this.OnButtonMouvClicked);
681 705
 		this.buttonForward.Clicked += new global::System.EventHandler(this.OnButtonMouvClicked);

+ 31
- 4
software/monitor/monitor/gtk-gui/gui.stetic View File

@@ -170,7 +170,6 @@
170 170
                 <child>
171 171
                   <widget class="Gtk.DrawingArea" id="drawingAreaCamera">
172 172
                     <property name="MemberName" />
173
-                    <signal name="ExposeEvent" handler="OnDrawingAreaCameraExposeEvent" />
174 173
                   </widget>
175 174
                   <packing>
176 175
                     <property name="Position">1</property>
@@ -611,11 +610,9 @@
611 610
                                               <placeholder />
612 611
                                             </child>
613 612
                                             <child>
614
-                                              <placeholder />
615
-                                            </child>
616
-                                            <child>
617 613
                                               <widget class="Gtk.Button" id="buttonDown">
618 614
                                                 <property name="MemberName" />
615
+                                                <property name="Tooltip" translatable="yes">Move robot backward</property>
619 616
                                                 <property name="CanFocus">True</property>
620 617
                                                 <property name="Type">TextAndIcon</property>
621 618
                                                 <property name="Icon">resource:monitor.ressources.pan-down-symbolic.symbolic.png</property>
@@ -642,6 +639,7 @@
642 639
                                             <child>
643 640
                                               <widget class="Gtk.Button" id="buttonForward">
644 641
                                                 <property name="MemberName" />
642
+                                                <property name="Tooltip" translatable="yes">Move robot forward</property>
645 643
                                                 <property name="CanFocus">True</property>
646 644
                                                 <property name="Type">TextAndIcon</property>
647 645
                                                 <property name="Icon">resource:monitor.ressources.pan-up-symbolic.symbolic.png</property>
@@ -666,6 +664,7 @@
666 664
                                             <child>
667 665
                                               <widget class="Gtk.Button" id="buttonLeft">
668 666
                                                 <property name="MemberName" />
667
+                                                <property name="Tooltip" translatable="yes">Turn robot to the left</property>
669 668
                                                 <property name="CanFocus">True</property>
670 669
                                                 <property name="Type">TextAndIcon</property>
671 670
                                                 <property name="Icon">resource:monitor.ressources.pan-start-symbolic.symbolic.png</property>
@@ -690,6 +689,7 @@
690 689
                                             <child>
691 690
                                               <widget class="Gtk.Button" id="buttonRight">
692 691
                                                 <property name="MemberName" />
692
+                                                <property name="Tooltip" translatable="yes">Turn robot to the right</property>
693 693
                                                 <property name="CanFocus">True</property>
694 694
                                                 <property name="Type">TextAndIcon</property>
695 695
                                                 <property name="Icon">resource:monitor.ressources.pan-end-symbolic.symbolic.png</property>
@@ -713,6 +713,33 @@
713 713
                                                 <property name="YShrink">False</property>
714 714
                                               </packing>
715 715
                                             </child>
716
+                                            <child>
717
+                                              <widget class="Gtk.Button" id="buttonStop">
718
+                                                <property name="MemberName" />
719
+                                                <property name="Tooltip" translatable="yes">Stop robot movements</property>
720
+                                                <property name="CanFocus">True</property>
721
+                                                <property name="Type">TextAndIcon</property>
722
+                                                <property name="Icon">resource:monitor.ressources.hand-filled-32.png</property>
723
+                                                <property name="Label" translatable="yes" />
724
+                                                <property name="UseUnderline">True</property>
725
+                                                <signal name="Clicked" handler="OnButtonMouvClicked" />
726
+                                              </widget>
727
+                                              <packing>
728
+                                                <property name="TopAttach">1</property>
729
+                                                <property name="BottomAttach">2</property>
730
+                                                <property name="LeftAttach">1</property>
731
+                                                <property name="RightAttach">2</property>
732
+                                                <property name="AutoSize">True</property>
733
+                                                <property name="XOptions">Fill</property>
734
+                                                <property name="YOptions">Fill</property>
735
+                                                <property name="XExpand">False</property>
736
+                                                <property name="XFill">True</property>
737
+                                                <property name="XShrink">False</property>
738
+                                                <property name="YExpand">False</property>
739
+                                                <property name="YFill">True</property>
740
+                                                <property name="YShrink">False</property>
741
+                                              </packing>
742
+                                            </child>
716 743
                                           </widget>
717 744
                                         </child>
718 745
                                       </widget>

BIN
software/monitor/monitor/monitor View File


+ 2
- 0
software/monitor/monitor/monitor.csproj View File

@@ -70,6 +70,7 @@
70 70
     <EmbeddedResource Include="ressources\robot-icon.png" />
71 71
     <EmbeddedResource Include="ressources\robot-icon.resized.png" />
72 72
     <EmbeddedResource Include="ressources\missing_picture.png" />
73
+    <EmbeddedResource Include="ressources\hand-filled-32.png" />
73 74
   </ItemGroup>
74 75
   <ItemGroup>
75 76
     <Compile Include="gtk-gui\generated.cs" />
@@ -80,6 +81,7 @@
80 81
     <Compile Include="Client.cs" />
81 82
     <Compile Include="CommandManager.cs" />
82 83
     <Compile Include="DestijlCommandManager.cs" />
84
+    <Compile Include="ImageWidget.cs" />
83 85
   </ItemGroup>
84 86
   <ItemGroup>
85 87
     <None Include="afterBuild.sh" />

BIN
software/monitor/monitor/ressources/hand-filled-32.png View File


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

@@ -9,3 +9,6 @@ Makefile
9 9
 *.cmake
10 10
 CMakeCache.txt
11 11
 
12
+docs/
13
+doc/
14
+

+ 0
- 23
software/raspberry/superviseur-robot/CMakeLists.txt View File

@@ -1,23 +0,0 @@
1
-cmake_minimum_required(VERSION 3.6)
2
-project(ProjDestijl CXX)
3
-
4
-set (ProjDestjil_VERSION_MAJOR 1)
5
-set (ProjDestjil_VERSION_MINOR 0)
6
-set (CMAKE_CXX_STANDARD 11)
7
-
8
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
9
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
10
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/superviseur/bin)
11
-
12
-option(BUILD_FOR_XENOMAI "Build for Raspberry" OFF)
13
-
14
-set(CMAKE_BUILD_TYPE DEBUG)
15
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy")
16
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy")
17
-
18
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt")
19
-
20
-add_subdirectory("lib")
21
-#add_subdirectory("examples")
22
-add_subdirectory("superviseur")
23
-

+ 0
- 142
software/raspberry/superviseur-robot/ProjDestijl.cbp View File

@@ -1,142 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<CodeBlocks_project_file>
3
-	<FileVersion major="1" minor="6"/>
4
-	<Project>
5
-		<Option title="ProjDestijl"/>
6
-		<Option makefile_is_custom="1"/>
7
-		<Option compiler="gcc"/>
8
-		<Option virtualFolders="CMake Files\;CMake Files\lib\;CMake Files\superviseur\;"/>
9
-		<Build>
10
-			<Target title="all">
11
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot"/>
12
-				<Option type="4"/>
13
-				<MakeCommands>
14
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 all"/>
15
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
16
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
17
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
18
-				</MakeCommands>
19
-			</Target>
20
-			<Target title="rebuild_cache">
21
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot"/>
22
-				<Option type="4"/>
23
-				<MakeCommands>
24
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 rebuild_cache"/>
25
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
26
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
27
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
28
-				</MakeCommands>
29
-			</Target>
30
-			<Target title="edit_cache">
31
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot"/>
32
-				<Option type="4"/>
33
-				<MakeCommands>
34
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 edit_cache"/>
35
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
36
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
37
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/Makefile&quot;  VERBOSE=1 clean"/>
38
-				</MakeCommands>
39
-			</Target>
40
-			<Target title="destijl">
41
-				<Option output="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/lib/libdestijl.a" prefix_auto="0" extension_auto="0"/>
42
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib"/>
43
-				<Option object_output="./"/>
44
-				<Option type="2"/>
45
-				<Option compiler="gcc"/>
46
-				<Compiler>
47
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/."/>
48
-				</Compiler>
49
-				<MakeCommands>
50
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 destijl"/>
51
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
52
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 clean"/>
53
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 clean"/>
54
-				</MakeCommands>
55
-			</Target>
56
-			<Target title="destijl/fast">
57
-				<Option output="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/lib/libdestijl.a" prefix_auto="0" extension_auto="0"/>
58
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib"/>
59
-				<Option object_output="./"/>
60
-				<Option type="2"/>
61
-				<Option compiler="gcc"/>
62
-				<Compiler>
63
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/."/>
64
-				</Compiler>
65
-				<MakeCommands>
66
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 destijl/fast"/>
67
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
68
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 clean"/>
69
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/Makefile&quot;  VERBOSE=1 clean"/>
70
-				</MakeCommands>
71
-			</Target>
72
-			<Target title="superviseur">
73
-				<Option output="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur/bin/superviseur" prefix_auto="0" extension_auto="0"/>
74
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/../superviseur/bin"/>
75
-				<Option object_output="./"/>
76
-				<Option type="1"/>
77
-				<Option compiler="gcc"/>
78
-				<Compiler>
79
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/./src"/>
80
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/../lib"/>
81
-					<Add directory="/usr/xenomai/include"/>
82
-					<Add directory="/usr/xenomai/include/mercury"/>
83
-				</Compiler>
84
-				<MakeCommands>
85
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 superviseur"/>
86
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
87
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 clean"/>
88
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 clean"/>
89
-				</MakeCommands>
90
-			</Target>
91
-			<Target title="superviseur/fast">
92
-				<Option output="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur/bin/superviseur" prefix_auto="0" extension_auto="0"/>
93
-				<Option working_dir="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/../superviseur/bin"/>
94
-				<Option object_output="./"/>
95
-				<Option type="1"/>
96
-				<Option compiler="gcc"/>
97
-				<Compiler>
98
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/./src"/>
99
-					<Add directory="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/../lib"/>
100
-					<Add directory="/usr/xenomai/include"/>
101
-					<Add directory="/usr/xenomai/include/mercury"/>
102
-				</Compiler>
103
-				<MakeCommands>
104
-					<Build command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 superviseur/fast"/>
105
-					<CompileFile command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 &quot;$file&quot;"/>
106
-					<Clean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 clean"/>
107
-					<DistClean command="/usr/bin/make -f &quot;/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/Makefile&quot;  VERBOSE=1 clean"/>
108
-				</MakeCommands>
109
-			</Target>
110
-		</Build>
111
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/image.cpp">
112
-			<Option target="destijl"/>
113
-		</Unit>
114
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/message.cpp">
115
-			<Option target="destijl"/>
116
-		</Unit>
117
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/monitor.cpp">
118
-			<Option target="destijl"/>
119
-		</Unit>
120
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/robot.cpp">
121
-			<Option target="destijl"/>
122
-		</Unit>
123
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/functions.cpp">
124
-			<Option target="superviseur"/>
125
-		</Unit>
126
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/functions.h">
127
-			<Option target="superviseur"/>
128
-		</Unit>
129
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/main.cpp">
130
-			<Option target="superviseur"/>
131
-		</Unit>
132
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/CMakeLists.txt">
133
-			<Option virtualFolder="CMake Files\"/>
134
-		</Unit>
135
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/CMakeLists.txt">
136
-			<Option virtualFolder="CMake Files\lib\"/>
137
-		</Unit>
138
-		<Unit filename="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/CMakeLists.txt">
139
-			<Option virtualFolder="CMake Files\superviseur\"/>
140
-		</Unit>
141
-	</Project>
142
-</CodeBlocks_project_file>

+ 0
- 32
software/raspberry/superviseur-robot/compile_commands.json View File

@@ -1,32 +0,0 @@
1
-[
2
-{
3
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib",
4
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/.   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/destijl.dir/src/robot.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/robot.cpp",
5
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/robot.cpp"
6
-},
7
-{
8
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib",
9
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/.   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/destijl.dir/src/monitor.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/monitor.cpp",
10
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/monitor.cpp"
11
-},
12
-{
13
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib",
14
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/.   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/destijl.dir/src/message.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/message.cpp",
15
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/message.cpp"
16
-},
17
-{
18
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib",
19
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/.   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/destijl.dir/src/image.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/image.cpp",
20
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/src/image.cpp"
21
-},
22
-{
23
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur",
24
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/./src -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/../lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/superviseur.dir/src/main.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/main.cpp",
25
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/main.cpp"
26
-},
27
-{
28
-  "directory": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur",
29
-  "command": "/usr/bin/g++   -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/./src -I/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/../lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury   -I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -g3 -gdwarf-2   -std=gnu++11 -o CMakeFiles/superviseur.dir/src/functions.cpp.o -c /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/functions.cpp",
30
-  "file": "/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/superviseur/src/functions.cpp"
31
-}
32
-]

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


+ 0
- 5
software/raspberry/superviseur-robot/lib/CMakeLists.txt View File

@@ -1,5 +0,0 @@
1
-set(LIB_FILES ./src/robot.cpp ./src/monitor.cpp ./src/message.cpp ./src/image.cpp)
2
-include_directories("./")
3
-
4
-add_library(destijl STATIC ${LIB_FILES})
5
-

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

@@ -1,4 +1,4 @@
1
- /*
1
+/*
2 2
  * Copyright (C) 2018 dimercur
3 3
  *
4 4
  * This program is free software: you can redistribute it and/or modify
@@ -21,48 +21,64 @@
21 21
 
22 22
 using namespace cv;
23 23
 
24
+/**
25
+ * Create an object for accessing camera
26
+ * @param size Size of picture to grab (@see captureSize)
27
+ * @param fps speed of sampling
28
+ */
24 29
 Camera::Camera(int size, int fps) {
25 30
     this->SetSize(size);
26 31
 #ifndef __FOR_PC__
27 32
     this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
28
-    this->cap.set(CV_CAP_PROP_FRAME_WIDTH,width);
29
-    this->cap.set(CV_CAP_PROP_FRAME_HEIGHT,height);
33
+    this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
34
+    this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
30 35
     this->cap.set(CV_CAP_PROP_FPS, fps);
31 36
 #endif /* __FOR_PC__ */
32 37
 }
33 38
 
39
+/**
40
+ * Open camera
41
+ * @return True if camera is open, false otherwise
42
+ */
34 43
 bool Camera::Open() {
35 44
     bool status = false;
36
-    
45
+
37 46
 #ifdef __FOR_PC__
38 47
     if (this->cap.open(0)) {
39 48
         //this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
40
-        this->cap.set(CV_CAP_PROP_FRAME_WIDTH,width);
41
-        this->cap.set(CV_CAP_PROP_FRAME_HEIGHT,height);
42
-        
43
-        status =true;
44
-     }
49
+        this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
50
+        this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
51
+
52
+        status = true;
53
+    }
45 54
 #else
46 55
     if (this->cap.open()) {
47
-        cout<<"Camera warmup 2sec"<<endl<<flush;
56
+        cout << "Camera warmup 2sec" << endl << flush;
48 57
         sleep(2);
49
-        cout<<"Start capture"<<endl<<flush;
50
-    
51
-        status =true;
58
+        cout << "Start capture" << endl << flush;
59
+
60
+        status = true;
52 61
     }
53 62
 #endif /* __FOR_PC__ */
54
-    
63
+
55 64
     return status;
56 65
 }
57 66
 
67
+/**
68
+ * Close and release camera
69
+ */
58 70
 void Camera::Close() {
59 71
     this->cap.release();
60 72
 }
61 73
 
74
+/**
75
+ * Define size for sampled picture
76
+ * @param size Size of picture (@see captureSize)
77
+ */
62 78
 void Camera::SetSize(int size) {
63 79
     this->size = size;
64
-    
65
-    switch (size){
80
+
81
+    switch (size) {
66 82
         case xs:
67 83
             this->width = 480;
68 84
             this->height = 360;
@@ -85,33 +101,47 @@ void Camera::SetSize(int size) {
85 101
     }
86 102
 }
87 103
 
104
+/**
105
+ * Grab next image from camera
106
+ * @return Image taken from camera
107
+ */
88 108
 Img Camera::Grab() {
89 109
     ImageMat frame;
90
-    
110
+
91 111
 #ifdef __FOR_PC__
92 112
     cap >> frame;
93 113
     Img capture = Img(frame);
94 114
 #else
95 115
     cap.grab();
96
-    cap.retrieve (frame);
97
-    cvtColor(frame,frame,CV_BGR2RGB);
98
-    
116
+    cap.retrieve(frame);
117
+    cvtColor(frame, frame, CV_BGR2RGB);
118
+
99 119
     Img capture = Img(frame);
100 120
 #endif /* __FOR_PC__ */
101
-    
121
+
102 122
     return capture;
103 123
 }
104 124
 
125
+/**
126
+ * Get opening status for camera
127
+ * @return true if camera is open, false otherwise
128
+ */
105 129
 bool Camera::IsOpen() {
106 130
     return cap.isOpened();
107 131
 }
108 132
 
133
+/**
134
+ * Get width of sampled image
135
+ * @return Width of sampled picture
136
+ */
109 137
 int Camera::GetWidth() const {
110 138
     return width;
111 139
 }
112 140
 
141
+/**
142
+ * Get height of sampled image
143
+ * @return height of sampled picture
144
+ */
113 145
 int Camera::GetHeight() const {
114 146
     return height;
115 147
 }
116
-
117
-

+ 57
- 0
software/raspberry/superviseur-robot/lib/camera.h View File

@@ -26,32 +26,89 @@
26 26
 #endif /* __FOR_PC__ */
27 27
 #include "img.h"
28 28
 
29
+/**
30
+ * Enumerate for picture size
31
+ */
29 32
 enum captureSize {xs, sm, md, lg};
30 33
 
34
+/**
35
+ * Class for camera (image grab)
36
+ * 
37
+ * @brief Class for camera (image grab)
38
+ */
31 39
 class Camera {
32 40
 public:
41
+    /**
42
+     * Create an object for accessing camera
43
+     * @param size Size of picture to grab (@see captureSize)
44
+     * @param fps speed of sampling
45
+     */
33 46
     Camera(int size, int fps);
34 47
 
48
+    /**
49
+     * Open camera
50
+     * @return True if camera is open, false otherwise
51
+     */
35 52
     bool Open();
53
+    
54
+    /**
55
+     * Close and release camera
56
+     */
36 57
     void Close();
37 58
     
59
+    /**
60
+     * Get width of sampled image
61
+     * @return Width of sampled picture
62
+     */
38 63
     int GetWidth() const;
64
+    
65
+    /**
66
+     * Get height of sampled image
67
+     * @return height of sampled picture
68
+     */
39 69
     int GetHeight() const;
40 70
 
71
+    /**
72
+     * Get opening status for camera
73
+     * @return true if camera is open, false otherwise
74
+     */
41 75
     bool IsOpen();
76
+    
77
+    /**
78
+     * Define size for sampled picture
79
+     * @param size Size of picture (@see captureSize)
80
+     */
42 81
     void SetSize(int size);
43 82
 
83
+    /**
84
+     * Grab next image from camera
85
+     * @return Image taken from camera
86
+     */
44 87
     Img Grab();
45 88
     
46 89
 private:
47 90
 #ifdef __FOR_PC__
91
+    /**
92
+     * Camera descriptor
93
+     */
48 94
     cv::VideoCapture cap;
49 95
 #else
50 96
     raspicam::RaspiCam_Cv cap;
51 97
 #endif /*  __FOR_PC__ */   
52 98
    
99
+    /**
100
+     * Size for image (default= small)
101
+     */
53 102
     int size = sm;
103
+    
104
+    /**
105
+     * Width of image
106
+     */
54 107
     int width;
108
+    
109
+    /**
110
+     * Height of image
111
+     */
55 112
     int height;
56 113
 };
57 114
 

+ 2
- 0
software/raspberry/superviseur-robot/lib/commonitor.cpp View File

@@ -339,6 +339,8 @@ Message *ComMonitor::StringToMessage(string &s) {
339 339
         msg = new Message(MESSAGE_ROBOT_GO_LEFT);
340 340
     } else if (tokenCmd.find(LABEL_MONITOR_ROBOT_GO_RIGHT) != string::npos) {
341 341
         msg = new Message(MESSAGE_ROBOT_GO_RIGHT);
342
+    } else if (tokenCmd.find(LABEL_MONITOR_ROBOT_STOP) != string::npos) {
343
+        msg = new Message(MESSAGE_ROBOT_STOP);
342 344
     } else if (tokenCmd.find(LABEL_MONITOR_ROBOT_POWEROFF) != string::npos) {
343 345
         msg = new Message(MESSAGE_ROBOT_POWEROFF);
344 346
     } else {

+ 0
- 70
software/raspberry/superviseur-robot/lib/definitions.h View File

@@ -1,70 +0,0 @@
1
-/*
2
- * Copyright (C) 2018 dimercur
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
-/**
19
- * \file      definitions.h
20
- * \author    PE.Hladik
21
- * \version   1.0
22
- * \date      06/06/2017
23
- * \brief     Various constants used in destjil project
24
- */
25
-
26
-
27
-#ifndef DEFINITIONS_H
28
-#define DEFINITIONS_H
29
-
30
-#define OPEN_COM_DMB            'o'
31
-#define CLOSE_COM_DMB           'C'
32
-
33
-#define DMB_PING                'p'
34
-#define DMB_IDLE                'r'
35
-#define DMB_START_WITHOUT_WD    'u'
36
-#define DMB_START_WITH_WD       'W'
37
-#define DMB_RELOAD_WD           'w'
38
-#define DMB_GET_VBAT            'v'
39
-#define DMB_IS_BUSY             'b'
40
-#define DMB_MOVE                'M'
41
-#define DMB_TURN                'T'
42
-#define DMB_GO_FORWARD          'F'
43
-#define DMB_GO_BACK             'B'
44
-#define DMB_GO_LEFT             'L'
45
-#define DMB_GO_RIGHT            'R'
46
-#define DMB_STOP_MOVE           'S'
47
-
48
-#define ROBOT_TIMED_OUT         -3
49
-#define ROBOT_UKNOWN_CMD        -2
50
-#define ROBOT_ERROR             -1
51
-#define ROBOT_CHECKSUM          -4
52
-#define ROBOT_OK                0
53
-
54
-#define CAM_OPEN                    'A'
55
-#define CAM_CLOSE                   'I'
56
-#define CAM_ASK_ARENA               'y'
57
-#define CAM_ARENA_CONFIRM           'x'
58
-#define CAM_ARENA_INFIRM            'z'
59
-#define CAM_COMPUTE_POSITION        'p'
60
-#define CAM_STOP_COMPUTE_POSITION   's'
61
-
62
-#define DMB_BAT_LOW             0
63
-#define DMB_BAT_MEDIUM          1
64
-#define DMB_BAT_HIGH            2
65
-
66
-#define DMB_BUSY                1
67
-#define DMB_DO_NOTHING          0
68
-
69
-#endif /* MSG_H */
70
-

+ 0
- 260
software/raspberry/superviseur-robot/lib/image.cpp View File

@@ -1,260 +0,0 @@
1
-
2
-/*
3
- * Copyright (C) 2018 dimercur
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
- */
18
-
19
-/**
20
- * \file      image.cpp
21
- * \author    L.Senaneuch
22
- * \version   1.0
23
- * \date      06/06/2017
24
- * \brief     Fonctions de traitement d'image utilisable pour la détection du robot.
25
- *
26
- * \details   Ce fichier utilise la libraire openCV2 pour faciliter le traitement d'image dans le projet Destijl.
27
- *            Il permet de faciliter la détection de l'arène et la détection du robot.
28
- *			  /!\ Attention Bien que celui-ci soit un .cpp la structure du code n'est pas sous forme d'objet.
29
- */
30
-
31
-#include "image.h"
32
-#include <iostream>
33
-
34
-using namespace cv;
35
-#ifndef __STUB__
36
-#ifdef __FOR_PC__
37
-VideoCapture cap;
38
-#else
39
-using namespace raspicam;
40
-#endif /* __FOR_PC__ */
41
-#else
42
-Image stubImg;
43
-
44
-#endif
45
-using namespace std;
46
-
47
-float calculAngle(Position * positionRobot);
48
-int cropArena(Image *imgInput, Image *imgOutput, Arene *AreneInput);
49
-float euclideanDist(Point& p, Point& q);
50
-
51
-void draw_arena(Image *imgInput, Image *imgOutput, Arene *monArene)
52
-{
53
-    if(imgInput!=imgOutput)
54
-        *imgOutput=imgInput->clone();
55
-    rectangle(*imgOutput,monArene->tl(),monArene->br(),Scalar(0,0,125),2,8,0);
56
-}
57
-
58
-int open_camera(Camera  *camera)
59
-{
60
-#ifndef __STUB__
61
-#ifdef __FOR_PC__
62
-    // open the default camera, use something different from 0 otherwise;
63
-    // Check VideoCapture documentation.
64
-    printf("Opening Camera...\n");
65
-    if(!cap.open(0))
66
-        return -1;
67
-    
68
-    return 0;
69
-#else // for raspberry
70
-    
71
-    camera->set(CV_CAP_PROP_FORMAT, CV_8UC3);
72
-    camera->set(CV_CAP_PROP_FRAME_WIDTH,WIDTH);
73
-    camera->set(CV_CAP_PROP_FRAME_HEIGHT,HEIGHT);
74
-
75
-    printf("Opening Camera...\n");
76
-    if (!(camera->open())) {
77
-        perror("Can't open Camera\n") ;
78
-        return -1;
79
-    }
80
-    else
81
-    {
82
-        printf("Camera warmup 2sec\n");
83
-        sleep(2);
84
-        printf("Start capture\n");
85
-        return 0;
86
-    }
87
-#endif /* __FOR_PC__ */
88
-#else 
89
-    return 0;
90
-#endif
91
-}
92
-
93
-void get_image(Camera *camera, Image * monImage, const char  * fichier) // getImg(Camera, Image img);
94
-{
95
-#ifndef __STUB__
96
-#ifdef __FOR_PC__
97
-    if (monImage != NULL)
98
-    {
99
-        cap>>*monImage;
100
-    }
101
-#else // for raspberry
102
-    camera->grab();
103
-    camera->retrieve(*monImage);
104
-    cvtColor(*monImage,*monImage,CV_BGR2RGB);
105
-#endif /* __FOR_PC__ */
106
-#else
107
-    stubImg = imread(fichier, CV_LOAD_IMAGE_COLOR);
108
-    stubImg.copyTo(*monImage);
109
-#endif
110
-}
111
-
112
-void close_camera(Camera *camera) // closeCam(Camera) : camera Entrer
113
-{
114
-#ifndef __STUB__
115
-#ifdef __FOR_PC__
116
-    cap.release();
117
-#else // for raspberry
118
-    camera->release();
119
-#endif /* __FOR_PC__ */
120
-#else
121
-
122
-#endif
123
-}
124
-
125
-
126
-int detect_arena(Image *monImage, Arene *rectangle) // Image en entrée // rectangle en sortie
127
-{
128
-    vector<vector<Point> > contours;
129
-    vector<Point> approx;
130
-    vector<Vec4i> hierarchy;
131
-
132
-    Image imageTrt;
133
-    cvtColor(*monImage,imageTrt,CV_RGB2GRAY); // conversion en niveau de gris
134
-    threshold(imageTrt,imageTrt,128,255,CV_THRESH_BINARY); // Threshold les éléments les plus clair
135
-    Canny(imageTrt, imageTrt, 100,200,3); // detection d'angle
136
-
137
-    findContours(imageTrt, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
138
-    for(unsigned int i = 0; i < contours.size();i++)
139
-	{
140
-        approxPolyDP(Image(contours[i]), approx, arcLength(Image(contours[i]), true)*0.1, true);
141
-        if(approx.size()==4 && fabs(cv::contourArea(contours[i])) > 100000)
142
-        {
143
-            *rectangle = boundingRect(Image(contours[i]));
144
-            return 0;
145
-        }
146
-    }
147
-    return -1;
148
-}
149
-
150
-int cropArena(Image *imgInput, Image *imgOutput, Arene *areneInput) // image // rectangle // image2
151
-{
152
-    Image img;
153
-    img=imgInput->clone();
154
-
155
-    *imgOutput = img(*areneInput);
156
-    return 0;
157
-}
158
-
159
-float euclideanDist(Point& p, Point& q) {
160
-    Point diff = p - q;
161
-    return cv::sqrt(diff.x*diff.x + diff.y*diff.y);
162
-}
163
-
164
-void compress_image(Image *imgInput, Jpg *imageCompress) // image entrée // imageEncodé en sortie
165
-{
166
-    imencode(".jpg",*imgInput,*imageCompress);
167
-}
168
-
169
-
170
-int detect_position(Image *imgInput, Position *posTriangle, Arene * monArene) // entree : image  / sortie tab pos
171
-{
172
-    vector<vector<Point> > contours;
173
-    vector<Point> approx;
174
-    vector<Vec4i> hierarchy;
175
-
176
-    Image imgTraitment;
177
-
178
-    if(monArene==NULL)
179
-        imgTraitment=imgInput->clone();
180
-    else
181
-        cropArena(imgInput,&imgTraitment, monArene);
182
-
183
-    cvtColor(imgTraitment,imgTraitment,CV_RGB2GRAY);
184
-    threshold(imgTraitment,imgTraitment,128,255,CV_THRESH_BINARY);
185
-    findContours(imgTraitment, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
186
-
187
-    int nbrTriangle = 0;
188
-    for(unsigned int i = 0;i < contours.size();i++)
189
-	{
190
-        approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.17, true);
191
-        if(approx.size() == 3 && fabs(contourArea(contours[i])) > 200 && fabs(contourArea(contours[i])) < 700)
192
-        {
193
-
194
-            Point a,b,c;
195
-            Point center;
196
-
197
-
198
-            a = approx[0];
199
-            b = approx[1];
200
-            c = approx[2];
201
-
202
-
203
-            if(monArene !=NULL) // ajout de l'offset de l'arène
204
-            {
205
-               a.x += monArene->x;
206
-               a.y += monArene->y;
207
-               b.x += monArene->x;
208
-               b.y += monArene->y;
209
-               c.x += monArene->x;
210
-               c.y += monArene->y;		    
211
-            }
212
-		
213
-            center.x = (a.x + b.x + c.x)/3;
214
-            center.y = (a.y + b.y + c.y)/3;
215
-
216
-            posTriangle[nbrTriangle].center=center;
217
-
218
-            if(euclideanDist(center,b) > euclideanDist(center,a) && euclideanDist(center,b) > euclideanDist(center,c) )
219
-            {
220
-
221
-                posTriangle[nbrTriangle].direction=b;
222
-                //line(img,center,b,Scalar(0,125,0),2,8,0);
223
-            }
224
-            else if(euclideanDist(center,a) > euclideanDist(center,c))
225
-            {
226
-                posTriangle[nbrTriangle].direction=a;
227
-                //line(img,center,a,Scalar(0,125,0),2,8,0);
228
-
229
-            }
230
-            else
231
-            {
232
-                posTriangle[nbrTriangle].direction=c;
233
-                //line(img,center,c,Scalar(0,125,0),2,8,0);
234
-            }
235
-            posTriangle[nbrTriangle].angle=calculAngle(&posTriangle[nbrTriangle]);
236
-
237
-            nbrTriangle++;
238
-
239
-        }
240
-    }
241
-    return nbrTriangle;
242
-}
243
-
244
-void draw_position(Image *imgInput, Image *imgOutput, Position *positionRobot) // img E/S   pos : E
245
-{
246
-    if(imgInput!=imgOutput)
247
-    {
248
-        *imgOutput=imgInput->clone();
249
-    }
250
-    line(*imgOutput,positionRobot->center,positionRobot->direction,Scalar(0,125,0),2,8,0);
251
-}
252
-
253
-float calculAngle(Position * positionRobot) // position en entree
254
-{
255
-    float a = positionRobot->direction.x - positionRobot->center.x;
256
-    float b = positionRobot->direction.y - positionRobot->center.y ;
257
-    float angle = atan2(b,a);
258
-    return angle * 180.f/M_PI;
259
-
260
-}

+ 0
- 140
software/raspberry/superviseur-robot/lib/image.h View File

@@ -1,140 +0,0 @@
1
-/*
2
- * Copyright (C) 2018 dimercur
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
- */
17
-
18
-#ifndef _IMAGE_H_
19
-#define _IMAGE_H_
20
-
21
-#ifndef __STUB__
22
-#ifndef __FOR_PC__
23
-#include <raspicam/raspicam_cv.h>
24
-#else
25
-#include <opencv2/highgui/highgui.hpp>
26
-#endif /* __FOR_PC__ */
27
-#else
28
-#include <opencv2/highgui/highgui.hpp>
29
-#endif
30
-#include "opencv2/imgproc/imgproc.hpp"
31
-#include <unistd.h>
32
-#include <math.h>
33
-
34
-#define WIDTH 480 //1280 1024 640 480
35
-#define HEIGHT 360 // 960 768 480 360
36
-
37
-using namespace std;
38
-using namespace cv;
39
-#ifndef __STUB__
40
-#ifndef __FOR_PC__
41
-using namespace raspicam;
42
-#endif /* __FOR_PC__ */
43
-#endif
44
-
45
-typedef Mat Image;
46
-#ifndef __STUB__
47
-#ifndef __FOR_PC__
48
-typedef RaspiCam_Cv Camera;
49
-#else
50
-typedef int Camera;
51
-#endif /* __FOR_PC__ */
52
-#else
53
-typedef int Camera;
54
-#endif
55
-
56
-typedef Rect Arene;
57
-typedef vector<unsigned char> Jpg;
58
-
59
-struct Position {
60
-    Point center;
61
-    Point direction;
62
-    float angle;
63
-};
64
-
65
-/**
66
- * \brief       Ouvre une camera.
67
- * \details     Met à jour le descripteur de fichier passé en paramètre pour correspondre à la camera ouverte
68
- *             
69
- * \param       camera  Pointeur d'un file descriptor d'une camera ouverte
70
- * \return      Retourne 0 si la camera a été ouverte correctement et -1 si une erreur survient.
71
- */
72
-int open_camera(Camera *camera);
73
-
74
-/**
75
- * \brief       Ferme la camera passé en paramètre
76
- *             
77
- * \param       camera  Pointeur sur la camera à fermer
78
- */
79
-void close_camera(Camera *camera);
80
-
81
-/**
82
- * \brief       Capture une image avec la camera passée en entrée. En cas de test sans camera, la fonction charge une image 
83
- * \details     La camera doit préalablement être ouverte via \a openCamera(...)
84
- *             
85
- * \param       camera      Pointeur sur la camera passée en entrée.
86
- * \param       monImage    Pointeur sur une image capturée. 
87
- * \param       fichier     Chemin du fichier d'image
88
- * \return      Retourne -1 si une erreur survient.
89
- */
90
-void get_image(Camera *camera, Image * monImage, const char *fichier = NULL);
91
-
92
-/**
93
- * \brief       Détecte une arène dans une image fournis en paramètre.
94
- *             
95
- * \param       monImage    Pointeur sur l'image d'entrée
96
- * \param       rectangle   Pointeur sur les coordonnées du rectangles trouvé. 
97
- * \return      Retourne -1 si aucune arène n'est détectée. Sinon retourne 0
98
- */
99
-int detect_arena(Image *monImage, Arene *rectangle);
100
-
101
-/**
102
- * \brief       Dessine le plus petit rectangle contenant l'arène
103
- 
104
- * \param       imgInput    Pointeur sur l'image d'entrée.
105
- * \param       imgOutput   Pointeur sur l'image de sortie (image d'entrée + arène marquée)
106
- * \param       monArene    Pointeur de type Arène contenant les information à dessiner
107
- */
108
-void draw_arena(Image *imgInput, Image *imgOutput, Arene *monArene);
109
-
110
-/**
111
- * \brief       Détecte la position d'un robot.
112
- * \details     Détecte la position de triangles blanc sur une image /a imgInput passé en paramètre d'entrer.
113
- *             
114
- * \param       imgInput    Pointeur sur l'image sur laquelle chercher la position du des robots.
115
- * \param       posTriangle Pointeur sur un tableau de position ou seront stocké les positions des triangles détectés.
116
- * \param       monArene    Pointeur de type Arène si nécessaire d'affiner la recherche (optionnel) 
117
- * \return      Le nombre de triangles détectés.
118
- */
119
-int detect_position(Image *imgInput, Position *posTriangle, Arene * monArene = NULL);
120
-
121
-/**
122
- * \brief       Dessine sur une image en entrée la position d'un robot et sa direction.
123
- * \details     Sauvegarde l'image des coordonnées passées par positionRobot superposée à l'image d'entrée sur imgOutput.
124
- *             
125
- * \param       imgInput         Pointeur sur l'image d'entrée
126
- * \param       imgOutput        Pointeur sur l'image de sortie ( image d'entrée + dessin de la position)
127
- * \param       positionRobot    Pointeur sur la structure position d'un robot.
128
- */
129
-void draw_position(Image *imgInput, Image *imgOutput, Position *positionRobot);
130
-
131
-/**
132
- * \brief       Détecte la position d'un robot.
133
- * \details     Détecte la position de triangles blanc sur une image /a imgInput passé en paramètre d'entrer.
134
- *             
135
- * \param       imgInput      	Pointeur sur l'image à sauvegarder en mémoire sous format jpg.
136
- * \param       imageCompress	Pointeur sur une image .jpg.
137
- */
138
-void compress_image(Image *imgInput, Jpg *imageCompress);
139
-
140
-#endif // _IMAGE_H_

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

@@ -17,23 +17,47 @@
17 17
 
18 18
 #include "img.h"
19 19
 
20
+/**
21
+ * Tell if arena is empty (not found) or not
22
+ * @return true if no arena found, false otherwise
23
+ */
20 24
 bool Arena::IsEmpty() {
21 25
     if ((this->arena.height == 0) || (this->arena.width == 0)) return true;
22 26
     else return false;
23 27
 }
24 28
 
29
+/**
30
+ * Create new Img object based on image data
31
+ * 
32
+ * @param imgMatrice Image data to be stored (raw data)
33
+ */
25 34
 Img::Img(ImageMat imgMatrice) {
26 35
     this->img = imgMatrice.clone();
27 36
 }
28 37
 
38
+/**
39
+ * Convert object to a string representation
40
+ * 
41
+ * @return String containing information on contained image (size and number of channel) 
42
+ */
29 43
 string Img::ToString() {
30 44
     return "Image size: " + to_string(this->img.cols) + "x" + to_string(this->img.rows) + " (dim=" + to_string(this->img.dims) + ")";
31 45
 }
32 46
 
47
+/**
48
+ * Create a copy of current object
49
+ * 
50
+ * @return New Img object, copy of current 
51
+ */
33 52
 Img* Img::Copy() {
34 53
     return new Img(this->img);
35 54
 }
36 55
 
56
+/**
57
+ * Function for computing angle 
58
+ * @param robots Position of robot
59
+ * @return Angle
60
+ */
37 61
 float Img::CalculAngle(Position robot) {
38 62
     float a = robot.direction.x - robot.center.x;
39 63
     float b = robot.direction.y - robot.center.y;
@@ -41,6 +65,12 @@ float Img::CalculAngle(Position robot) {
41 65
     return angle * 180.f / M_PI;
42 66
 }
43 67
 
68
+/**
69
+ * Function for computing angle 
70
+ * @param pt1 ???
71
+ * @param pt2 ???
72
+ * @return Angle
73
+ */
44 74
 float Img::CalculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
45 75
     float a = pt1.x - pt2.x;
46 76
     float b = pt1.y - pt2.y;
@@ -50,21 +80,59 @@ float Img::CalculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
50 80
 
51 81
 #ifdef __WITH_ARUCO__ 
52 82
 
83
+/**
84
+ * Find center point of given aruco
85
+ * @param aruco Aruco coordinates
86
+ * @return Center point coordinate
87
+ */
53 88
 cv::Point2f Img::FindArucoCenter(std::vector<cv::Point2f> aruco) {
54 89
     return ((aruco[0] + aruco[2]) / 2);
55 90
 }
56 91
 
92
+/**
93
+ * Find direction of given aruco
94
+ * @param aruco Aruco coordinates
95
+ * @return Orientation of aruco
96
+ */
57 97
 cv::Point2f Img::FindArucoDirection(std::vector<cv::Point2f> aruco) {
58 98
     return ((aruco[0] + aruco[1]) / 2);
59 99
 }
100
+#endif // __WITH_ARUCO__
101
+
102
+/**
103
+ * Used for computing distance
104
+ * @param p ???
105
+ * @param q ???
106
+ * @return Distance
107
+ */
108
+float Img::EuclideanDistance(cv::Point2f p, cv::Point2f q) {
109
+    cv::Point diff = p - q;
110
+    return cv::sqrt(diff.x * diff.x + diff.y * diff.y);
111
+}
60 112
 
61
-std::list<Position> Img::SearchAruco(Arena arena) {
113
+/**
114
+ * Compress current image to JPEG
115
+ * @return Image compressed as JPEG
116
+ */
117
+Jpg Img::ToJpg() {
118
+    Jpg imgJpg;
119
+    cv::imencode(".jpg", this->img, imgJpg);
120
+    return imgJpg;
121
+}
122
+
123
+/**
124
+ * Search available robots in an image
125
+ * @param arena Arena position for cropping image
126
+ * @return list of position, empty if no robot found
127
+ */
128
+std::list<Position> Img::SearchRobot(Arena arena) {
129
+#ifdef __WITH_ARUCO__
62 130
     ImageMat imgTraitment;
63 131
     std::list<Position> positionList;
64 132
     cv::Point2f areneCoor;
65 133
     std::vector<int> ids;
66 134
     std::vector<std::vector<cv::Point2f> > corners;
67
-    
135
+
68 136
     if (arena.IsEmpty())
69 137
         imgTraitment = this->img.clone();
70 138
     else {
@@ -72,7 +140,7 @@ std::list<Position> Img::SearchAruco(Arena arena) {
72 140
         areneCoor.x = arena.arena.x;
73 141
         areneCoor.y = arena.arena.y;
74 142
     }
75
-    
143
+
76 144
     cv::aruco::detectMarkers(imgTraitment, dictionary, corners, ids);
77 145
     if (ids.size() > 0) {
78 146
         for (int i = 0; i < ids.size(); i++) {
@@ -89,22 +157,7 @@ std::list<Position> Img::SearchAruco(Arena arena) {
89 157
         }
90 158
     }
91 159
     return positionList;
92
-}
93
-#endif // __WITH_ARUCO__
94
-
95
-float Img::EuclideanDistance(cv::Point2f p, cv::Point2f q) {
96
-    cv::Point diff = p - q;
97
-    return cv::sqrt(diff.x * diff.x + diff.y * diff.y);
98
-}
99
-
100
-Jpg Img::ToJpg() {
101
-    Jpg imgJpg;
102
-    cv::imencode(".jpg", this->img, imgJpg);
103
-    return imgJpg;
104
-}
105
-
106
-std::list<Position> Img::SearchRobot(Arena arena) {
107
-
160
+#else
108 161
     std::list<Position> robotsFind;
109 162
     std::vector<std::vector<cv::Point> > contours;
110 163
     std::vector<cv::Point> approx;
@@ -168,8 +221,14 @@ std::list<Position> Img::SearchRobot(Arena arena) {
168 221
     }
169 222
 
170 223
     return robotsFind;
224
+
225
+#endif // __WITH_ARUCO__
171 226
 }
172 227
 
228
+/**
229
+ * Search arena outline in current image
230
+ * @return Arena object with coordinate of outline, empty if no arena found
231
+ */
173 232
 Arena Img::SearchArena() {
174 233
     std::vector<std::vector<cv::Point> > contours;
175 234
     std::vector<cv::Point> approx;
@@ -189,26 +248,44 @@ Arena Img::SearchArena() {
189 248
             return rectangle;
190 249
         }
191 250
     }
251
+
192 252
     return Arena();
193 253
 }
194 254
 
195
-int Img::DrawRobot(Position robot) {
255
+/**
256
+ * Draw an oriented arrow at robot position
257
+ * @param robot Position of robot
258
+ */
259
+void Img::DrawRobot(Position robot) {
196 260
     cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0, 0, 255), 3, 8, 0);
197
-    return 0;
198 261
 }
199 262
 
263
+/**
264
+ * Draw an oriented arrow for each position provided
265
+ * @param robots List of robot positions
266
+ * @return Number of position drawn
267
+ */
200 268
 int Img::DrawAllRobots(std::list<Position> robots) {
201 269
     for (Position robot : robots) {
202 270
         cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0, 0, 255), 3, 8, 0);
203 271
     }
272
+
204 273
     return robots.size();
205 274
 }
206 275
 
207
-int Img::DrawArena(Arena arenaToDraw) {
276
+/**
277
+ * Draw arena outline
278
+ * @param arenaToDraw Arena position
279
+ */
280
+void Img::DrawArena(Arena arenaToDraw) {
208 281
     cv::rectangle(this->img, arenaToDraw.arena.tl(), arenaToDraw.arena.br(), cv::Scalar(0, 0, 125), 2, 8, 0);
209
-    return 0;
210 282
 }
211 283
 
284
+/**
285
+ * Crop image around detected arena
286
+ * @param arena Coordinate of arena
287
+ * @return Reduced image, focused on arena
288
+ */
212 289
 ImageMat Img::CropArena(Arena arena) {
213 290
     return this->img(arena.arena);
214 291
 }

+ 124
- 7
software/raspberry/superviseur-robot/lib/img.h View File

@@ -29,64 +29,181 @@
29 29
 #ifdef __WITH_ARUCO__
30 30
 #include <opencv2/aruco/dictionary.hpp>
31 31
 #include <opencv2/aruco/charuco.hpp>
32
-//#include <opencv2/aruco.hpp>
33 32
 #include <opencv2/core/mat.hpp>
34
-
35 33
 #endif // __WITH_ARUCO__
36 34
 
37 35
 #define ARENA_NOT_DETECTED -1
38 36
 
39 37
 using namespace std;
40 38
 
39
+/**
40
+ * Redefinition of cv::Mat type
41
+ */
41 42
 typedef cv::Mat ImageMat;
42 43
 
44
+/**
45
+ * Declaration of Jpg type
46
+ */
43 47
 typedef vector<unsigned char> Jpg;
44 48
 
49
+/**
50
+ * Position type used for store robot coordinates
51
+ * 
52