00001 /*!@file Devices/HeliPose.H read HeliPose data */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // 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: Lior Elazary 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/HeliBot/HeliPose.H $ 00035 // $Id: HeliPose.H 13901 2010-09-09 15:12:26Z lior $ 00036 // 00037 00038 #ifndef HeliPose_H_DEFINED 00039 #define HeliPose_H_DEFINED 00040 00041 #include "Image/OpenCVUtil.H" 00042 #include "Component/ModelComponent.H" 00043 #include "Component/ModelParam.H" 00044 #include "Util/Types.H" 00045 #include "Image/Point3D.H" 00046 #include "Image/Point2D.H" 00047 #include "Media/FrameSeries.H" 00048 #include "Transport/FrameInfo.H" 00049 #include "Raster/GenericFrame.H" 00050 #include "Devices/IMU_SFE_Atomic.H" 00051 #include <pthread.h> 00052 #include <unistd.h> 00053 00054 class HeliPose : public ModelComponent { 00055 public: 00056 00057 struct Pose { 00058 Point3D<float> translation; 00059 Point3D<float> velocity; 00060 Point3D<float> rotation; 00061 float roll; 00062 float pitch; 00063 float yaw; 00064 float accelX; 00065 float accelY; 00066 float accelZ; 00067 bool valid; 00068 }; 00069 00070 //! Constructor 00071 HeliPose(OptionManager& mgr, 00072 nub::ref<InputFrameSeries>& ifs, 00073 nub::ref<OutputFrameSeries>& ofs, 00074 const std::string& descrName = "HeliPose", 00075 const std::string& tagName = "HeliPose"); 00076 00077 //! Destructor 00078 ~HeliPose(); 00079 00080 //! This method should not be called (implements thread code) 00081 void run_cameraPose(); //get the pose from the camera 00082 00083 void run_imuPose(); //get the pose from the imu 00084 00085 //! init the thread and connect to the HeliPose 00086 void init(); 00087 00088 //! Get sensor data 00089 Pose getPose(); 00090 00091 //!Get the extrinsic pose 00092 std::vector<Point2D<int> > getExtrinsic(Image<byte>& img); 00093 00094 //!Get the extrinsic pose 00095 std::vector<Point2D<int> > getExtrinsic(Image<PixRGB<byte> >& img); 00096 00097 //!Show a grid on the image based on the pose 00098 void displayExtrinsic(Image<byte>& img); 00099 00100 Image<PixRGB<byte> > getImg(); 00101 00102 //! Calculate the IMu mean an std as rest 00103 void getIMUBias(); 00104 00105 00106 protected: 00107 //! get started (see ModelComponent.H) 00108 void start1(); 00109 00110 //! get started (see ModelComponent.H) 00111 void start2(); 00112 00113 //! get stopped (see ModelComponent.H) 00114 void stop1(); 00115 00116 private: 00117 nub::soft_ref<InputFrameSeries> itsIfs; 00118 nub::soft_ref<OutputFrameSeries> itsOfs; 00119 nub::soft_ref<IMU_SFE_Atomic> itsIMU; 00120 pthread_t runner; 00121 pthread_mutex_t itsPoseLock; 00122 pthread_mutex_t itsImgLock; 00123 mutable bool running; 00124 mutable bool itsDebug; 00125 Image<PixRGB<byte> > itsCurrentImg; 00126 Pose itsCurrentPose; 00127 Point3D<float> itsRotationScale; 00128 Point3D<float> itsVelocityScale; 00129 Point3D<float> itsRotationBias; 00130 Point3D<float> itsVelocityBias; 00131 Point3D<float> itsRotationSigma; 00132 Point3D<float> itsVelocitySigma; 00133 00134 00135 #ifdef HAVE_OPENCV 00136 CvMemStorage* itsStorage; 00137 CvMat* itsIntrinsicMatrix; 00138 CvMat* itsDistortionCoeffs; 00139 CvMat* itsCameraRotation; 00140 CvMat* itsCameraTranslation; 00141 #endif 00142 00143 00144 }; 00145 00146 // ###################################################################### 00147 /* So things look consistent in everyone's emacs... */ 00148 /* Local Variables: */ 00149 /* indent-tabs-mode: nil */ 00150 /* End: */ 00151 00152 #endif