navigation updated with completed dijkstra's algo

Dependents:   R5 2016 Robotics Team 1

Revision:
2:17bd430aeca1
Parent:
1:a53d97b74fab
Child:
4:a5d44517c65c
diff -r a53d97b74fab -r 17bd430aeca1 navigation.h
--- a/navigation.h	Sun Nov 22 19:32:45 2015 +0000
+++ b/navigation.h	Wed Jan 27 20:48:42 2016 +0000
@@ -1,6 +1,6 @@
 #ifndef NAVIGATION_H
 #define NAVIGATION_H
-#include "StepperMotor.h"
+#include "StepperDrive.h"
 #include "stdint.h"
 #include "mbed.h"
 #include <vector>
@@ -10,46 +10,48 @@
 {
 public:
     Navigation(int size);
-    void addGraphNode(uint16_t src, uint16_t target, uint16_t dist,
-                      uint16_t angle);
+    void addGraphNode(uint16_t src, uint16_t target, float dist,
+                      float angle);
     void addGraphNode(uint16_t src);
     int graphSize() { return graph.size(); }
     uint16_t getVertex() { return vertex; }
-    uint16_t getAngle() { return angle; }
+    float getAngle() { return angle; }
     void setVertex(uint16_t target) { vertex = target; }
+    void setAngle(float target) { angle = target; }
     int numNeighbors(int src) { return graph[src].size(); }
     int loadMap(char* inputFile);
     void getShortestPath(uint16_t destination);
-    uint16_t getMinDist(uint16_t target) { return minDistance[target]; }
-    void executeRoute(StepperMotor &leftMotor, StepperMotor &rightMotor);
+    void executeRoute(Serial &pc, StepperDrive &drive);
     // utility functions
+    uint16_t getMinDist(float target) { return minDistance[target]; }
     void printPrevious(Serial &pc);
     void printRoute(Serial &pc);
     void printGraph(Serial &pc);
 
 private:
-    static const uint16_t MAX_DIST = 65535; // infinity
+    static const float MAX_DIST = 65535; // infinity
     static const uint16_t DEFAULT_VERTEX = 0;
-    static const uint16_t DEFAULT_ANGLE = 0;
+    static const float DEFAULT_ANGLE = 0.0;
     static const int DEFAULT_SIZE = 1;
-    static const int STEPS_PER_INCH = 20; //  per wheel diameter and stepper specs
+    //static const int STEPS_PER_INCH = 20; //  per wheel diameter and stepper specs
+    static const float PI = 3.14159;
 
     uint16_t vertex; // current vertex
-    uint16_t angle; // current angle
+    float angle; // current angle
 
     struct graphNode
     {
         uint16_t neighbor;
-        uint16_t distance; // in inches
-        uint16_t angle;
-        graphNode(uint16_t arg_neighbor = MAX_DIST,
-                  uint16_t arg_distance = MAX_DIST,
-                  uint16_t arg_angle = MAX_DIST)
+        float distance; // in inches
+        float angle;
+        graphNode(float arg_neighbor = MAX_DIST,
+                  float arg_distance = MAX_DIST,
+                  float arg_angle = MAX_DIST)
            : neighbor(arg_neighbor), distance(arg_distance), angle(arg_angle){}
     };
 
     std::vector<std::vector<graphNode> > graph;
-    std::vector<uint16_t> minDistance;
+    std::vector<float> minDistance;
     std::vector<int> previous;
     std::stack<uint16_t> route;
 };