00001 /************************************************************************************************/ 00002 /*! \file PhysicalControlMomentGyro.h 00003 * \brief The ControlMomentGyro class provides the interface for h/w control moment gyros. 00004 * \author $Author: cakinli $ 00005 * \version $Revision: 1.13 $ 00006 * \date $Date: 2005/02/25 18:40:52 $ 00007 ************************************************************************************************/ 00008 /*! 00009 * 00010 ************************************************************************************************/ 00011 00012 #ifndef __SSSL_PHYSICALCONTROLMOMENTGYRO_H__ 00013 #define __SSSL_PHYSICALCONTROLMOMENTGYRO_H__ 00014 00015 #include <Base/Actuator.h> 00016 #include <matrix/Matrix.h> 00017 #include <string> 00018 #include <sstream> 00019 #include <sys/time.h> 00020 #include <sys/types.h> 00021 #include <sys/stat.h> 00022 #include <sys/fcntl.h> 00023 #include <sys/ioctl.h> 00024 #include <asm/ioctls.h> 00025 #include <bits/types.h> 00026 00027 extern "C" 00028 { 00029 #include <Hardware/satctl.h> 00030 #include <Hardware/common.h> 00031 } 00032 using namespace std; 00033 using namespace O_SESSAME; 00034 00035 /*! Class that provides interface to actual hardware CMGs */ 00036 class PhysicalControlMomentGyro : public Actuator 00037 { 00038 public: 00039 // Contructors/Deconstructors 00040 00041 /*! Default Constructor */ 00042 PhysicalControlMomentGyro(); 00043 00044 /*! Default Deconstructor */ 00045 virtual ~PhysicalControlMomentGyro(); 00046 00047 // Facilitators 00048 00049 /*! Set angular velocity of the CMG wheel 00050 * \param wheelOmega Desired angular velocity of the CMG wheel in rad/sec */ 00051 void CommandWheelSpeed(double wheelOmega); // will change wheelOmega if set different due to saturation 00052 00053 /*! Set torque output to the CMG wheel 00054 * \param wheelTorque Desired output torque in N-m */ 00055 void CommandWheelTorque(double wheelTorque); // will change wheelTorque if set different due to saturation 00056 00057 /*! Set the angle of the wheel axis with respect to its center position 00058 * \param wheelAngle Desired wheel axis angle in radians */ 00059 void CommandAngle(double wheelAngle); 00060 00061 /*! Set the gimbal angle rate of the CMG 00062 * \param gimbalRate Desired gimbal angel rate of the CMG in rad/sec */ 00063 void CommandGimbalRate(double gimbalRate); 00064 00065 /*! Stop the CMG wheel */ 00066 int Stop(); 00067 00068 /*! Initialize all components of the CMG */ 00069 int Initialize(); 00070 00071 /*! Deinitialize all components of the CMG */ 00072 int Deinitialize(); 00073 00074 // Mutators 00075 00076 /*! Set the maximum and minimum angular speeds of the CMG wheel 00077 * \param minWheelSpeed Minimum allowable CMG wheel speed 00078 * \param maxWheelSpeed Maximum allowable CMG wheel speed */ 00079 void SetWheelSpeedLimits(double minWheelSpeed, double maxWheelSpeed); 00080 00081 /*! Set the maximum and minimum torque outputs to the CMG wheel 00082 * \param minWheelTorque Minimum allowable CMG torque output 00083 * \param maxWheelTorque Maximum allowable CMG torque output */ 00084 void SetWheelTorqueLimits(double minWheelTorque,double maxWheelTorque); 00085 00086 /*! Set the maximum change in torque outputs 00087 * \param maxTorqueStep The maximum allowable change between two consecutive torque outputs in N-m */ 00088 void SetMaxTorqueStep(double maxTorqueStep); 00089 00090 /*! Set which daisy chain the CMG is located on */ 00091 void SetDaisyChainNumber(int DaisyChainNumber); 00092 00093 /*! Set the port to which the CMG is plugged into 00094 * \param Port A string contaaining the name of the proper port, S0 for serial 1, USB1 for usb port 2, etc */ 00095 void SetDaisyChainPort(string Port); 00096 00097 // Inspectors 00098 00099 /*! Get the angular velocity of the CMG wheel, returns a double in rad/sec */ 00100 double QueryWheelSpeed(); 00101 00102 /*! Get the current torque output to the CMG wheel, returns a double in N-m */ 00103 double QueryWheelTorque(); 00104 00105 /*! Get the current angle of the CMG wheel axis with respect ot its center position, returns a double in radians */ 00106 double QueryAngle(); 00107 00108 /*! Get the angular velocity limts of the CMG wheel 00109 * \param minWheelSpeed Set to the minimum speed limit of the CMG wheel 00110 * \param maxWheelSpeed Set to the maximum speed limit of the CMG wheel */ 00111 void GetWheelSpeedLimits(double& minWheelSpeed, double& maxWheelSpeed); 00112 00113 /*! Get the torque output limts to the CMG wheel 00114 * \param minWheelTorque Set to the minimum torque output to the CMG wheel 00115 * \param maxWheelTorque Set to the maximum torque output to the CMG wheel */ 00116 void GetWheelTorqueLimits(double& minWheelTorque, double& maxWheelTorque); 00117 00118 /*! Sets maxTorqueStep to the maximun allowable chang in torque values */ 00119 void GetMaxTorqueStep(double& maxTorqueStep); 00120 00121 00122 protected: 00123 00124 00125 private: 00126 00127 /*! Private member function to send a Go command to the smart motor 00128 * \param Address Is either the CMG wheel address of the lineasr actuator address */ 00129 void GoCommand(int Address); 00130 00131 /*! Private function used to initialize the the linear actuator by finding its upper and lower limits 00132 * and then repositioning itself to the center of its travel */ 00133 void FindLimits(); 00134 00135 /*! Double for the current wheel speed in rad/sec */ 00136 double m_CurrentWheelSpeed; 00137 00138 /*! double for the current wheel torque output in N-m */ 00139 double m_CurrentWheelTorque; 00140 00141 /*! Double for the current angle of the wheel axis with respect to its center position in radians */ 00142 double m_CurrentAngle; 00143 00144 /*! Double holding the current LA velocity */ 00145 double m_CurrentLAVelocity; 00146 00147 /*! Double holding the acceleration of the LA */ 00148 double m_CurrentLAAcceleration; 00149 00150 /*! the maximum position count of the LA */ 00151 int m_LAMax; 00152 00153 /*! the minimum position count of the LA */ 00154 int m_LAMin; 00155 00156 /*! The position count at mid-travel for the LA*/ 00157 int m_LAMid; 00158 00159 /*! THe integer address of the CMG wheel */ 00160 int m_WheelAddress; 00161 00162 /*! THe integer address of the LA */ 00163 int m_LAAddress; 00164 00165 /*! Static integer representing the file descriptor for talking to the CMG */ 00166 static int m_fd; 00167 00168 /*! String holding the port to which the CMG is connected */ 00169 string m_DaisyChainPort; 00170 00171 /*! THe number of the daisy chain that the CMG is on */ 00172 int m_DaisyChainNumber; 00173 00174 /*! MAximun allowable wheel speed in rad/sec */ 00175 double m_MaxWheelSpeed; 00176 00177 /*! Minimum allowable wheel speed in rad/sec */ 00178 double m_MinWheelSpeed; 00179 00180 /*! Maximum torque output to the wheel in N-m */ 00181 double m_MaxWheelTorque; 00182 00183 /*! Minimum torque output to the wheel in N-m */ 00184 double m_MinWheelTorque; 00185 00186 /*! MAximum allowable change in consecutive torque values */ 00187 double m_MaxTorqueStep; 00188 00189 }; 00190 00191 #endif 00192 // Do not change the comments below - they will be added automatically by CVS 00193 /***************************************************************************** 00194 * $Log: PhysicalControlMomentGyro.h,v $ 00195 * Revision 1.13 2005/02/25 18:40:52 cakinli 00196 * Created Makefiles and organized include directives to reduce the number of 00197 * include paths. Reorganized libraries so that there is now one per source 00198 * directory. Each directory is self-contained in terms of its Makefile. 00199 * The local Makefile in each directory includes src/config.mk, which has all 00200 * the definitions and general and pattern rules. So at most, to see what 00201 * goes into building a target, a person needs to examine the Makefile in 00202 * that directory, and ../config.mk. 00203 * 00204 * Revision 1.12 2003/12/16 17:20:26 bstreetman 00205 * A bit o' fall cleaning. Just look at how pretty it is. 00206 * 00207 * Revision 1.11 2003/09/15 21:42:46 bstreetman 00208 * Added Config Parsing ability, removed extraneous construction/initialization functions, removed hardcoded parameters 00209 * 00210 * Revision 1.10 2003/08/22 18:18:03 bstreetman 00211 * Added the ability to set gimbal rate 00212 * 00213 * Revision 1.9 2003/08/04 21:25:23 bstreetman 00214 * Now with doxygen-style comments 00215 * 00216 * Revision 1.8 2003/08/01 20:21:20 bstreetman 00217 * Cleaned and streamlined all code. Reduced warning and outputs. CMG and Momentum Wheels now no longer accept a global integer in initialization. The file descriptor is now set and held internally. 00218 * 00219 * Revision 1.7 2003/07/23 19:18:36 bstreetman 00220 * Added command and query angle functionality 00221 * 00222 * Revision 1.6 2003/07/22 21:40:14 bstreetman 00223 * Added FindLimits() 00224 * 00225 * Revision 1.5 2003/07/22 18:30:32 bstreetman 00226 * Added GoCommand() and fixed others 00227 * 00228 * Revision 1.4 2003/07/21 21:37:38 bstreetman 00229 * Added daisy chain port and number set functions 00230 * 00231 * Revision 1.3 2003/07/16 21:39:36 bstreetman 00232 * Updated headers and continued function implementation 00233 * 00234 * Revision 1.2 2003/07/15 20:43:39 bstreetman 00235 * Updated CMG headers and began impletation 00236 * 00237 * Revision 1.1 2003/06/19 21:31:55 simpliciter 00238 * Initial submission, upgrades from Andy's generic code. 00239 * 00240 * Revision 1.1.1.1 2003/06/06 18:44:15 simpliciter 00241 * Initial submission. 00242 * 00243 * 00244 ******************************************************************************/