00001 /*!@file BeoSub/test-BeoSubIMU.C test the IMU */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2002 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/BeoSub/test-BeoSubIMU.C $ 00035 // $Id: test-BeoSubIMU.C 6990 2006-08-11 18:13:51Z rjpeters $ 00036 // 00037 00038 #include "BeoSub/BeoSubIMU.H" 00039 #include "Component/ModelManager.H" 00040 00041 //! A hook which will be called when a new IMU reading is received 00042 class TestBeoSubIMUListener : public BeoSubIMUListener { 00043 public: 00044 //! Destructor 00045 virtual ~TestBeoSubIMUListener() {} 00046 00047 //! New data was received 00048 virtual void newData(const float xa, const float ya, const float za, 00049 const Angle xv, const Angle yv, const Angle zv) 00050 { 00051 LINFO("<X-Accel=%8.4f, Y-Accel=%8.4f, Z-Accel=%8.4f, X-Vel=%8.4f, Y-Vel=%8.4f, Z-Vel=%8.4f>", 00052 xa, ya, za, xv.getVal(), yv.getVal(), zv.getVal()); 00053 } 00054 }; 00055 00056 int main(const int argc, const char **argv) 00057 { 00058 // get a manager going: 00059 ModelManager manager("IMU Manager"); 00060 00061 // instantiate our model components: 00062 nub::soft_ref<BeoSubIMU> imu(new BeoSubIMU(manager)); 00063 manager.addSubComponent(imu); 00064 00065 // Parse command-line: 00066 if (manager.parseCommandLine(argc, argv, "<serdev>", 1, 1) == false) 00067 return(1); 00068 00069 // let's configure our serial device: 00070 imu->setModelParamVal("IMUSerialPortDevName", 00071 manager.getExtraArg(0), MC_RECURSE); 00072 00073 // let's register our listener: 00074 rutz::shared_ptr<TestBeoSubIMUListener> lis(new TestBeoSubIMUListener); 00075 rutz::shared_ptr<BeoSubIMUListener> lis2; lis2.dynCastFrom(lis); // cast down 00076 imu->setListener(lis2); 00077 00078 // get started: 00079 manager.start(); 00080 00081 // this is completely event driven, so here we just sleep. When data 00082 // is received, it will trigger our listener: 00083 while (1) sleep(1000); 00084 00085 // stop everything and exit: 00086 manager.stop(); 00087 return 0; 00088 } 00089 00090 // ###################################################################### 00091 /* So things look consistent in everyone's emacs... */ 00092 /* Local Variables: */ 00093 /* indent-tabs-mode: nil */ 00094 /* End: */