]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
camera/color-finder: add angle
authorMonika Svedirohova <svedimon@fel.cvut.cz>
Thu, 4 Oct 2012 20:13:15 +0000 (22:13 +0200)
committerMonika Svedirohova <svedimon@fel.cvut.cz>
Thu, 4 Oct 2012 20:13:15 +0000 (22:13 +0200)
src/camera/color-finder/control/CRecognition.cpp
src/camera/color-finder/control/CRecognition.h
src/camera/color-finder/main/revue.cpp
src/types/robottype.idl

index 1bbb260b2324d7d20787934daac4ce461a3f92e2..c0234a2509dac58371b045305a2761b1d648fa88 100644 (file)
@@ -1,9 +1,11 @@
 #include <CRecognition.h>
+#include <math.h>
 
 #define min(a,b) ((a) < (b) ? (a) : (b))
 #define max(a,b) ((a) > (b) ? (a) : (b))
 
 bool white = false;
+
 //Vymazani promennych a jejich nastaveni na pocatecni hodnoty
 CRecognition::CRecognition()
 {
@@ -222,7 +224,8 @@ SPixelPosition CRecognition::findSegment(CRawImage* image)
                result.x = segmentArray[index].x;
                result.y = segmentArray[index].y;
                result.info = true;
-               //fprintf(stdout,"xy = %i %i\n", result.x, result.y);
+               result.uhel = ((atan2(result.x - 320 , result.y - 240)-M_PI/2)*180)/ M_PI;
+               //fprintf(stdout,"xyu = %i %i %lf \n", result.x, result.y, result.uhel);
        } 
 
        //vykreslime vysledek
index 7d858fe85f49518ce42c843f98c8abdf32b07669..c97c7410f26df97ff27aa38707850f3cd6433bc1 100644 (file)
@@ -21,6 +21,7 @@ typedef struct{
        int x;
        int y;
         bool info;
+       double uhel;
 }SPixelPosition;
 
 class CRecognition
index c16d58f38e7d444f39aa7bea7743c42d70f34776..ad6918d9efbc3e5da43e3b936d3e003bfbf148d3 100644 (file)
@@ -111,9 +111,10 @@ void send_data(SPixelPosition pos)
         orte.camera_result.y = pos.y;
         orte.camera_result.target_valid = pos.info; // OK / NOTĀ OK
         orte.camera_result.data_valid = data;
+       orte.camera_result.angle_deg = pos.uhel;
 
         ORTEPublicationSend(orte.publication_camera_result);
-        fprintf(stderr, "ORTE: x: %d y: %d, info: %d \n", pos.x, pos.y, pos.info);
+        fprintf(stderr, "ORTE: x: %d y: %d, info: %d uhel: %lf data_valid: %d \n", pos.x, pos.y, pos.info, pos.uhel, data);
 }
 
 /* Fce pro zapnuti a vypnuti rozpoznavani */
index eae458802c6d4f2f3f83d104a3317f1ae86ee3ab..8133653ed335af52d4be7d10d4eb11d49b2a43ac 100644 (file)
@@ -160,6 +160,7 @@ module camera {
        struct result {
                 octet x;
                 octet y;
+               double angle_deg;
 
                 boolean data_valid;
                 boolean target_valid;