BotControl.H

Go to the documentation of this file.
00001 /*!@file RCBot/BotControl.H  abstract robot control (can use corba)  */
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 <elazary@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/RCBot/BotControl.H $
00035 // $Id: BotControl.H 9412 2008-03-10 23:10:15Z farhan $
00036 //
00037 
00038 #ifndef BOTCONTROL_H
00039 #define BOTCONTROL_H
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Devices/FrameGrabberConfigurator.H"
00044 #include "Devices/sc8000.H"
00045 #include "Devices/ssc.H"
00046 #include "GUI/XWinManaged.H"
00047 #include "Image/DrawOps.H"
00048 #include "Image/Image.H"
00049 #include "Image/Pixels.H"
00050 #include "Image/ShapeOps.H"
00051 #include "Media/FrameSeries.H"
00052 #include "Transport/FrameIstream.H"
00053 #include "Util/Timer.H"
00054 #include "Devices/BeoChip.H"
00055 
00056 //! Class to abstract robot control for various robots
00057 //! Can control the robot as well as get sensor values
00058 
00059 enum RBEOCHIP {RBEOCHIP_RESET, RBEOCHIP_CAL, RBEOCHIP_SETSERVO};
00060 
00061 class BotControl : public ModelComponent {
00062 public:
00063 
00064   // various robot types
00065   enum RobotType {RCBOT_JEEP, RCBOT_TRUCK, WIREBOT, BEOBOT, SIMULATION};
00066 
00067   BotControl(OptionManager &mgr,
00068              const std::string& descrName = "Robot Controller",
00069              const std::string& tagName = "BotControl",
00070              RobotType inBotType = SIMULATION);
00071 
00072   //! Destructor
00073   ~BotControl();
00074 
00075   //! Init process
00076   void init();
00077   //!set the speed -1.0 (reverse) ... 1.0 (forward)
00078   float getSpeed();
00079   //!get the speed -1.0 ... 1.0
00080   bool setSpeed(const float speedPos);
00081 
00082   //! gets steering angle; input from -1.0 (full left) to 1.0 (full right)
00083   float getSteering();
00084   //! sets steering angle; input from -1.0 (full left) to 1.0 (full right)
00085   bool setSteering(const float steeringPos);
00086 
00087   //! gets the image sensor i
00088   Image<PixRGB<byte > > getImageSensor(int i = 0);
00089 
00090   //! Get image sersor dims
00091   void getImageSensorDims(short &w, short &h, int i = 0);
00092 
00093   //! Added extra info to the display
00094   void setInfo(const char *info, Point2D<int> trackLoc, Point2D<int> recLoc);
00095 
00096   //! Get user input from window
00097   int getUserInput(Point2D<int> &loc);
00098 
00099   //! Set Display
00100   void setDisplay(bool sd);
00101 
00102 protected:
00103   nub::soft_ref<SC8000> sc8000;   //!< sc8000 servo controller
00104   nub::soft_ref<SSC> ssc;         //!< ssc servo controller
00105   nub::soft_ref<BeoChip> bc;      //!< BeoChip controller
00106 //   nub::soft_ref<FrameGrabberConfigurator> gbc;
00107 //   nub::soft_ref<FrameIstream> gb;
00108   nub::soft_ref<InputFrameSeries> ifs;
00109   XWinManaged *xwin;
00110 
00111 private:
00112   //!The type of robot we are using
00113   RobotType botType;
00114 
00115   //!servo def
00116   int speedServo;
00117   int steerServo;
00118   int driveServoLeft;
00119   int driveServoRight;
00120 
00121   //! Speed position
00122   float speed;
00123 
00124   //! steer position
00125   float steering;
00126 
00127   //! Image dims
00128   int width; int height;
00129 
00130   // display windows
00131   void showImg(Image<PixRGB<byte> > &img);
00132 
00133   // setDisplay
00134   bool dispImg;
00135 
00136   //extra info
00137   char *extraInfo;
00138   Point2D<int> trackLoc;
00139   Point2D<int> recLoc;
00140 
00141   //to compute frame/sec
00142   unsigned long long int avgtime;
00143   int avgn;
00144   float fps;
00145   Timer timer;
00146   static const int NAVG = 20;
00147 };
00148 
00149 #endif
00150 
00151 // ######################################################################
00152 /* So things look consistent in everyone's emacs... */
00153 /* Local Variables: */
00154 /* indent-tabs-mode: nil */
00155 /* End: */
Generated on Sun May 8 08:41:17 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3