]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
To get actual team color structure orte.robot_switches needs to be used (instead...
authorPetr Kubiznak <kubizpet@fel.cvut.cz>
Fri, 28 May 2010 10:41:45 +0000 (12:41 +0200)
committerPetr Kubiznak <kubizpet@fel.cvut.cz>
Fri, 28 May 2010 10:41:45 +0000 (12:41 +0200)
src/camera/rozkuk/rozkuk.cxx
src/types/robottype.idl

index a3272b55a9593f74ef0469c4d99d9017e96fd115..3e5dc6d68c52d164efd6b911ecfdae09495d93cf 100644 (file)
@@ -31,6 +31,8 @@ extern "C" {
 
 // uncomment next line to "log" the output frames - save them as pnm to the working directory
 //#define PPC_DEBUG
+// uncomment next line to print orte state
+#define ORTE_DEBUG
 
 // modes definitions
 #define MODE_QUIT         0x01
@@ -289,7 +291,7 @@ int modeRecognize(CvCapture* capture, CORBA_octet currentColor) {
        while(ORTE_CAMERA_CONTROL) {
        
                //if color changed during recognition, restart the mode to load appropriate masks
-               if(orte.camera_control.game_color != currentColor) return MODE_RECOGNIZE;
+               if(orte.robot_switches.team_color != currentColor) return MODE_RECOGNIZE;
 
 #ifdef ROZKUK_DEBUG       /************ DEBUG SESSION ONLY ************/
                /* keyboard events handeling */
@@ -464,7 +466,7 @@ int modeManager(int defaultMode) {
                        cvMoveWindow(WINDOW_PROD, cvQueryFrame(capture)->width, cvQueryFrame(capture)->height+50);
 #endif                    /*----------- DEBUG SESSION ONLY -----------*/
                        //load masks and run recognition mode, then free masks (they are in memory only while in recognition mode)
-                       color = orte.camera_control.game_color;
+                       color = orte.robot_switches.team_color;
                        if((ret=loadMasks((color==BLUE ? clBLUE : clYELLOW)))) return ret;
                        mode = modeRecognize(capture, color);
                        freeMasks();
@@ -589,11 +591,31 @@ void rcv_cmr_ctrl_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBa
                case NEW_DATA:
                        // nothing to do - changes will be processed in the recognition loop
 #ifdef ORTE_DEBUG
-                       printf("orte: New data: ctrl %d, clr %d\n", orte_data->camera_control.on, orte_data->camera_control.game_color);
+                       fprintf(stderr, "orte: New camera data: ctrl %d", orte_data->camera_control.on);
 #endif /*----------- ORTE_DEBUG -----------*/
                        break;
                case DEADLINE:
-                       printf("ORTE deadline occurred - CMR_CTRL receive\n");
+                       fprintf(stderr, "ORTE deadline occurred - CMR_CTRL receive\n");
+                       break;
+       }
+}
+
+/******************************************************************************/
+
+/** Orte switches control callback function. */
+void rcv_robot_switches_cb(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam) {
+#ifdef ORTE_DEBUG
+       struct robot_switches_type *instance = (struct robot_switches_type *)vinstance;
+#endif /*----------- ORTE_DEBUG -----------*/
+
+       switch (info->status) {
+               case NEW_DATA:
+                       // nothing to do - changes will be processed in the recognition loop
+#ifdef ORTE_DEBUG
+                       fprintf(stderr, "orte: New switches data: clr %d", instance->team_color);
+#endif /*----------- ORTE_DEBUG -----------*/
+               case DEADLINE:
+                       fprintf(stderr, "ORTE deadline occurred - CMR_CTRL receive\n");
                        break;
        }
 }
@@ -610,6 +632,7 @@ int main(int argc, char *argv[]) {
        }
        robottype_publisher_camera_result_create(&orte, NULL, NULL);
        robottype_subscriber_camera_control_create(&orte, rcv_cmr_ctrl_cb, &orte);
+       robottype_subscriber_robot_switches_create(&orte, rcv_robot_switches_cb, &orte);
        
        modeManager(START_MODE);
 
index c1f5cba246b47ad825988951c92ae37c88332ba6..768a60cbc4e0f85cea0a126122cec53d4ef34a72 100644 (file)
@@ -110,7 +110,6 @@ struct fsm_state {
 module camera {
        struct control {
                boolean on;
-               octet game_color;
        };
 
        typedef octet error;