Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BNO055_fusion mbed NeoStrip
Dependents: MadPulse_Controller_ros
Fork of ES456_Labs by
Revision 3:82e223a4a4e4, committed 2016-09-09
- Comitter:
- jdawkins
- Date:
- Fri Sep 09 15:28:02 2016 +0000
- Parent:
- 2:899128d20215
- Child:
- 4:0d0d62b0a6bd
- Commit message:
- Modified print statements to output $IMU and $MAG messages. This will work with Matlab madPulseCar Class.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 17 20:31:42 2016 +0000
+++ b/main.cpp Fri Sep 09 15:28:02 2016 +0000
@@ -1,6 +1,6 @@
//Uses the measured z-acceleration to drive leds 2 and 3 of the mbed
-#define LOG_RATE 25.0
+#define LOG_RATE 50.0
#define LOOP_RATE 200.0
#define CMD_TIMEOUT 1.0
#define GEAR_RATIO (1/2.75)
@@ -64,12 +64,17 @@
status_LED = 1;
if(imu.check()) {
+
pc.printf("BNO055 connected\r\n");
imu.setmode(OPERATION_MODE_CONFIG);
imu.SetExternalCrystal(1);
imu.setmode(OPERATION_MODE_NDOF); //Uses magnetometer
- imu.set_angle_units(RADIANS);
+ imu.set_angle_units(DEGREES);
+ imu.set_accel_units(MPERSPERS);
+ imu.set_anglerate_units(DEG_PER_SEC);
+ imu.setoutputformat(WINDOWS);
imu.set_mapping(2);
+
} else {
@@ -89,18 +94,22 @@
pc.printf("ES456 Vehicle Sensor Logger\r\n");
while(1){
-
+
imu.get_angles();
imu.get_accel();
imu.get_gyro();
imu.get_mag();
if(t.read()-t_imu > (1/LOG_RATE)) {
+
+ //pc.printf("$MAD,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.1f,%.1f,%.1f\r\n", imu.gyro.x,imu.gyro.y,imu.gyro.z,imu.accel.x,imu.accel.y,imu.accel.z,imu.mag.x,imu.mag.y,imu.mag.z);
+ //xbee.printf("$MAD,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.1f,%.1f,%.1f\r\n", imu.gyro.x,imu.gyro.y,imu.gyro.z,imu.accel.x,imu.accel.y,imu.accel.z,imu.mag.x,imu.mag.y,imu.mag.z);
+
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);
pc.printf("$MAG,%.1f, %.1f, %.1f\r\n",imu.mag.x,imu.mag.y,imu.mag.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);
- xbee.printf("$MAG,%.1f, %.1f, %.1f\r\n",imu.mag.x,imu.mag.y,imu.mag.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);
+ // xbee.printf("$MAG,%.1f, %.1f, %.1f\r\n",imu.mag.x,imu.mag.y,imu.mag.z);
t_imu = t.read();
} // if t.read
