Added BNO080Wheelchair.h
Dependents: BNO080_program wheelchaircontrol8 Version1-9 BNO080_program
Revision 12:f013530d8358, committed 2019-08-07
- Comitter:
- t1jain
- Date:
- Wed Aug 07 18:49:44 2019 +0000
- Parent:
- 11:dbe6d8d0ceb1
- Commit message:
- Updated Quaternion to TVector4
Changed in this revision
BNO080Wheelchair.cpp | Show annotated file Show diff for this revision Revisions of this file |
BNO080Wheelchair.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r dbe6d8d0ceb1 -r f013530d8358 BNO080Wheelchair.cpp --- a/BNO080Wheelchair.cpp Fri Aug 02 23:34:30 2019 +0000 +++ b/BNO080Wheelchair.cpp Wed Aug 07 18:49:44 2019 +0000 @@ -10,8 +10,8 @@ } //Check if all the -void BNO080Wheelchair::setup() { - imu -> begin(); +bool BNO080Wheelchair::setup() { + bool setup = imu -> begin(); //Tell the IMU to report every 100ms imu -> enableReport(BNO080::TOTAL_ACCELERATION, 200); imu -> enableReport(BNO080::LINEAR_ACCELERATION, 200); @@ -28,7 +28,11 @@ // imu -> enableReport(BNO080::STEP_COUNTER, 100); // imu -> enableReport(BNO080::SIGNIFICANT_MOTION, 100); // imu -> enableReport(BNO080::SHAKE_DETECTOR, 100); + return setup; +} +bool BNO080Wheelchair::hasNewData(BNO080::Report report) { + return imu -> hasNewData(report); } //Get the x component of the angular velocity from IMU. Stores the component @@ -155,12 +159,12 @@ } //Get the rotation of the IMU (from magnetic north) in radians -Quaternion BNO080Wheelchair::rotation() { +TVector4 BNO080Wheelchair::rotation() { wait(0.05); //printf("Update Data GYRO X: %d \n", imu -> updateData()); // hasNewData()? imu -> updateData(); //wait(0.05); - return imu -> rotationVector; + return imu -> rotationVector.vector(); } /*
diff -r dbe6d8d0ceb1 -r f013530d8358 BNO080Wheelchair.h --- a/BNO080Wheelchair.h Fri Aug 02 23:34:30 2019 +0000 +++ b/BNO080Wheelchair.h Wed Aug 07 18:49:44 2019 +0000 @@ -25,7 +25,10 @@ uint8_t i2cAddress, int i2cPortpeed); //Set up the IMU, check if it connects - void setup(); + bool setup(); + + //Checks if IMU has new data + bool hasNewData(BNO080::Report report); //Get the x-component of the linear acceleration (total) double accel_x(); @@ -67,7 +70,7 @@ char compass(); //Get the rotation of the IMU (from magnetic north) in radians - Quaternion rotation(); + TVector4 rotation(); double rot_w(); double rot_x();