added main and defined M_PI

Dependencies:   BNOWrapper

Committer:
t1jain
Date:
Wed Aug 07 18:50:14 2019 +0000
Revision:
10:14374b492f1d
Parent:
8:729ad465d6c9
Updated Wrapper to be compatible with new code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JesiMiranda 1:4a5b43b9502c 1 #include <mbed.h>
JesiMiranda 1:4a5b43b9502c 2 #include <BNO080.h>
JesiMiranda 7:b548a684290d 3 #include "Watchdog.h"
t1jain 10:14374b492f1d 4 #include <BNO080Wheelchair.h>
JesiMiranda 2:1fd1549d3fbd 5
JesiMiranda 0:0f12b8c4d5f1 6 int main()
JesiMiranda 0:0f12b8c4d5f1 7 {
JesiMiranda 7:b548a684290d 8 Serial pc(USBTX, USBRX, 57600);
JesiMiranda 1:4a5b43b9502c 9 // Create IMU, passing in output stream, pins, I2C address, and I2C frequency
JesiMiranda 7:b548a684290d 10 // These pin assignments are specific to stm32- L432KC
JesiMiranda 7:b548a684290d 11 //BNO080 imu(&pc, D4, D5, D12, D10, 0x4b, 100000);
JesiMiranda 8:729ad465d6c9 12
JesiMiranda 8:729ad465d6c9 13 //NUCLEO- F767ZI
t1jain 10:14374b492f1d 14 BNO080Wheelchair imu(&pc, D2, D4, D13, D15, 0x4b, 100000);
JesiMiranda 8:729ad465d6c9 15
JesiMiranda 8:729ad465d6c9 16
JesiMiranda 8:729ad465d6c9 17 Watchdog dog(&imu);
JesiMiranda 8:729ad465d6c9 18 dog.Configure(4); //need to find the time for entire program to run
t1jain 10:14374b492f1d 19 imu.setup();
JesiMiranda 1:4a5b43b9502c 20 // Tell the IMU to report rotation every 100ms and acceleration every 200ms
JesiMiranda 7:b548a684290d 21
t1jain 10:14374b492f1d 22 // imu.enableReport(BNO080::TOTAL_ACCELERATION, 100);
t1jain 10:14374b492f1d 23 // imu.enableReport(BNO080::ROTATION, 100);
JesiMiranda 3:24e65bfcea6d 24
JesiMiranda 3:24e65bfcea6d 25 while (true) {
JesiMiranda 1:4a5b43b9502c 26 wait(.001f);
JesiMiranda 4:ecd3871549e8 27
JesiMiranda 1:4a5b43b9502c 28 // poll the IMU for new data -- this returns true if any packets were received
t1jain 10:14374b492f1d 29 if(imu.hasNewData(BNO080::TOTAL_ACCELERATION)) {
JesiMiranda 1:4a5b43b9502c 30 // now check for the specific type of data that was received (can be multiple at once)
t1jain 10:14374b492f1d 31
t1jain 10:14374b492f1d 32 pc.printf("Acc in X: %f\n", imu.accel_x());
JesiMiranda 7:b548a684290d 33
t1jain 10:14374b492f1d 34 pc.printf("Rot in X: ");
t1jain 10:14374b492f1d 35 TVector4 eulerRadians = imu.rotation();
t1jain 10:14374b492f1d 36 TVector4 eulerDegrees = eulerRadians * (180.0 / M_PI);
t1jain 10:14374b492f1d 37 eulerDegrees.print(pc, true);
t1jain 10:14374b492f1d 38 pc.printf("\n");
t1jain 10:14374b492f1d 39 dog.Service();
JesiMiranda 7:b548a684290d 40
JesiMiranda 1:4a5b43b9502c 41 }
JesiMiranda 0:0f12b8c4d5f1 42 }
JesiMiranda 3:24e65bfcea6d 43
JesiMiranda 0:0f12b8c4d5f1 44 }
JesiMiranda 3:24e65bfcea6d 45