BeoSubMotor.H

Go to the documentation of this file.
00001 /*!@file BeoSub/BeoSubMotor.H Low-level driver for BeoSub motors */
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/BeoSubMotor.H $
00035 // $Id: BeoSubMotor.H 4679 2005-06-24 04:59:53Z rjpeters $
00036 //
00037 
00038 // core of the code contributed by Harris Chiu, USC/ISI
00039 
00040 #ifndef BEOSUBMOTOR_H_DEFINED
00041 #define BEOSUBMOTOR_H_DEFINED
00042 
00043 #include "Component/ModelComponent.H"
00044 #include "Component/ModelParam.H"
00045 #include "Util/Types.H"
00046 
00047 // motor channels:
00048 //
00049 // channel 0 is frame rate of the camera
00050 // channel 1 is Submarine left right motion
00051 // channel 2 is Submarine Camera Up Down motion
00052 // channel 3 is Submarine forward backward motion motion
00053 // channel 4 is Submarine Camera left right motion
00054 // channel 5 is unused
00055 // channel 6 is Submarine Up Down motion
00056 // channel 7 is unused
00057 // channel 8 is unused
00058 #define BSM_LEFTRIGHT 1
00059 #define BSM_CAMUPDOWN 2
00060 #define BSM_FORBACKWARD 3
00061 #define BSM_CAMLEFTRIGHT 4
00062 #define BSM_UPDOWN 6
00063 
00064 //! Low-level driver for the BeoSub motors
00065 class BeoSubMotor : public ModelComponent
00066 {
00067 public:
00068   // Constructor
00069   BeoSubMotor(OptionManager& mgr,
00070               const std::string& descrName = "BeoSub Motor",
00071               const std::string& tagName = "BeoSub Motor",
00072               const int def_parallel_port_addr = 0x378);
00073 
00074   //! Destructor
00075   ~BeoSubMotor();
00076 
00077   //! Set a value
00078   /*! Set a value not less than a minimum and
00079     not larger than maximum to protect controller box from damage
00080     write the value to the parallel port
00081     @param value the value to set
00082     @param channel the channel to set the value to
00083     @param immed if true, immediately send all values to the
00084     interface, otherwise just store the value internally and it will
00085     be sent at the next writePort() or setValue() with immed set to
00086     true.
00087     @return true on success */
00088   bool setValue(const byte value, const int channel, const bool immed = true);
00089 
00090   //! Get the last set value on a given channel
00091   byte getValue(const int channel) const;
00092 
00093   //! Pulse a channel on for a bit
00094   /*!@param positive use a pulse value higher than rest if true, lower
00095     then rest otherwise */
00096   bool pulseValue(const int channel, const bool positive);
00097 
00098   //! Write out our internal data to the parallel port
00099   /*! @return true on success */
00100   bool WritePort();
00101 
00102   unsigned char chMin[9];
00103   unsigned char chMax[9];
00104   unsigned char chDefault[9];
00105 protected:
00106   NModelParam<int> itsPort;  //!< base address of parallel port
00107   unsigned char strobelo;
00108   unsigned char strobehi;
00109   unsigned char ch[9];  //!< channel values
00110   void reset();
00111   void SendCh(const int value);
00112 };
00113 
00114 #endif
00115 
00116 // ######################################################################
00117 /* So things look consistent in everyone's emacs... */
00118 /* Local Variables: */
00119 /* indent-tabs-mode: nil */
00120 /* End: */
Generated on Sun May 8 08:40:19 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3