AMOS_IMU_UserGuide
In Nature Robotics Ltd. www.innaturerobotics.com
}
IMU_DATASAMPLE imu_sample;
for (int i=0;i<NUM_SAMPLES;i++) {
if (!imu.GetMagSample(&imu_sample, NUM_TO_AVG)) {//collect raw magnetometer
data from the LIS3MDL 3-axis magnetometer device and process it to get the
magnetic vector and temperature
printf("Error getting magnetometer sample #%d.\n",i+1);
return -2;
}
if (!imu.GetAccGyroSample(&imu_sample, NUM_TO_AVG)) {//collect accelerometer,
gyro, and temperature data from the LSM6DS33 3-axis acc/gyro device
printf("Error getting acc/gyro sample #%d.\n",i+1);
return -3;
}
//sample #, accX, accY, accZ, gyroX, gyroY, gyroZ, temperature
//un-comment the following lines to show mag, acc, and gyro data
printf("%d (%.3f sec): magX = %.6f, magY = %.6f, magZ = %.6f, accX = %.6f,
accY = %.6f, accZ = %.6f, gyroX = %.3f, gyroY = %.3f, gyroZ = %.3f, temperature =
%.1f deg C\n",
i+1,imu_sample.sample_time_sec,imu_sample.mag_data[0],imu_sample.mag_data[1],imu_
sample.mag_data[2],
imu_sample.acc_data[0],imu_sample.acc_data[1],imu_sample.acc_data[2],
imu_sample.angular_rate[0],imu_sample.angular_rate[1],imu_sample.angular_rate[2],
imu_sample.acc_gyro_temperature);
imu.ComputeOrientation(&imu_sample);
printf("%d (%.3f sec): roll = %.1f deg, pitch = %.1f deg, heading = %.1f
deg\n",i+1,imu_sample.sample_time_sec,imu_sample.roll,imu_sample.pitch,imu_sample
.heading);
}
return 0 ;
}