]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
rozkuk: Let it work with orte (partially)
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Apr 2010 14:55:20 +0000 (16:55 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 22 Apr 2010 14:55:20 +0000 (16:55 +0200)
src/camera/rozkuk/rozkuk.cxx
src/types/robottype.idl

index 2f9215d4ce1038b698399297be9748157f77e809..53b46e5e779e93469c3a5231b98e2c8d69583f0e 100644 (file)
@@ -8,7 +8,6 @@
  * 
  ******************************************************************************/
 
-extern "C" {
 #include <inttypes.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -17,16 +16,14 @@ extern "C" {
 #include <getopt.h>
 #include <unistd.h>
 
-#include <orte.h>
-//#include "roboorte.h"
-//#include "rozkorte.h"
-}
-
 #include <opencv/cv.h>
 #include <opencv/highgui.h>
 
 #include "clr2float.h"
 
+extern "C" {
+#include <roboorte_robottype.h>
+}
 /******************************************************************************/
 
 // modes definitions
@@ -85,6 +82,8 @@ extern "C" {
 #define FRAME_HEIGHT                   480
 #define FRAME_SIZE                             (FRAME_WIDTH * FRAME_HEIGHT)
 
+struct robottype_orte_data orte;
+    
 /******************************************************************************/
 
 // function declarations
@@ -273,6 +272,10 @@ int modeRecognize(CvCapture* capture) {
        clr2float(frame, &floatMat, threshold, SATURATION, thresFrame); // get float representation (in DEBUG session, thresholded image is stored to thresFrame)
        layout = recognize(floatMat);
                printf("var: %d, thr: %d\n", layout, threshold);
+               orte.camera_result.side = layout;
+               orte.camera_result.center = layout; // FIXME
+               ORTEPublicationSend(orte.publication_camera_result);
+               
 #ifdef ROZKUK_DEBUG                            /************ DEBUG SESSION ONLY ************/
        displayProduct(floatMat, layout);
 #endif                                                                         /*----------- DEBUG SESSION ONLY -----------*/
@@ -331,8 +334,11 @@ int modeManager(int defaultMode) {
                cvNamedWindow(WINDOW_PROD, CV_WINDOW_AUTOSIZE);
                cvMoveWindow(WINDOW_PROD, cvQueryFrame(capture)->width, cvQueryFrame(capture)->height+50);
 #endif                                                                         /*----------- DEBUG SESSION ONLY -----------*/
-               mode = modeRecognize(capture);
-               break;
+               //if (orte.camera_control.on) 
+                   mode = modeRecognize(capture);
+//             else
+//                 sleep(1);
+//             break;
 
        default:
                goto end;                       // jump out of the loop
@@ -428,14 +434,22 @@ void freeMasks(void) {
 
 int main(int argc, char *argv[]) {
        int ret;
-/*  while (orte_init()) {
-    perror("orte_init");
-    usleep(500*1000);
-  }
-*/
+
+       ret = robottype_roboorte_init(&orte);
+       if (ret < 0) {
+           fprintf(stderr, "robottype_roboorte_init failed\n");
+           return ret;
+       }
+       robottype_publisher_camera_result_create(&orte, NULL, NULL);
+       robottype_subscriber_camera_control_create(&orte, NULL, NULL);
+
+       
        if((ret=loadMasks())) return ret;
        ret = modeManager(START_MODE);
        freeMasks();
+
+       ret = robottype_roboorte_destroy(&orte);
+       
        return ret;
 }
 
index 01ba68947433fb410b3f8b9fd66fc97f9f1525b9..a80e4b093cb05af05e8f8f7ac174b47e66f9b668 100644 (file)
@@ -95,15 +95,14 @@ struct fsm_state {
        char state_name[21];
 };
 
-// FIXME: obsolete, update (?):
 struct camera_control {
     boolean on;
     octet game_color;
 };
 
-// FIXME: obsolete, update:
 struct camera_result {
-    octet lot;
+    octet side;
+    octet center;
 };
 
 struct puck_inside {