LoLGMDExtricateEMD.H

Go to the documentation of this file.
00001 /**
00002    \file  Robots/LoBot/control/LoLGMDExtricateEMD.H
00003    \brief A behaviour for getting the robot unstuck using the raw LGMD
00004    spikes and an array of elementary motion detectors.
00005 
00006    This file defines a class that implements an array of Reichardt
00007    Elementary Motion Detectors that are wired into the LGMD's of lobot's
00008    locusts. The behaviour uses this EMD array to sense the direction in
00009    which maximal spiking activity is ocurring and to steer the robot away
00010    from approaching obstacles in that direction.
00011 */
00012 
00013 // //////////////////////////////////////////////////////////////////// //
00014 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00015 // by the University of Southern California (USC) and the iLab at USC.  //
00016 // See http://iLab.usc.edu for information about this project.          //
00017 // //////////////////////////////////////////////////////////////////// //
00018 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00019 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00020 // in Visual Environments, and Applications'' by Christof Koch and      //
00021 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00022 // pending; application number 09/912,225 filed July 23, 2001; see      //
00023 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00024 // //////////////////////////////////////////////////////////////////// //
00025 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00026 //                                                                      //
00027 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00028 // redistribute it and/or modify it under the terms of the GNU General  //
00029 // Public License as published by the Free Software Foundation; either  //
00030 // version 2 of the License, or (at your option) any later version.     //
00031 //                                                                      //
00032 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00033 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00034 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00035 // PURPOSE.  See the GNU General Public License for more details.       //
00036 //                                                                      //
00037 // You should have received a copy of the GNU General Public License    //
00038 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00039 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00040 // Boston, MA 02111-1307 USA.                                           //
00041 // //////////////////////////////////////////////////////////////////// //
00042 //
00043 // Primary maintainer for this file: mviswana usc edu
00044 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/control/LoLGMDExtricateEMD.H $
00045 // $Id: LoLGMDExtricateEMD.H 13787 2010-08-13 15:30:47Z mviswana $
00046 //
00047 
00048 #ifndef LOBOT_LGMD_EXTRICATE_EMD_DOT_H
00049 #define LOBOT_LGMD_EXTRICATE_EMD_DOT_H
00050 
00051 //------------------------------ HEADERS --------------------------------
00052 
00053 // lobot headers
00054 #include "Robots/LoBot/control/LoBehavior.H"
00055 
00056 #include "Robots/LoBot/lgmd/LocustModel.H"
00057 #include "Robots/LoBot/io/LoEMD.H"
00058 
00059 #include "Robots/LoBot/misc/LoVector.H"
00060 #include "Robots/LoBot/misc/factory.hh"
00061 
00062 // Standard C++ headers
00063 #include <vector>
00064 
00065 //----------------------------- NAMESPACE -------------------------------
00066 
00067 namespace lobot {
00068 
00069 //------------------------- CLASS DEFINITION ----------------------------
00070 
00071 /**
00072    \class lobot::LGMDExtricateEMD
00073 
00074    \brief A behaviour for moving the robot away from obstacles by
00075    running the raw LGMD inputs via an EMD array.
00076 
00077    This class implements a behaviour designed to move lobot away from
00078    obstacles obstructing its path. It does this by using an array of
00079    Reichardt Elementary Motion Detectors that are wired into the locusts
00080    being used to "guide" lobot. The idea is to emulate an insect's
00081    compound eyes.
00082 
00083    As an obstacle approaches the robot, we expect to see an LGMD "wave"
00084    travel through the locusts depending on the obstacle's trajectory. For
00085    example, when an obstacle approaches from the left, we will see the
00086    LGMD's of the leftmost locusts fire first and then those of the
00087    locusts towards the right. The EMD will track this LGMD wave and
00088    point in the direction of maximal spiking activity, which will allow
00089    the behaviour to steer the robot away.
00090 */
00091 class LGMDExtricateEMD : public Behavior {
00092    // Prevent copy and assignment
00093    LGMDExtricateEMD(const LGMDExtricateEMD&) ;
00094    LGMDExtricateEMD& operator=(const LGMDExtricateEMD&) ;
00095 
00096    // Handy type to have around in a derived class
00097    typedef Behavior base ;
00098 
00099    // Boilerplate code to make the generic factory design pattern work
00100    friend  class subfactory<LGMDExtricateEMD, base> ;
00101    typedef register_factory<LGMDExtricateEMD, base> my_factory ;
00102    static  my_factory register_me ;
00103 
00104    /// A compound eye is built from an array of elementary motion
00105    /// detectors. In Robolocust's case, the individual locust LGMDs are
00106    /// the EMDs.
00107    typedef EMD<const LocustModel*> LMD ; // LMD = LGMD motion detector
00108    typedef std::vector<LMD*> EMDs ;
00109    EMDs m_emds ;
00110 
00111    /// This behaviour works by computing a vector that points in the
00112    /// direction of maximal LGMD spiking activity and steering the robot
00113    /// away from that direction. This data member is used to keep track
00114    /// of the above-mentioned vector for visualization purposes.
00115    Vector m_emd_vector ;
00116 
00117    /// In each iteration, this behaviour issues both a drive and a turn
00118    /// command. This structure is a convenient way to hold both these
00119    /// commands together in one place.
00120    struct Command {
00121       int drive ;
00122       int turn  ;
00123 
00124       Command() ;
00125    } ;
00126 
00127    /// This data member holds the most recent commands issued by this
00128    /// behaviour. Useful for visualization.
00129    Command m_cmd ;
00130 
00131    /// A private constructor because behaviours are instantiated with an
00132    /// object factory and not directly by clients.
00133    LGMDExtricateEMD() ;
00134 
00135    /// Stuff to take care of before regular action processing starts.
00136    void pre_run() ;
00137 
00138    /// This method implements the behaviour's extrication strategy, which
00139    /// involves running all the LGMD spikes through an EMD array.
00140    void action() ;
00141 
00142    /// Visualization routine to aid with development and debugging.
00143    void render_me() ;
00144 
00145    /// Clean-up.
00146    ~LGMDExtricateEMD() ;
00147 } ;
00148 
00149 //-----------------------------------------------------------------------
00150 
00151 } // end of namespace encapsulating this file's definitions
00152 
00153 #endif
00154 
00155 /* So things look consistent in everyone's emacs... */
00156 /* Local Variables: */
00157 /* indent-tabs-mode: nil */
00158 /* End: */
Generated on Sun May 8 08:05:44 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3