Browse Source

update lib

pehladik 5 years ago
parent
commit
cc84086479

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

@@ -22,6 +22,13 @@
22 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 32
  * Create an object for accessing camera
26 33
  * @param size Size of picture to grab (@see captureSize)
27 34
  * @param fps speed of sampling

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

@@ -35,9 +35,16 @@ enum captureSize {xs, sm, md, lg};
35 35
  * Class for camera (image grab)
36 36
  * 
37 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 44
 class Camera {
40 45
 public:
46
+    Camera();
47
+    
41 48
     /**
42 49
      * Create an object for accessing camera
43 50
      * @param size Size of picture to grab (@see captureSize)

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

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

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

@@ -47,7 +47,7 @@ typedef enum {
47 47
     MESSAGE_ROBOT_COM_OPEN,
48 48
     MESSAGE_ROBOT_COM_CLOSE,
49 49
          
50
-    // Messages for camera   
50
+    // Messages for camera from Monitor to Supervisor
51 51
     MESSAGE_CAM_OPEN,
52 52
     MESSAGE_CAM_CLOSE,
53 53
     MESSAGE_CAM_ASK_ARENA,
@@ -55,6 +55,8 @@ typedef enum {
55 55
     MESSAGE_CAM_ARENA_INFIRM,
56 56
     MESSAGE_CAM_POSITION_COMPUTE_START,
57 57
     MESSAGE_CAM_POSITION_COMPUTE_STOP,
58
+            
59
+    // Messages for camera from Supervisor to Monitor 
58 60
     MESSAGE_CAM_POSITION,
59 61
     MESSAGE_CAM_IMAGE,
60 62
             
@@ -499,7 +501,14 @@ protected:
499 501
  * Message class for holding battery level, based on Message class
500 502
  * 
501 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 513
 class MessageBattery : public Message {
505 514
 public:

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

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

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

@@ -7,12 +7,12 @@
7 7
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
8 8
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
9 9
         <group>
10
-            <file>file:/home_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 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 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 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 16
         </group>
17 17
     </open-files>
18 18
 </project-private>

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

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

Loading…
Cancel
Save