Affordable Smart Wheelchair / wheelchairControlSummer2019

Dependencies:   QEI2 chair_BNO055 PID VL53L1X_Filter

Dependents:   wheelchairControlSumer2019

Files at this revision

API Documentation at this revision

Comitter:
ryanlin97
Date:
Tue Jul 17 02:29:26 2018 +0000
Parent:
3:a5e71bfdb492
Child:
5:e0ccaab3959a
Commit message:
beginning imu class

Changed in this revision

BNO055.lib Show annotated file Show diff for this revision Revisions of this file
imu.cpp Show annotated file Show diff for this revision Revisions of this file
imu.h Show annotated file Show diff for this revision Revisions of this file
wheelchair.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BNO055.lib	Tue Jul 17 02:29:26 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/StressedDave/code/BNO055/#1f722ffec323
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imu.cpp	Tue Jul 17 02:29:26 2018 +0000
@@ -0,0 +1,23 @@
+#include "imu.h"
+
+Imu::Imu(){
+  imu = new BNO055(SDA, SCL);
+}
+
+Imu::Imu(PinName sda_pin, PinName scl_pin){
+  imu = new BNO055(sda_pin, scl_pin);
+}
+void Imu::setup(){
+  imu.reset();
+  pc.printf("Bosch Sensortec BNO055 test program on \r\n");
+  while (imu.check() == 0) {
+    pc.printf("Bosch BNO055 is NOT available!!\r\n");
+    wait(.5);
+  }
+  pc.printf("Bosch Sensortec BNO055 available \r\n");
+  imu.set_accel_units(MPERSPERS);
+  imu.setmode(OPERATION_MODE_AMG);
+  imu.get_calib();
+  imu.write_calibration_data();
+  imu.set_angle_units(DEGREES);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imu.h	Tue Jul 17 02:29:26 2018 +0000
@@ -0,0 +1,24 @@
+#ifndef Imu
+#define imu
+
+#include  "mbed.h"
+#include  "math.h"
+#include    "BNO055.h"
+
+#define PI 3.141593
+#define SDA D14
+#define SCL D15
+
+class Imu
+{
+public:
+  Imu();
+  Imu(BNO055*)
+  void setup();
+
+
+private:
+
+};
+
+#endif
--- a/wheelchair.cpp	Mon Jul 16 20:46:42 2018 +0000
+++ b/wheelchair.cpp	Tue Jul 17 02:29:26 2018 +0000
@@ -10,9 +10,12 @@
 */
 void Wheelchair::move(float x_coor, float y_coor)
 {
-    printf("x is %f y is %f \n", 1.6*x_coor + 2.5, 1.6*y_coor + 2.5 + offset); 
-    x->write(1.6*x_coor + 2.5);
-    y->write(1.6*y_coor + 2.5 + offset);
+    printf("raw is %f %f \n", x_coor, y_coor);
+    printf("x is %f y is %f \n", ((x_coor*1.6f) + 1.7f), ((y_coor*1.6f) + 1.7f)); 
+    float scaled_x = ((x_coor * 1.6f) + 1.7f)/3.3f;
+    float scaled_y = (3.3f - (y_coor * 1.6f))/3.3f;
+    x->write(scaled_x);
+    y->write(scaled_y);
     
 }