00001 /* ========================================================================== * 00002 * File ............... BHand.h * 00003 * Creation Date ...... Dec 1998 * 00004 * Last Updated ....... Oct 2010 * 00005 * Revision ........... 4.4.3 * 00006 * Authors ............ Emanuel Todorov * 00007 * Brian Zenowich * 00008 * Edward Hannigan * 00009 * * 00010 * ************************************************************************ * 00011 * * 00012 * Copyright (C) 1998-2010 Barrett Technology, Inc. <support@barrett.com> * 00013 * 625 Mount Auburn St * 00014 * Cambridge, MA 02138, USA * 00015 * * 00016 * All rights reserved. * 00017 * * 00018 * Redistribution and use in source and binary forms, with or without * 00019 * modification, are permitted provided that the following conditions * 00020 * are met: * 00021 * * 00022 * 1. Redistributions of source code must retain the above copyright * 00023 * notice, this list of conditions and the following disclaimer. * 00024 * 2. Redistributions in binary form must reproduce the above copyright * 00025 * notice, this list of conditions and the following disclaimer in the * 00026 * documentation and/or other materials provided with the distribution. * 00027 * * 00028 * THIS SOFTWARE IS PROVIDED BY BARRETT TECHNOLOGY, INC AND CONTRIBUTORS * 00029 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00031 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BARRETT * 00032 * TECHNOLOGY, INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00033 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00034 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00035 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * 00036 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * 00037 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * 00038 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 00039 * * 00040 * The views and conclusions contained in the software and documentation * 00041 * are those of the authors and should not be interpreted as representing * 00042 * official policies, either expressed or implied, of Barrett Technology. * 00043 * * 00044 * ==========================================================================*/ 00045 00046 00060 #ifndef BHAND_H 00061 #define BHAND_H 00062 00063 00064 #include "BHandSupervisoryRealTime.h" 00065 #include "BHandHardware.h" 00066 00067 00068 /* There should be one instance of this class created for each BarrettHand. 00069 00070 BHand contains methods for serial communication with the Barrett Hand, 00071 supports a supervise mode to execute high-level commands on the hand, and a 00072 real time mode that lets users write their own control loops. In Real Time 00073 mode the desired control variables are sent to the hand and desired feedback 00074 values are received from the hand. 00075 00076 Commands for supervise mode include initialize hand, open, close, etc. See 00077 Supervisory.cpp for an example program how Supervise mode works. 00078 00079 Real time mode is entered for specified motors by calling #RTStart. A user may 00080 set control and feedback parameters sent during a control loop update with 00081 a call to #RTSetFlags. To perform a control loop update call #RTUpdate and to 00082 go back to supervise mode call #RTAbort. See RealTime.cpp for an example 00083 program to see how Real Time mode works. 00084 */ 00092 class BHand : public BHandSupervisoryRealtime 00093 { 00094 public: 00095 00097 // Public Methods BarrettHand (Constructor/Deconstructor) 00099 00100 BHand(); 00101 virtual ~BHand(); 00102 00103 00105 // Public Methods for BarrettHand Device Drivers 00107 00108 int setDeviceDriver(BHandDriver *driver); 00109 BHandDriver * getDeviceDriver(); 00110 00111 00113 // Public Methods for Access to Descriptions of BarrettHand Hardware 00115 00116 static unsigned int getHardwareNumModels(); 00117 static BHandHardware * getHardwareDesc(unsigned int hwIndex); 00118 00119 int setHardwareDesc(unsigned int hwIndex); 00120 BHandHardware * getHardwareDesc(); 00121 00122 00124 // Public Methods (Misc.) 00126 00127 static void SetDefaultBaud(unsigned int baud); 00128 00129 static const char* ErrorMessage(int err); 00130 00131 private: 00132 00133 BHandDriver *m_driver; 00134 BHandHardware *m_hardwareDesc; 00135 00136 #ifndef LINUX 00137 // For Timer 00138 static unsigned int m_handCount; 00139 unsigned int m_timerRes; 00140 #endif 00141 }; 00142 00143 00144 // pointer to hand corresponding to each port-1 (1 : BH_MAXPORT) 00145 extern BHand* _BHandArray[]; 00146 00147 00148 #endif