Razor-AHRS / razor-9dof-ahrs

AHRS Firmware for the SparkFun 9DOF Razor IMU and SparkFun 9DOF Sensor Stick
Other
450 stars 264 forks source link

Reading all data using #oscb #32

Closed kiwi3 closed 9 years ago

kiwi3 commented 9 years ago

Hello!

I'm trying to use the Razor IMU to log all acceleration, gyro, and magnetometer data to an output file. I added some code to log the gyro angles (and a timestamp) from the Razor_AHRS_test.pde sketch into a file and that works well. I get the timestamp and then the three angles correctly. However, when I change it to the #oscb (all calibrated values binary, accel_xyz, mag_xyz, gyr_xyz) mode and try to simply read the six other outputs to the file using the readFloat() function, I don't get the results I'm expecting. The acceleration and magnetometer values appear to make sense, but the gyro angles are not the same (even though I didn't move the IMU between tests) and they appear to shift all over when moving the IMU even slightly (very jittery). It says in the Arduino setup file that the format is 3x3, i.e. 3 rows of 3 binary float values of 4 bytes each, making 36 bytes total. Here is my code for reading the extra data and then printing it to a file. Please let me know if you can see any errors with this. I'm very new to Processing and Java so maybe I missed something simple.

while (serial.available() >= 36) { accel_x = readFloat(serial); accel_y = readFloat(serial); accel_z = readFloat(serial); mag_x = readFloat(serial); mag_y = readFloat(serial); mag_z = readFloat(serial); gyr_x = readFloat(serial); gyr_y = readFloat(serial); gyr_z = readFloat(serial); }

out.println(time + " " + accel_x + " " + accel_y + " " + accel_z + " " + mag_x + " " + mag_y + " " + mag_z + " " + gyr_x + " " + gyr_y + " " + gyr_z);

Thanks :)