Roving robot using the RS-EDP.

Dependencies:   mbed RSEDP_AM_MC1_lib SDFileSystem

Revision:
1:ffef6386027b
Parent:
0:8d15dc761944
--- a/Rover.h	Mon Aug 16 09:46:28 2010 +0000
+++ b/Rover.h	Thu Aug 26 14:41:08 2010 +0000
@@ -39,7 +39,7 @@
  * ---------------
  *
  * The set up assumes the H-bridge being used has pins for:
- * 
+ *
  * - PWM input
  * - Brake
  * - Direction
@@ -68,6 +68,7 @@
 #include "PID.h"
 #include "IMU.h"
 #include "SDFileSystem.h"
+#include "HMC6352.h"
 
 /**
  * Defines
@@ -81,6 +82,9 @@
 #define REVS_PER_ROTATION     (ROTATION_DISTANCE / WHEEL_DIAMETER)
 #define PULSES_PER_ROTATION   (REVS_PER_ROTATION * PULSES_PER_REV)
 #define PULSES_PER_MM         (PULSES_PER_REV / WHEEL_DIAMETER)
+#define DISTANCE_PER_PULSE    (WHEEL_DIAMETER / PULSES_PER_REV)
+#define ENCODING              2 //Use X2 encoding
+#define WHEEL_DISTANCE        (ROTATION_DISTANCE / DISTANCE_PER_PULSE)
 //-----
 // PID
 //-----
@@ -96,13 +100,13 @@
 //---------
 // Logging
 //---------
-#define LOG_RATE     0.01
+#define LOG_RATE     0.025
 //-----
 // IMU
 //-----
 #define ACCELEROMETER_RATE 0.005
 #define GYROSCOPE_RATE     0.005
-#define IMU_RATE           0.025
+#define IMU_RATE_          0.025
 #define GYRO_MEAS_ERROR    0.3
 
 class Rover {
@@ -175,12 +179,17 @@
      * +ve distance -> forward
      * -ve distance -> backward
      *
-     * @param distance The distance to move.
+     * @param distance The distance to move in metres.
      */
-    void move(int distance);
+    void move(float distance);
 
     /**
      * Turn the rover left or right a certain number of degrees.
+     *
+     * +ve degrees -> clockwise
+     * -ve degrees -> counter-clockwise
+     *
+     * @param degrees The number of degrees to rotate.
      */
     void turn(int degrees);
 
@@ -246,12 +255,12 @@
     IMU           imu;
 
     FILE*          logFile;
-    
+
     volatile int   leftStopFlag_;
     volatile int   rightStopFlag_;
 
     volatile int   positionSetPoint_;
-    volatile int   headingSetPoint_;
+    volatile float headingSetPoint_;
     volatile float degreesTurned_;
 
     volatile int   leftPulses_;
@@ -269,6 +278,16 @@
 
     volatile State state_;
 
+    volatile float headingBuffer[1024];
+    volatile int   leftPositionBuffer[1024];
+    volatile int   rightPositionBuffer[1024];
+    volatile float leftVelocityBuffer[1024];
+    volatile float rightVelocityBuffer[1024];
+    volatile int   logIndex;
+    
+    volatile float startHeading_;
+    volatile float endHeading_;
+    
 };
 
 #endif /* ROVER_H */