AMOS_IMU_UserGuide

In Nature Robotics Ltd. www.innaturerobotics.com
* @param argc the number of program arguments
* @param argv an array of character pointers that corresponds to the program
arguments
* @return true if a magnetometer calibration flag (-magcal) is present in the
array of program arguments
* @return false if no magnetometer calibration flag is present in the array of
program arguments.
*/
bool isMagCalFlagPresent(int argc, char * argv[]) {
for (int i=0;i<argc;i++) {
if (strlen(argv[i])<7) continue;
if (strncmp(argv[i],"-magcal",7)==0) {
return true;
}
}
return false;
}
/**
* @brief the main function for the IMUTest program
*
* @param argc the number of program arguments specified on the command line to
the program
* @param argv a character array corresponding to each of the program arguments
* @return int the return code from the IMUTest program
*/
int main(int argc, char * argv[])
{
const int NUM_SAMPLES = 100;
const int NUM_TO_AVG = 1;//number of individual samples to average for each
call to IMU::GetSample
pthread_mutex_t i2cMutex = PTHREAD_MUTEX_INITIALIZER;;//mutex for controlling
access to i2c bus
IMU imu(&i2cMutex);
if (imu.m_bInitError) {
printf("An error occurred trying to initialized the IMU.\n");
return -1;
}
if (isMagCalFlagPresent(argc,argv)) {
if (!imu.DoMagCal()) {
printf("Error doing magnetometer calibration.\n");
return -2;
}