BeobotEffectors.C

Go to the documentation of this file.
00001 /*!@file Beobot/BeobotEffectors.C controls the effectors of the Beobots
00002   (e.g., motors) */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00006 // University of Southern California (USC) and the iLab at USC.         //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: Laurent Itti <itti@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Beobot/BeobotEffectors.C $
00036 // $Id: BeobotEffectors.C 6795 2006-06-29 20:45:32Z rjpeters $
00037 //
00038 
00039 #include "Beobot/BeobotEffectors.H"
00040 
00041 #include "Component/OptionManager.H"
00042 #include "Devices/lcd.H"
00043 #include "Devices/ssc.H"
00044 
00045 // ######################################################################
00046 BeobotEffectors::BeobotEffectors(OptionManager& mgr,
00047                                  const std::string& descrName,
00048                                  const std::string& tagName) :
00049   ModelComponent(mgr, descrName, tagName),
00050   myBeoChip(new BeoChip(mgr))
00051 {
00052   // register our subcomponents:
00053   addSubComponent(myBeoChip);
00054 }
00055 
00056 // ##################################################################
00057 BeobotEffectors::~BeobotEffectors()
00058 { }
00059 
00060 // ##################################################################
00061 void BeobotEffectors::performAction(BeobotAction& action)
00062 {
00063   turn(action.getTurn());
00064   speed(action.getSpeed());
00065   changegear(action.getGear());
00066 }
00067 
00068 // ##################################################################
00069 void BeobotEffectors::center()
00070 { myBeoChip->setServo(bbc.speedServoNum,0.0F); }
00071 
00072 // ##################################################################
00073 void BeobotEffectors::turn(const float angle)
00074 { myBeoChip->setServo(bbc.steerServoNum, angle); }
00075 
00076 // ##################################################################
00077 void BeobotEffectors::speed(const float sp)
00078 { myBeoChip->setServo(bbc.speedServoNum, sp); }
00079 
00080 // ##################################################################
00081 void BeobotEffectors::stop()
00082 { myBeoChip->setServo(bbc.speedServoNum, 0.0F); }
00083 
00084 // ##################################################################
00085 void BeobotEffectors::changegear(const int gear)
00086 {
00087   if (gear == 0)
00088     myBeoChip->setServo(bbc.gearServoNum, -1.0);
00089   else if (gear == 1)
00090     myBeoChip->setServo(bbc.gearServoNum,  0.0);
00091   else
00092     myBeoChip->setServo(bbc.gearServoNum,  1.0);
00093 }
00094 
00095 // ##################################################################
00096 void BeobotEffectors::display(const char* message)
00097 { myBeoChip->lcdPrintf(0,0, "%s", message); }
00098 
00099 // ##################################################################
00100 void BeobotEffectors::cleardisplay()
00101 { myBeoChip->lcdClear(); }
00102 
00103 // ##################################################################
00104 /* So things look consistent in everyone's emacs... */
00105 /* Local Variables: */
00106 /* indent-tabs-mode: nil */
00107 /* End: */
Generated on Sun May 8 08:40:12 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3