LoExtricate.H

Go to the documentation of this file.
00001 /**
00002    \file  Robots/LoBot/control/LoExtricate.H
00003    \brief A behaviour for getting the robot unstuck when the emergency
00004    stop behaviour commands a full stop because stuff has gotten too close
00005    for comfort.
00006 */
00007 
00008 // //////////////////////////////////////////////////////////////////// //
00009 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00010 // by the University of Southern California (USC) and the iLab at USC.  //
00011 // See http://iLab.usc.edu for information about this project.          //
00012 // //////////////////////////////////////////////////////////////////// //
00013 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00014 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00015 // in Visual Environments, and Applications'' by Christof Koch and      //
00016 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00017 // pending; application number 09/912,225 filed July 23, 2001; see      //
00018 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00019 // //////////////////////////////////////////////////////////////////// //
00020 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00023 // redistribute it and/or modify it under the terms of the GNU General  //
00024 // Public License as published by the Free Software Foundation; either  //
00025 // version 2 of the License, or (at your option) any later version.     //
00026 //                                                                      //
00027 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00028 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00029 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00030 // PURPOSE.  See the GNU General Public License for more details.       //
00031 //                                                                      //
00032 // You should have received a copy of the GNU General Public License    //
00033 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00034 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00035 // Boston, MA 02111-1307 USA.                                           //
00036 // //////////////////////////////////////////////////////////////////// //
00037 //
00038 // Primary maintainer for this file: mviswana usc edu
00039 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/control/LoExtricate.H $
00040 // $Id: LoExtricate.H 13813 2010-08-21 05:36:12Z mviswana $
00041 //
00042 
00043 #ifndef LOBOT_EXTRICATE_BEHAVIOUR_DOT_H
00044 #define LOBOT_EXTRICATE_BEHAVIOUR_DOT_H
00045 
00046 //------------------------------ HEADERS --------------------------------
00047 
00048 // lobot headers
00049 #include "Robots/LoBot/control/LoBehavior.H"
00050 #include "Robots/LoBot/misc/LoVector.H"
00051 #include "Robots/LoBot/misc/factory.hh"
00052 
00053 //----------------------------- NAMESPACE -------------------------------
00054 
00055 namespace lobot {
00056 
00057 //------------------------- CLASS DEFINITION ----------------------------
00058 
00059 /**
00060    \class lobot::Extricate
00061 
00062    \brief A behaviour for unsticking the robot after the emergency stop
00063    behaviour stops it dead in its tracks because things have gotten too
00064    close for comfort.
00065 
00066    This class implements a behaviour that monitors the robot's danger
00067    zone and commands the robot to back-up, turn and/or drive forwards as
00068    required to get it away from the wall, corner or other obstacle
00069    currently obstructing its path so that it can start moving normally
00070    again.
00071 
00072    The extrication algorithm is based on the potential field idea: each
00073    danger reading exerts a virtual repulsive force on the robot while
00074    distance measurements outside of the danger zone exert an attractive
00075    force. The sum of all these force vectors is used to drive and steer
00076    the robot away from obstacles.
00077 */
00078 class Extricate : public Behavior {
00079    // Prevent copy and assignment
00080    Extricate(const Extricate&) ;
00081    Extricate& operator=(const Extricate&) ;
00082 
00083    // Handy type to have around in a derived class
00084    typedef Behavior base ;
00085 
00086    // Boilerplate code to make the generic factory design pattern work
00087    friend  class subfactory<Extricate, base> ;
00088    typedef register_factory<Extricate, base> my_factory ;
00089    static  my_factory register_me ;
00090 
00091    /// The extricate behaviour works by computing a virtual repulsive
00092    /// force for each danger zone reading and an attractive force for
00093    /// each distance reading that lies outside the danger zone. The
00094    /// resulting total force exerted on the robot is then used to drive
00095    /// and steer the robot away from obstacles.
00096    ///
00097    /// These data members are used to keep track of the attractive,
00098    /// repulsive and total force vectors.
00099    ///
00100    /// DEVNOTE: Actually, we only need to remember these forces for
00101    /// visualization purposes.
00102    Vector m_attractive, m_repulsive, m_total_force ;
00103 
00104    /// In each iteration, the extricate behaviour issues both a drive and
00105    /// a turn command. This structure is a convenient way to hold both
00106    /// these commands together in one place.
00107    struct Command {
00108       int drive ;
00109       int turn  ;
00110 
00111       Command() ;
00112    } ;
00113 
00114    /// This data member holds the extricate behaviour's most recent
00115    /// drive and turn commands. Useful for visualization.
00116    Command m_cmd ;
00117 
00118    /// A private constructor because behaviours are instantiated with an
00119    /// object factory and not directly by clients.
00120    Extricate() ;
00121 
00122    /// Things to do/check before regular action processing kicks in.
00123    void pre_run() ;
00124 
00125    /// This method implements the behaviour's extrication strategy. As
00126    /// mentioned earlier, it works by computing attractive and repulsive
00127    /// forces based on the laser range finder's distance readings.
00128    void action() ;
00129 
00130    /// Visualization routine to aid with development and debugging.
00131    void render_me() ;
00132 
00133    /// Clean-up.
00134    ~Extricate() ;
00135 } ;
00136 
00137 //-----------------------------------------------------------------------
00138 
00139 } // end of namespace encapsulating this file's definitions
00140 
00141 #endif
00142 
00143 /* So things look consistent in everyone's emacs... */
00144 /* Local Variables: */
00145 /* indent-tabs-mode: nil */
00146 /* End: */
Generated on Sun May 8 08:41:22 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3