Gruppe 3 / Mbed 2 deprecated PES1

Dependencies:   Servo mbed pixy

Fork of PES by Gruppe 3

Files at this revision

API Documentation at this revision

Comitter:
Shukle
Date:
Wed Apr 19 10:13:52 2017 +0000
Parent:
9:d9e46f9c9e40
Child:
11:7c5598781280
Commit message:
readCamera hinzugef?gt

Changed in this revision

Roboter.h Show annotated file Show diff for this revision Revisions of this file
pixy.lib Show annotated file Show diff for this revision Revisions of this file
readCamera.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Roboter.h	Wed Apr 19 10:07:55 2017 +0000
+++ b/Roboter.h	Wed Apr 19 10:13:52 2017 +0000
@@ -4,7 +4,7 @@
 #include <mbed.h>
 #include "IRSensor.h"
 #include "Servo.h"
-#include "Kamera.h"
+#include "readCamera.h"
 
 class Roboter
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pixy.lib	Wed Apr 19 10:13:52 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/PES-2/code/pixy/#b0a6783fb615
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/readCamera.cpp	Wed Apr 19 10:13:52 2017 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "Pixy.h"
+
+Pixy pixy(I2C_SDA, I2C_SCL);
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+static int i = 0;
+static int k = 0;
+static int range = 1;           // 1: fährt strahl an, 2: fährt kegel an
+static int state = 0;
+int j;
+uint16_t blocks;
+
+
+int main()
+{
+    pixy.setSerialOutput(&pc);
+
+    while (1) {
+        blocks = pixy.getBlocks(1);
+
+        if (blocks) {
+            i++;
+            if (i % 5 == 0) {
+                for (j = 0; j < blocks; j++) {
+                    int xAxis = pixy.blocks[j].x;
+                    int yAxis = pixy.blocks[j].y;
+                    //printf("%d, %d\n\r", xAxis, yAxis);
+                    
+                     
+        
+                    // soll drehen bis in stahl, fahren bis kegel, 25 pixel links rechts kegel
+                    if(xAxis < 185 && xAxis > 135  &&  yAxis > 155 && yAxis < 190 ) {              // wenn Klotz an Position zum aufnehmen
+                        state = 4;
+                        range = 1;
+                    } else {
+                        if (range == 1){         // fährt Strahl an
+                            if (xAxis < 155){
+                                state = 1;
+                            } else if (xAxis > 165){
+                                state = 2;
+                            } else{   // fährt gerade
+                                state = 3;
+                                range = 2;
+                            }
+                        } else {                // fährt solange bis Kegelrand
+                            if (xAxis > 185 || xAxis < 135) {
+                                range = 1;
+                            }
+                        }
+                    }
+                    
+                    
+                    
+                }
+                k=0;
+            }
+        } else{
+            k++;
+            if (k % 20 == 0) {
+                i=0;
+                state = 0;
+            }
+        }
+        printf("%d\n\r",state);
+        //return state;
+    }
+}
\ No newline at end of file