Sébastien DI MERCURIO 5 years ago
parent
commit
0ac343ee95

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

22
 using namespace cv;
22
 using namespace cv;
23
 
23
 
24
 /**
24
 /**
25
+ * Create an object for accessing camera with default values (size = sm and 
26
+ * fps = 10)
27
+ */
28
+Camera::Camera():Camera(sm, 10){
29
+}
30
+
31
+/**
25
  * Create an object for accessing camera
32
  * Create an object for accessing camera
26
  * @param size Size of picture to grab (@see captureSize)
33
  * @param size Size of picture to grab (@see captureSize)
27
  * @param fps speed of sampling
34
  * @param fps speed of sampling

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

35
  * Class for camera (image grab)
35
  * Class for camera (image grab)
36
  * 
36
  * 
37
  * @brief Class for camera (image grab)
37
  * @brief Class for camera (image grab)
38
+ * How to grab an image and send it to the monitor:
39
+ *  1. Grab an image, for example:
40
+ *          Img * img = new Img(cam->Grab());
41
+ *  2. Instanciate the message to send the image:
42
+ *          MessageImg *msgImg = new MessageImg(MESSAGE_CAM_IMAGE, img);
38
  */
43
  */
39
 class Camera {
44
 class Camera {
40
 public:
45
 public:
46
+    Camera();
47
+    
41
     /**
48
     /**
42
      * Create an object for accessing camera
49
      * Create an object for accessing camera
43
      * @param size Size of picture to grab (@see captureSize)
50
      * @param size Size of picture to grab (@see captureSize)

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

131
 }
131
 }
132
 
132
 
133
 /**
133
 /**
134
- * Get message ID
134
+ * Check message ID
135
  * @return Current message ID
135
  * @return Current message ID
136
  */
136
  */
137
 bool Message::CheckID(MessageID id) {
137
 bool Message::CheckID(MessageID id) {
162
  */
162
  */
163
 MessageInt::MessageInt(MessageID id, int val) {
163
 MessageInt::MessageInt(MessageID id, int val) {
164
     MessageInt::SetID(id);
164
     MessageInt::SetID(id);
165
-
166
     value = val;
165
     value = val;
167
 }
166
 }
168
 
167
 
282
  * Create a new, empty image message
281
  * Create a new, empty image message
283
  */
282
  */
284
 MessageImg::MessageImg() {
283
 MessageImg::MessageImg() {
284
+    this->messageID = MESSAGE_CAM_IMAGE;
285
     image = NULL;
285
     image = NULL;
286
 }
286
 }
287
 
287
 
362
  * Create a new, empty battery message
362
  * Create a new, empty battery message
363
  */
363
  */
364
 MessageBattery::MessageBattery() {
364
 MessageBattery::MessageBattery() {
365
+    this->messageID = MESSAGE_ROBOT_BATTERY_LEVEL;
365
     this->level = BATTERY_UNKNOWN;
366
     this->level = BATTERY_UNKNOWN;
366
 }
367
 }
367
 
368
 
455
 /* class MessagePosition */
456
 /* class MessagePosition */
456
 
457
 
457
 /**
458
 /**
458
- * Create a new, empty string message
459
+ * Create a new, empty position message
459
  */
460
  */
460
 MessagePosition::MessagePosition() {
461
 MessagePosition::MessagePosition() {
462
+    this->messageID = MESSAGE_CAM_POSITION;
461
     this->pos.angle = 0.0;
463
     this->pos.angle = 0.0;
462
     this->pos.robotId = 0;
464
     this->pos.robotId = 0;
463
     this->pos.center.x=0.0;
465
     this->pos.center.x=0.0;
467
 }
469
 }
468
 
470
 
469
 /**
471
 /**
470
- * Create a new string message, with given ID and string
472
+ * Create a new position message, with given ID and position
471
  * @param id Message ID
473
  * @param id Message ID
472
- * @param s Message string
474
+ * @param pos Message position
473
  * @throw std::runtime_error if message ID is incompatible with string data
475
  * @throw std::runtime_error if message ID is incompatible with string data
474
  */
476
  */
475
 MessagePosition::MessagePosition(MessageID id, Position& pos) {
477
 MessagePosition::MessagePosition(MessageID id, Position& pos) {

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

47
     MESSAGE_ROBOT_COM_OPEN,
47
     MESSAGE_ROBOT_COM_OPEN,
48
     MESSAGE_ROBOT_COM_CLOSE,
48
     MESSAGE_ROBOT_COM_CLOSE,
49
          
49
          
50
-    // Messages for camera   
50
+    // Messages for camera from Monitor to Supervisor
51
     MESSAGE_CAM_OPEN,
51
     MESSAGE_CAM_OPEN,
52
     MESSAGE_CAM_CLOSE,
52
     MESSAGE_CAM_CLOSE,
53
     MESSAGE_CAM_ASK_ARENA,
53
     MESSAGE_CAM_ASK_ARENA,
55
     MESSAGE_CAM_ARENA_INFIRM,
55
     MESSAGE_CAM_ARENA_INFIRM,
56
     MESSAGE_CAM_POSITION_COMPUTE_START,
56
     MESSAGE_CAM_POSITION_COMPUTE_START,
57
     MESSAGE_CAM_POSITION_COMPUTE_STOP,
57
     MESSAGE_CAM_POSITION_COMPUTE_STOP,
58
+            
59
+    // Messages for camera from Supervisor to Monitor 
58
     MESSAGE_CAM_POSITION,
60
     MESSAGE_CAM_POSITION,
59
     MESSAGE_CAM_IMAGE,
61
     MESSAGE_CAM_IMAGE,
60
             
62
             
499
  * Message class for holding battery level, based on Message class
501
  * Message class for holding battery level, based on Message class
500
  * 
502
  * 
501
  * @brief Battery message class
503
  * @brief Battery message class
502
- * 
504
+ * How to use:
505
+ *  1. Ask the battery level to the robot:
506
+ *      MessageBattery * msg;
507
+ *      msg = (MessageBattery*)robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET));
508
+ *  2. Send the message, for example:
509
+ *          monitor.send(msg);
510
+ *      or
511
+ *          WriteInQueue(&q_messageToMon, msg);
503
  */
512
  */
504
 class MessageBattery : public Message {
513
 class MessageBattery : public Message {
505
 public:
514
 public:

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

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

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

7
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
7
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
8
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
8
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
9
         <group>
9
         <group>
10
-            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/main.cpp</file>
10
+            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.h</file>
11
+            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.cpp</file>
11
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.h</file>
12
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.h</file>
13
+            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.cpp</file>
12
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
14
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
13
-            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</file>
14
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.h</file>
15
             <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.h</file>
15
-            <file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</file>
16
         </group>
16
         </group>
17
     </open-files>
17
     </open-files>
18
 </project-private>
18
 </project-private>

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

64
     /**********************************************************************/
64
     /**********************************************************************/
65
     ComMonitor monitor;
65
     ComMonitor monitor;
66
     ComRobot robot;
66
     ComRobot robot;
67
-    int robotStarted;
67
+    int robotStarted = 0;
68
     int move = MESSAGE_ROBOT_STOP;
68
     int move = MESSAGE_ROBOT_STOP;
69
     
69
     
70
     /**********************************************************************/
70
     /**********************************************************************/

Loading…
Cancel
Save