SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Revision:
63:d9a81b3d69f5
Parent:
62:bc5caf59fe39
Child:
64:43ab429a37e0
diff -r bc5caf59fe39 -r d9a81b3d69f5 Hardwares/IMUManager.h
--- a/Hardwares/IMUManager.h	Sun Apr 09 18:20:57 2017 +0000
+++ b/Hardwares/IMUManager.h	Sun Apr 09 22:08:34 2017 +0000
@@ -44,16 +44,27 @@
 #define FXOS8700CQ_XYZ_DATA_SC FXOS8700CQ_XYZ_DATA_2G
 
 #if FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_2G
-    #define ACCELER_SCALE_F 0.000244f
+    #define ACCELER_SCALE_F_MG 0.244f
 #elif FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_4G
-    #define ACCELER_SCALE_F 0.000488f
+    #define ACCELER_SCALE_F_MG 0.488f
 #elif FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_8G
-    #define ACCELER_SCALE_F 0.000976f
+    #define ACCELER_SCALE_F_MG 0.976f
 #else
     #error Must define a scale for accelerometer!
 #endif
 
 #define FXOS8700CQ_CTRL_REG1    0x2A
+#define FXOS8700CQ_CTRL_REG1_v 0x05
+
+#define FXOS8700CQ_CTRL_REG2    0x2B
+#define FXOS8700CQ_RESET_MASK 0x40
+
+#define FXOS8700CQ_OFF_X        0x2F
+
+#define FXOS8700CQ_OFF_Y        0x30
+
+#define FXOS8700CQ_OFF_Z        0x31
+#define OFFSET_SCALE_F  2.0f
 
 #define FXOS8700CQ_M_CTRL_REG1  0x5B
 
@@ -61,6 +72,9 @@
 
 #define FXOS8700CQ_READ_LEN 13 // status plus 6 channels = 13 bytes
 
+#define IMU_UPDATE_TICK_RATE 0.002f
+#define IMU_DEFAULT_G 9.8f
+
 #include <mbed.h>
 
 #ifdef __cplusplus
@@ -76,10 +90,18 @@
 
 uint8_t imu_manager_init();
 
+void imu_manager_calibrate();
+
+void imu_manager_begin_tick();
+
 void imu_manager_update();
 
 const volatile struct imu_vec3* imu_manager_get_accl();
 
+const volatile struct imu_vec3* imu_manager_get_velocity();
+
+const volatile struct imu_vec3* imu_manager_get_position();
+
 //const volatile struct imu_vec3* imu_manager_get_magt();
 
 #ifdef __cplusplus