imu rev1
Fork of AIviate by
Revision 5:d85bac38cdff, committed 2013-11-26
- Comitter:
- team10
- Date:
- Tue Nov 26 20:29:54 2013 +0000
- Parent:
- 4:44a5b1e8fd27
- Commit message:
- imu rev1
Changed in this revision
diff -r 44a5b1e8fd27 -r d85bac38cdff IMUfilter.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IMUfilter.lib Tue Nov 26 20:29:54 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/aberk/code/IMUfilter/#8a920397b510
diff -r 44a5b1e8fd27 -r d85bac38cdff control.cpp --- a/control.cpp Sat Nov 02 08:47:14 2013 +0000 +++ b/control.cpp Tue Nov 26 20:29:54 2013 +0000 @@ -2,18 +2,47 @@ #include "sensor.h" #include "steps.h" #include "mbed.h" +#include "IMUfilter.h" #define MAXPROC 15 +IMUfilter imuFilter(0.1, 10); + process procs[MAXPROC] = {0}; - +Serial pc3(USBTX, USBRX); +LocalFileSystem local("local"); int main() { + init(); + pc3.baud(115200); + accelerometer_measure(); + gyro_turnon(); + sensor ter; + int a; while (true) { schedule(); + a = read_accelerometer(&ter); + a = read_gyro(&ter); + + wait(1); + //Gyro and accelerometer values must be converted to rad/s and m/s/s + //before being passed to the filter. + /* imuFilter.updateFilter(ter.gx, + ter.gy, + ter.gz, + ter.ax, + ter.ay, + ter.az); + imuFilter.computeEuler(); + printf("%f, %f, %f\n", imuFilter.getRoll(), imuFilter.getPitch(), imuFilter.getYaw()); + + */ + + } +; } void init()
diff -r 44a5b1e8fd27 -r d85bac38cdff sensor.cpp --- a/sensor.cpp Sat Nov 02 08:47:14 2013 +0000 +++ b/sensor.cpp Tue Nov 26 20:29:54 2013 +0000 @@ -2,7 +2,7 @@ extern Serial pc; -I2C i2c(p9, p10); +I2C i2c(p28, p27); char set_i2c_pointer(char addr, char reg) {
diff -r 44a5b1e8fd27 -r d85bac38cdff steps.cpp --- a/steps.cpp Sat Nov 02 08:47:14 2013 +0000 +++ b/steps.cpp Tue Nov 26 20:29:54 2013 +0000 @@ -35,8 +35,14 @@ pc.printf("Error in get_sensor_data while reading from gyro!\r\n"); return 1; } + // updated output format for matlab if (USBDEBUG) - pc.printf("Ax: %i Ay: %i Az: %i Gx: %i Gy: %i Gz: %i\r\n", s.ax, s.ay, s.az, s.gx, s.gy, s.gz); + //pc.printf("%i,%i,%i\r\n", s.ax, s.ay, s.az); + pc.printf("%i,%i,%i,%i,%i,%i\r\n", s.ax, s.ay, s.az, s.gx, s.gy, s.gz); + + + //if (USBDEBUG) + // pc.printf("Ax: %i Ay: %i Az: %i Gx: %i Gy: %i Gz: %i\r\n", s.ax, s.ay, s.az, s.gx, s.gy, s.gz); return 1; }