Final Project files for mBed development.

Dependencies:   m3pi mbed

Files at this revision

API Documentation at this revision

Comitter:
alecguertin
Date:
Mon Dec 01 01:02:42 2014 +0000
Parent:
17:c72c092fcdf7
Child:
19:47759cf4f9b9
Commit message:
added logic to calculate angle to drive at -- untested

Changed in this revision

main.c Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.c	Mon Dec 01 00:41:04 2014 +0000
+++ b/main.c	Mon Dec 01 01:02:42 2014 +0000
@@ -189,9 +189,12 @@
     // Main program loop.
     // robot_loop();
     size_t bytes_read = 0;
-    int err, x, y, last_x, last_y;
+    int err, x, y, last_x, last_y, delta_x, delta_y;
     int offset = 0;
     char *cur, *next;
+    float angle, theta;
+    angle = 0;
+    theta = 0;
     ps_file = fopen("/local/test.ps", "r");
     /* PS parsing loop. */
     while (1) {
@@ -203,7 +206,11 @@
         cur = instbuf;
         while (cur[0] != '\0') {
             err = retrieve_inst(instbuf, &x, &y, &draw);
-            move(x, y, draw);
+            delta_x = x-last_x;
+            delta_y = y-last_y;
+            theta = tan(delta_x/delta_y);
+            theta *= 57.2957795;
+            delta_a = theta-angle;
             last_x = x;
             last_y = y;
             next = strchr(cur, '\n');
@@ -217,6 +224,8 @@
     }
     //
     // We should never reach this point!
+    //
+    // Yes, we should...
     return 0;
 }
 
--- a/main.h	Mon Dec 01 00:41:04 2014 +0000
+++ b/main.h	Mon Dec 01 01:02:42 2014 +0000
@@ -19,6 +19,13 @@
 #define ERR_FAILURE 1
 #define DRIVE_RATE  1/50
 
+
+/**
+ * @brief   move the robot from its current position to (x,y)
+ *
+ */
+void move(int x, int y, int draw);
+
 /**
  * @brief get values of next PostScript instruction.
  *