Streams BNO055 IMU data

Dependencies:   BNO055_fusion mbed NeoStrip

Dependents:   MadPulse_Controller_ros

Fork of ES456_Labs by USNA WSE ES456

Files at this revision

API Documentation at this revision

Comitter:
piper
Date:
Thu Sep 06 18:21:14 2018 +0000
Parent:
7:0cafae5bdcfb
Commit message:
Streams data to Xbee

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0cafae5bdcfb -r 7f35f3cd8235 main.cpp
--- a/main.cpp	Wed Sep 27 19:57:59 2017 +0000
+++ b/main.cpp	Thu Sep 06 18:21:14 2018 +0000
@@ -1,3 +1,11 @@
+// =========================================================================
+// ES456 Autonomous Vehicles
+// Streams BNO055 IMU data from MadPulse vehicle control board 
+// Dawkins, Piper - Nov 2016
+//
+// Updates:
+// 9/6/18  Piper - Stream data to Xbee
+// =========================================================================
 //Uses the measured z-acceleration to drive leds 2 and 3 of the mbed
 
 #define STAT_RATE 1.0
@@ -31,7 +39,8 @@
 DigitalOut imu_LED(LED4);
 
 Serial pc(USBTX, USBRX); // tx, rx for serial USB interface to pc
-Serial xbee(p28, p27); // tx, rx for Xbee
+//Serial xbee(p28, p27); // tx, rx for Xbee
+Serial xbee(p13, p14); // tx, rx for Xbee
 
 int log_it;
 
@@ -60,6 +69,7 @@
     if(imu.check()) {
 
         pc.printf("BNO055 connected\r\n");
+        xbee.printf("BNO055 connected\r\n");
         imu.setmode(OPERATION_MODE_CONFIG);
         imu.SetExternalCrystal(1);        
         imu.set_angle_units(RADIANS);
@@ -72,6 +82,7 @@
             
     } else {
         pc.printf("IMU BNO055 NOT connected\r\n Program Trap.");
+        xbee.printf("IMU BNO055 NOT connected\r\n Program Trap.");
         status_LED = 1;
         armed_LED = 1;
         imu_LED = 1;
@@ -86,6 +97,7 @@
     }
 
     pc.printf("ES456 Vehicle Sensor Logger\r\n");
+    xbee.printf("ES456 Vehicle Sensor Logger\r\n");
     while(1){
                          
         
@@ -119,17 +131,20 @@
                     imu.get_accel();  
                     imu.get_gyro(); 
                     pc.printf("$IMU,%.3f, %.3f, %.3f, %.3f, %.3f, %.3f\r\n", imu.accel.x,imu.accel.y,imu.accel.z,imu.gyro.x,imu.gyro.y,imu.gyro.z);                
+                    xbee.printf("$IMU,%.3f, %.3f, %.3f, %.3f, %.3f, %.3f\r\n", imu.accel.x,imu.accel.y,imu.accel.z,imu.gyro.x,imu.gyro.y,imu.gyro.z);                
                                                  
                     break;
                 }
                 case (LOG_MAG): {
                     imu.get_mag();   
                     pc.printf("$MAG,%.1f, %.1f, %.1f\r\n",imu.mag.x,imu.mag.y,imu.mag.z);                                 
+                    xbee.printf("$MAG,%.1f, %.1f, %.1f\r\n",imu.mag.x,imu.mag.y,imu.mag.z);                                 
                     break;
                 }
                 case (LOG_EUL): {
                     imu.get_angles();
                     pc.printf("$RPY,%.3f, %.3f, %.3f\r\n", imu.euler.roll,imu.euler.pitch,wrapTo2pi(imu.euler.yaw));                                    
+                    xbee.printf("$RPY,%.3f, %.3f, %.3f\r\n", imu.euler.roll,imu.euler.pitch,wrapTo2pi(imu.euler.yaw));                                    
                     break;
                 }
                 default :{