00001 /*!@file AppDevices/test-IMU_MicroStrain_3DM_GX2.C test the 00002 MicroStrain 3DM_GX2 IMU */ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2002 // 00006 // by the University of Southern California (USC) and the iLab at USC. // 00007 // See http://iLab.usc.edu for information about this project. // 00008 // //////////////////////////////////////////////////////////////////// // 00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00011 // in Visual Environments, and Applications'' by Christof Koch and // 00012 // Laurent Itti, California Institute of Technology, 2001 (patent // 00013 // pending; application number 09/912,225 filed July 23, 2001; see // 00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00015 // //////////////////////////////////////////////////////////////////// // 00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00017 // // 00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00019 // redistribute it and/or modify it under the terms of the GNU General // 00020 // Public License as published by the Free Software Foundation; either // 00021 // version 2 of the License, or (at your option) any later version. // 00022 // // 00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00026 // PURPOSE. See the GNU General Public License for more details. // 00027 // // 00028 // You should have received a copy of the GNU General Public License // 00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00031 // Boston, MA 02111-1307 USA. // 00032 // //////////////////////////////////////////////////////////////////// // 00033 // 00034 // Primary maintainer for this file: Christian Siagian <siagian@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppDevices/test-IMU_MicroStrain_3DM_GX2.C $ 00036 // $Id: test-IMU_MicroStrain_3DM_GX2.C 12962 2010-03-06 02:13:53Z irock $ 00037 // 00038 00039 #include "Devices/IMU_MicroStrain_3DM_GX2.H" 00040 #include "Component/ModelManager.H" 00041 00042 int main(const int argc, const char **argv) 00043 { 00044 // get a manager going: 00045 ModelManager manager("IMU Manager"); 00046 00047 // instantiate our model components: 00048 nub::soft_ref<IMU_MicroStrain_3DM_GX2> 00049 imu(new IMU_MicroStrain_3DM_GX2(manager)); 00050 manager.addSubComponent(imu); 00051 00052 // Parse command-line: 00053 if (manager.parseCommandLine(argc, argv, "<serdev> [command]", 1, 1) == false) 00054 return(1); 00055 00056 // let's configure our serial device: 00057 imu->configureSerial(manager.getExtraArg(0)); 00058 LINFO("Using: %s", manager.getExtraArg(0).c_str()); 00059 00060 // get started: 00061 manager.start(); 00062 00063 // set data requested to be roll, pitch, and yaw 00064 // imu->setDataRequested(ACCEL_AND_ANG_RATE); 00065 // imu->setDataRequested(MAGNETOMETER); 00066 imu->setDataRequested(ROLL_PITCH_YAW); 00067 00068 // this is completely event driven, so here we just sleep. When data 00069 // is received, it will trigger our listener: 00070 while (1) 00071 { 00072 if(imu->newData()) 00073 { 00074 // // get Acceleration and Angular Rate 00075 // AccelAndAngRateRecord record; 00076 // imu->getAccelerationAndAngularRate(record); 00077 // LINFO("Acceleration x:%15.6f y:%15.6f z:%15.6f", 00078 // record.accelX, record.accelY, record.accelZ); 00079 // LINFO("Angular Rate x:%15.6f y:%15.6f z:%15.6f", 00080 // record.angRateX , record.angRateY, record.angRateZ); 00081 00082 // // get magnetometer direction and magnitude 00083 // MagnetometerRecord mRecord; 00084 // imu->getMagnetometer(mRecord); 00085 // LINFO("Magnetometer x:%15.6f y:%15.6f z:%15.6f", 00086 // mRecord.magX, mRecord.magY, mRecord.magZ); 00087 00088 // get roll, pitch, and yaw 00089 RollPitchYawRecord rpyRecord; 00090 imu->getRollPitchYaw(rpyRecord); 00091 LINFO("Euler Angle r:%15.6f p:%15.6f y:%15.6f", 00092 rpyRecord.roll, rpyRecord.pitch, rpyRecord.yaw); 00093 } 00094 else 00095 usleep(1000); 00096 } 00097 00098 // stop everything and exit: 00099 manager.stop(); 00100 return 0; 00101 } 00102 00103 // ###################################################################### 00104 /* So things look consistent in everyone's emacs... */ 00105 /* Local Variables: */ 00106 /* indent-tabs-mode: nil */ 00107 /* End: */