00001 00002 /*!@file Devices/BeeStem3.H Simple interface to beestem */ 00003 00004 00005 // //////////////////////////////////////////////////////////////////// // 00006 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00007 // University of Southern California (USC) and the iLab at USC. // 00008 // See http://iLab.usc.edu for information about this project. // 00009 // //////////////////////////////////////////////////////////////////// // 00010 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00011 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00012 // in Visual Environments, and Applications'' by Christof Koch and // 00013 // Laurent Itti, California Institute of Technology, 2001 (patent // 00014 // pending; application number 09/912,225 filed July 23, 2001; see // 00015 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00016 // //////////////////////////////////////////////////////////////////// // 00017 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00018 // // 00019 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00020 // redistribute it and/or modify it under the terms of the GNU General // 00021 // Public License as published by the Free Software Foundation; either // 00022 // version 2 of the License, or (at your option) any later version. // 00023 // // 00024 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00025 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00026 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00027 // PURPOSE. See the GNU General Public License for more details. // 00028 // // 00029 // You should have received a copy of the GNU General Public License // 00030 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00031 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00032 // Boston, MA 02111-1307 USA. // 00033 // //////////////////////////////////////////////////////////////////// // 00034 // 00035 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu> 00036 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Devices/BeeStem3.H $ 00037 // $Id: BeeStem3.H 13241 2010-04-15 10:23:02Z beobot $ 00038 // 00039 00040 #ifndef BeeStem3_H_DEFINED 00041 #define BeeStem3_H_DEFINED 00042 00043 #include "Component/ModelComponent.H" 00044 #include "Component/ModelParam.H" 00045 #include "Devices/Serial.H" 00046 #include "Util/Types.H" // for byte 00047 #include <string> 00048 #include <vector> 00049 00050 #define PID_DEPTH 0 00051 #define PID_HEADING 1 00052 #define PID_ENABLE 3 00053 #define PID_DISABLE 2 00054 00055 #define DESIRED_DEPTH 0 00056 #define DESIRED_HEADING 1 00057 00058 class Serial; 00059 00060 class BeeStem3 : public ModelComponent 00061 { 00062 public: 00063 const static int NUM_MOTOR_CONTROLLERS = 9; 00064 struct MotorControllerIDs 00065 { 00066 const static int FWD_RIGHT_THRUSTER = 3; 00067 const static int FWD_LEFT_THRUSTER = 1; 00068 const static int DEPTH_RIGHT_THRUSTER = 4; 00069 const static int DEPTH_LEFT_THRUSTER = 2; 00070 const static int STRAFE_FRONT_THRUSTER = 0; 00071 const static int STRAFE_BACK_THRUSTER = 5; 00072 const static int SHOOTER = 6; 00073 const static int DROPPER_STAGE1 = 7; 00074 const static int DROPPER_STAGE2 = 8; 00075 }; 00076 //! Default constructor; see ModelComponent.H 00077 BeeStem3(OptionManager& mgr, 00078 const std::string& descrName = "BeeStem3 Driver", 00079 const std::string& tagName = "BeeStem3", 00080 const char *defdev = "/dev/ttyUSB0"); 00081 00082 //! Destructor 00083 ~BeeStem3(); 00084 00085 bool getSensors(int &accelX, int &accelY, int &accelZ, 00086 int &compassHeading, int &compassPitch, int &compassRoll, 00087 int &internalPressure, int &externalPressure, 00088 int &desiredHeading, int &desiredDepth, int &desiredSpeed, 00089 int &headingK, int &headingP, int &headingD, int &headingI, int &headingOutput, 00090 int &depthK, int &depthP, int &depthD, int &depthI, int &depthOutput, char &killSwitch); 00091 00092 00093 bool setPID(int pidMode, float k, float p, float i, float d); 00094 00095 // bool setDesiredValues(int16 heading, int16 depth, char speed, char markerDropper); 00096 bool setDesiredHeading(int16 heading); 00097 bool setDesiredDepth(int16 depth); 00098 bool setDesiredSpeed(char speed); 00099 void setThruster(int num, int val); 00100 void startCompassCalibration(); 00101 void endCompassCalibration(); 00102 00103 std::vector<int> mMotorControllerState; 00104 00105 protected: 00106 nub::soft_ref<Serial> itsPort; //!< Serial port to use 00107 pthread_mutex_t itsSerialLock; 00108 }; 00109 00110 #endif 00111 00112 // ###################################################################### 00113 /* So things look consistent in everyone's emacs... */ 00114 /* Local Variables: */ 00115 /* indent-tabs-mode: nil */ 00116 /* End: */