Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

ControlMomentGyro.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file ControlMomentGyro.cpp
00003 *  \brief Implementation of the ControlMomentGyro class
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.11 $
00006 *  \date    $Date: 2005/09/18 16:12:54 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*! 
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 
00013 #include "ControlMomentGyro.h"
00014 
00015 //////////////////////////////////////////////////////////////////////
00016 // Construction/Destruction
00017 //////////////////////////////////////////////////////////////////////
00018 int ControlMomentGyro::gyroCount = 0;
00019 ControlMomentGyro::ControlMomentGyro()
00020 {
00021         ++gyroCount;
00022 }
00023 
00024 ControlMomentGyro::~ControlMomentGyro()
00025 {
00026     Stop();
00027     --gyroCount;
00028         if (gyroCount == 0)
00029         {
00030                 Deinitialize();
00031         }
00032 }
00033 
00034 
00035 ///////////////////////////////////////////////////////////////////
00036 //  Facilitators
00037 ///////////////////////////////////////////////////////////////////
00038 
00039 void ControlMomentGyro::SetWheelSpeed(double wheelOmega)
00040 {
00041         m_PhysicalCMG.CommandWheelSpeed(wheelOmega);
00042 }
00043 
00044 void ControlMomentGyro::SetWheelTorque(double wheelTorque)
00045 {
00046         m_PhysicalCMG.CommandWheelTorque(wheelTorque);
00047 }
00048 
00049 void ControlMomentGyro::SetAngle(double wheelAngle)
00050 {
00051         m_PhysicalCMG.CommandAngle(wheelAngle);
00052 }
00053 
00054 void ControlMomentGyro::SetGimbalRate(double gimbalRate)
00055 {
00056         m_PhysicalCMG.CommandGimbalRate(gimbalRate);
00057 }
00058 
00059 int ControlMomentGyro::Stop()
00060 {
00061         m_PhysicalCMG.Stop();
00062         return 0;
00063 }
00064 
00065 int ControlMomentGyro::Initialize()
00066 {
00067         string port;
00068         port = "USB7";
00069         m_PhysicalCMG.SetDaisyChainPort(port);
00070         m_PhysicalCMG.Initialize();
00071         return 0;
00072 }
00073 
00074 ControlMomentGyro::ControlMomentGyro(cfgBody& cfgdat) {
00075 
00076 
00077   ++gyroCount;
00078 
00079   cout << "In construction\n";
00080         
00081   const char *myCommands[20] = {"Name", "DaisyChain", "DCPort",
00082     "Limits"};
00083 
00084   for (int i = 0; cfgdat.keys[i][0]; i++) {
00085           cout << "in loop\n";
00086     switch(getCmdIndex(myCommands, cfgdat.keys[i])) {
00087       case 0:
00088         name = cfgdat.vals[i][0];
00089         break;
00090       case 1:
00091         m_PhysicalCMG.SetDaisyChainNumber(atoi(cfgdat.vals[i][0]));
00092         break;
00093       case 2:
00094         m_PhysicalCMG.SetDaisyChainPort(string(cfgdat.vals[i][0]));
00095         break;
00096       case 3:
00097         m_PhysicalCMG.SetWheelTorqueLimits(atoi(cfgdat.vals[i][0]),
00098           atoi(cfgdat.vals[i][1]));
00099         break;
00100       default:
00101         break;
00102         
00103     }
00104   }
00105   cout << "end of const\n";
00106 }
00107   
00108 int ControlMomentGyro::Deinitialize()
00109 {
00110     
00111     m_PhysicalCMG.Deinitialize();
00112         return 0;
00113 }
00114 
00115 
00116 /////////////////////////////////////////////////////////////////////////
00117 // Mutators
00118 /////////////////////////////////////////////////////////////////////////
00119 
00120 void ControlMomentGyro::SetWheelAxis(const Vector& newWheelAxis)
00121 {
00122         m_CMGAxis = newWheelAxis;
00123 }
00124 
00125 void ControlMomentGyro::SetPort(string Port)
00126 {
00127         m_PhysicalCMG.SetDaisyChainPort(Port);
00128 }
00129 
00130 //////////////////////////////////////////////////////////////////////////
00131 // Inspectors
00132 //////////////////////////////////////////////////////////////////////////
00133 
00134 double ControlMomentGyro::GetWheelSpeed() 
00135 {
00136         m_CurrentWheelSpeed = m_PhysicalCMG.QueryWheelSpeed();
00137         return m_CurrentWheelSpeed;
00138 }
00139         
00140 double ControlMomentGyro::GetWheelTorque()
00141 {
00142         m_CurrentWheelTorque = m_PhysicalCMG.QueryWheelTorque();
00143         return m_CurrentWheelTorque;
00144 }
00145 
00146 
00147 double ControlMomentGyro::GetAngle()
00148 {
00149         m_CurrentAngle = m_PhysicalCMG.QueryAngle();
00150         return m_CurrentAngle;
00151 }
00152 
00153 
00154 Vector ControlMomentGyro::GetCMGAxis() const
00155 {
00156         return m_CMGAxis;
00157 }
00158 
00159 
00160 int ControlMomentGyro::getGyroCount() const
00161 {
00162         return gyroCount;
00163 }       
00164 
00165 // Do not change the comments below - they will be added automatically by CVS
00166 /*****************************************************************************
00167 *       $Log: ControlMomentGyro.cpp,v $
00168 *       Revision 1.11  2005/09/18 16:12:54  jayhawk_hokie
00169 *       Remove Jamfiles and unnecessary programs
00170 *       
00171 *       Revision 1.10  2003/10/27 17:04:16  bstreetman
00172 *       Added manual wat to set the communications port in SetPort()
00173 *       
00174 *       Revision 1.9  2003/09/15 21:42:45  bstreetman
00175 *       Added Config Parsing ability, removed extraneous construction/initialization functions, removed hardcoded parameters
00176 *       
00177 *       Revision 1.8  2003/08/22 18:18:03  bstreetman
00178 *       Added the ability to set gimbal rate
00179 *       
00180 *       Revision 1.7  2003/08/04 18:11:35  bstreetman
00181 *       Updated port locations
00182 *       
00183 *       Revision 1.6  2003/08/01 20:21:20  bstreetman
00184 *       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.
00185 *       
00186 *       Revision 1.5  2003/07/16 21:39:36  bstreetman
00187 *       Updated headers and continued function implementation
00188 *       
00189 *       Revision 1.4  2003/07/15 20:43:39  bstreetman
00190 *       Updated CMG headers and began impletation
00191 *       
00192 *       Revision 1.3  2003/07/04 15:54:53  simpliciter
00193 *       Fixed capitalization.
00194 *       
00195 *       Revision 1.2  2003/07/03 19:48:47  nicmcp
00196 *       Added an instance counter
00197 *       
00198 *       Revision 1.1.1.1  2003/06/06 18:44:15  simpliciter
00199 *       Initial submission.
00200 *       
00201 *
00202 ******************************************************************************/

Generated on Wed Sep 5 12:54:18 2007 for DSACSS Operational Code by  doxygen 1.3.9.1