00001 /*!@file BeoSub/BeoSubTwoBal.H An autonomous submarine with two ballasts */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 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/BeoSubTwoBal.H $ 00035 // $Id: BeoSubTwoBal.H 6990 2006-08-11 18:13:51Z rjpeters $ 00036 // 00037 00038 #ifndef BEOSUB_H_DEFINED 00039 #define BEOSUB_H_DEFINED 00040 00041 #include "BeoSub/BeoSub.H" 00042 #include "BeoSub/BeoSubSensor.H" 00043 #include "Devices/BeoChip.H" 00044 class HMR3300; 00045 class BeoSubListener; // privately defined in BeoSub.C //NOTE: really? 00046 class BeoSubBallast; 00047 class BeoSubIMU; 00048 class IEEE1394grabber; 00049 00050 //! A simple enum to know left from right 00051 enum BeoSubSide { BEOSUBLEFT = 0, BEOSUBRIGHT = 1 }; 00052 00053 //! Simple function to print the name (Left, Right) of a side. 00054 const char* beoSubSideName(const BeoSubSide s); 00055 00056 //! Definition and access functions for the BeoSub 00057 /*! BeoSub is an autonomous visually-guided submarine. This class 00058 impoements the highl-evel functionality, relying on low-level 00059 drivers to handle motor activation, compass reading, etc */ 00060 class BeoSubTwoBal : public BeoSub 00061 { 00062 public: 00063 // ###################################################################### 00064 /*! @name Constructors and Destructors */ 00065 //@{ 00066 00067 //! Constructor 00068 BeoSubTwoBal(OptionManager& mgr); 00069 00070 //! Destructor 00071 ~BeoSubTwoBal(); 00072 00073 //@} 00074 00075 // ###################################################################### 00076 /*! @name Low-level behaviors */ 00077 //@{ 00078 /* 00079 //! Acquire and save a bunch of measurements 00080 void checkpoint(const char *fmt, ...) 00081 // NOTE: this __attribute__ tells gcc that it should issue 00082 // printf-style warnings when compiling calls to 00083 // BeoSub::checkpoint(), treating the 1st argument (fmt) as the 00084 // format string, and the 2nd and subsequent arguments as the 00085 // printf-style parameters (SUBNOTE: because this is a member 00086 // function, there is a hidden 'this' parameter that counts as arg 00087 // 1, so the listed arguments are counted starting from 2) 00088 __attribute__((format(__printf__, 2, 3))); 00089 ; 00090 */ 00091 //@} 00092 00093 //protected: 00094 // ###################################################################### 00095 /*! @name Low-level access functions */ 00096 //@{ 00097 00098 //! Activate the thrusters 00099 /*! Values should be between -1.0 (full reverse) and 1.0 (full 00100 forward), 0.0 being no motion */ 00101 void thrust(const float leftval, const float rightval, const bool blocking = false); 00102 00103 //! Get the current thruster settings 00104 void getThrusters(float& leftval, float& rightval); 00105 00106 //! Set the left-front ballast. Value is between 0.0 (empty) and 1.0 (full) 00107 void setLFballast(const float val, const bool blocking = false); 00108 00109 //! Set the left-rear ballast. Value is between 0.0 (empty) and 1.0 (full) 00110 void setLRballast(const float val, const bool blocking = false); 00111 00112 //! Set the right-front ballast. Value is between 0.0 (empty) and 1.0 (full) 00113 void setRFballast(const float val, const bool blocking = false); 00114 00115 //! Set the right-rear ballast. Value is between 0.0 (empty) and 1.0 (full) 00116 void setRRballast(const float val, const bool blocking = false); 00117 00118 //! Set all ballasts 00119 void setBallasts(const float lf, const float lr, 00120 const float rf, const float rr, 00121 const bool blocking = false); 00122 00123 //! Get the left-front ballast. Value is between 0.0 (empty) and 1.0 (full) 00124 float getLFballast(); 00125 00126 //! Get the left-rear ballast. Value is between 0.0 (empty) and 1.0 (full) 00127 float getLRballast(); 00128 00129 //! Get the right-front ballast. Value is between 0.0 (empty) and 1.0 (full) 00130 float getRFballast(); 00131 00132 //! Get the right-rear ballast. Value is between 0.0 (empty) and 1.0 (full) 00133 float getRRballast(); 00134 00135 //! Get all ballasts 00136 void getBallasts(float& lf, float& lr, 00137 float& rf, float& rr); 00138 //! Drop a marker 00139 void dropMarker(const bool blocking = false); 00140 00141 //! Grab a an image from one of the cameras 00142 Image< PixRGB<byte> > grabImage(const enum BeoSubCamera cam); 00143 00144 //@} 00145 00146 protected: 00147 NModelParam<int> itsLeftThrusterServoNum; //!< servo num for left thruster 00148 NModelParam<int> itsRightThrusterServoNum; //!< servo num for right thruster 00149 00150 nub::soft_ref<HMR3300> itsHMR3300; //!< compass for heading 00151 00152 nub::soft_ref<BeoChip> itsBeoLeft, itsBeoRight; //!< our left and rt beochips 00153 00154 rutz::shared_ptr<BeoSubListener> itsBeoLisLeft, itsBeoLisRight; //!< listeners 00155 00156 BeoSubSensor<float> itsDepthSensor; //!< our depth sensor data 00157 00158 nub::soft_ref<BeoSubBallast> itsLFballast, itsLRballast, 00159 itsRFballast, itsRRballast; //!< our 4 ballasts 00160 00161 nub::soft_ref<BeoSubIMU> itsIMU; //!< our IMU 00162 00163 nub::soft_ref<IEEE1394grabber> itsCameraFront, 00164 itsCameraDown, itsCameraUp; //!< our three cameras 00165 00166 float itsThrustLeft, itsThrustRight; //!< our current thruster settings 00167 00168 void start1(); //!< get started, before our subcomponents start 00169 void start2(); //!< get started, after our subcomponents have started 00170 00171 private: 00172 //! Dispatch a BeoChip event 00173 void dispatchBeoChipEvent(const BeoSubSide side, 00174 const BeoChipEventType t, 00175 const int valint, 00176 const float valfloat); 00177 friend class BeoSubListener; 00178 }; 00179 00180 00181 #endif 00182 00183 // ###################################################################### 00184 /* So things look consistent in everyone's emacs... */ 00185 /* Local Variables: */ 00186 /* indent-tabs-mode: nil */ 00187 /* End: */