00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file Whorl.h 00003 * \brief Provides an encapsulation of the Whorl spacecraft simulator table data and object. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.19 $ 00006 * \date $Date: 2007/08/31 16:00:19 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /*! 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 #ifndef __SSSL_WHORL_H__ 00013 #define __SSSL_WHORL_H__ 00014 00015 #include <Utils/Error.h> 00016 #include <matrix/Matrix.h> 00017 #include <Sensors/RateGyro.h> 00018 #include <Sensors/DMURateGyro.h> 00019 #include <Sensors/Accelerometer.h> 00020 #include <Sensors/DMUAccelerometer.h> 00021 #include <Sensors/Magnetometer.h> 00022 #include <Sensors/TiltSensor.h> 00023 #include <Actuators/MomentumWheel.h> 00024 #include <Utils/CfgParse.h> 00025 #include <string> 00026 #include <map> 00027 00028 // Orbit Includes 00029 #include <orbit/Orbit.h> 00030 #include <orbit/OrbitState.h> 00031 #include <orbit/orbitstaterep/Keplerian.h> 00032 00033 // transform coe 00034 #include <orbit/orbitstaterep/MappingMeanOsculatingOrbitElements.h> 00035 00036 #include<unistd.h> 00037 00038 using namespace std; 00039 using namespace O_SESSAME; 00040 00041 class Whorl { 00042 00043 00044 public: 00045 // Constructor/Deconstructor 00046 Whorl( ); 00047 virtual ~Whorl( ); 00048 00049 void Initialize( TiXmlHandle tempHandle ); 00050 00051 // Accessor / Setting Functions 00052 00053 /** @brief Get the recent parameter estimate, a Vector w = [I11, I12, I13, I22, I23, I33, mg r1, mg r2, mg r3, c1, c2, c3] */ 00054 inline Vector GetParameter() { return m_recentParameter; }; 00055 00056 /** @brief Get the recent Moment of Inertia matrix in body design axes */ 00057 Matrix GetMOI(); 00058 00059 /** @brief Get the recent center of gravity vector, mg*r */ 00060 Vector GetCGVector(); 00061 00062 /** @brief Get the recent state estimate, a Vector of qbl and \f$\omega_{bl}\f$ */ 00063 inline Vector GetState() { return m_recentState; }; 00064 00065 /** @brief Get the recent attitude estimate, qbl */ 00066 Vector GetQuaternion(); 00067 00068 /** @brief Get the recent attitude estimate, mrp */ 00069 Vector GetMRP(); 00070 00071 /** @brief Get the recent angular velocity estimate, \f$\omega_{bl}\f$ */ 00072 Vector GetOmegaBL(); 00073 00074 /** @brief Get the recent Reference attitude estimate, qbl */ 00075 Vector GetReferenceQuaternion(); 00076 00077 /** @brief Get the recent Reference attitude estimate, mrp */ 00078 Vector GetReferenceMRP(); 00079 00080 /** @brief Get the recent Reference angular velocity estimate, \f$\omega_{r}\f$ */ 00081 Vector GetReferenceOmegaBL(); 00082 00083 /** @brief Get the recent control Vector */ 00084 inline Vector GetControl() { return m_recentControl; }; 00085 00086 /** @brief Get the recent control error Vector */ 00087 Vector GetControlError( ); 00088 00089 /** @brief Get the time of the current estimate */ 00090 inline struct timeval GetTimeOfEstimate() { return m_estimateTime; }; 00091 00092 /** @brief Update the recent state Vector */ 00093 inline void SetState(Vector& _updatedState) { m_recentState = _updatedState; }; 00094 00095 /** @brief Update the recent parameter Vector */ 00096 inline void SetParameter(Vector& _updatedParameter) { m_recentParameter = _updatedParameter; }; 00097 00098 /** @brief Update the recent control Vector */ 00099 inline void SetControl(Vector& _updatedControl) { m_recentControl = _updatedControl; }; 00100 00101 void SetMRPError( Vector _mrpError ); 00102 00103 void SetAngularRateError( Vector _rateError ); 00104 00105 void SetReferenceQuaternion( Vector _quaternion ); 00106 00107 void SetReferenceOmegaBL( Vector _rate ); 00108 00109 /** @brief Sets the time of the current estimate */ 00110 inline void SetTimeOfEstimate(timeval _t) { m_estimateTime = _t; }; 00111 00112 /** Hardware accessor functions */ 00113 00114 /*! Gets a pointer to a specific rate gyro */ 00115 inline RateGyro* GetRateGyro(string rgName) { return m_rateGyros[rgName]; }; 00116 00117 /*! Gets a pointer to a specific rate gyro */ 00118 inline Accelerometer* GetAccelerometer(string accName) { return m_accelerometers[accName]; }; 00119 00120 /*! Gets a pointer to a specific momentum wheel */ 00121 inline MomentumWheel* GetMomentumWheel(string mwName) { return m_momentumWheels[mwName]; }; 00122 00123 /*! Gets a pointer to the magnetometer */ 00124 inline Magnetometer* GetMagnetometer() { return m_magnetometer; }; 00125 00126 /*! \brief Value-Definitions of the different string values */ 00127 enum StringValue{ OFF, 00128 ON, 00129 molpe, 00130 hierax, 00131 sphigx }; 00132 00133 /*! \brief Map to associate the strings with the enum values */ 00134 map<string, StringValue> s_mapStringValues; 00135 00136 char *GetSimulatorName( ); 00137 00138 string GetHardwareFlag( ); 00139 00140 /* Set ECI position and velocity [km, km/s] */ 00141 void SetECI( Vector _ECI ); 00142 00143 /* Set Orbital ELements */ 00144 void SetCOE( Keplerian _COE ); 00145 00146 /* Set Osculating Orbital Elements */ 00147 void SetOscCOE( Keplerian _OscCOE ); 00148 00149 /* Get ECI position and velocity [km, km/s] */ 00150 Vector GetECI( ); 00151 00152 /* Get Orbital ELements */ 00153 Keplerian GetCOE( ); 00154 00155 /* Get Osculating Orbital Elements */ 00156 Keplerian GetOscCOE( ); 00157 00158 /* Set Orbit Control Vector [m/s^2] RIC frame */ 00159 void SetOrbitControl( Vector _control ); 00160 00161 /* Get Orbit Control Vector [m/s^2] RIC frame */ 00162 Vector GetOrbitControl( ); 00163 00164 00165 protected: 00166 00167 private: 00168 00169 /* Simulator Name */ 00170 char* m_SimulatorName; // Options: Whorl-I, Whorl-II 00171 00172 string m_HardwareONOFF; // Option for turning hardware on and off 00173 00174 /* Member stringstream in Whorl.h, momentum wheel ON/OFF choices. */ 00175 stringstream m_WheelOptionString; 00176 00177 /** State and time variables */ 00178 Vector m_recentState; /**< The most recently estimated state Vector, stored as quaternions (qbl) and angular velocities (\$f\omega\$f) */ 00179 Vector m_referenceState; 00180 Vector m_recentParameter; /**< The most recently estimated parameter Vector in the body-design frame, w = [I11, I12, I13, I22, I23, I33, mg r1, mg r2, mg r3, c1, c2, c3] */ 00181 Vector m_recentControl; /**< The most recently applied control Vector */ 00182 timeval m_estimateTime; /**< The time of the current estimate */ 00183 00184 Vector m_controlError; 00185 00186 /** Hardware maps */ 00187 map<string, RateGyro*> m_rateGyros; 00188 map<string, Accelerometer*> m_accelerometers; 00189 map<string, MomentumWheel*> m_momentumWheels; 00190 00191 Magnetometer* m_magnetometer; 00192 00193 /* Orbit */ 00194 Vector m_ECI; 00195 Keplerian m_COE; 00196 Keplerian m_OscCOE; 00197 00198 /* Orbit Control Vector [m/s^2] RIC frame */ 00199 Vector m_OrbitControl; 00200 00201 }; 00202 00203 #endif 00204 00205 // Do not change the comments below - they will be added automatically by CVS 00206 /***************************************************************************** 00207 * $Log: Whorl.h,v $ 00208 * Revision 1.19 2007/08/31 16:00:19 jayhawk_hokie 00209 * Added Orbit Control Capability. 00210 * 00211 * Revision 1.18 2007/05/29 19:14:24 jayhawk_hokie 00212 * Added Constructor Comments. 00213 * 00214 * Revision 1.17 2007/04/09 14:00:10 jayhawk_hokie 00215 * Modifications to parsing XML config file. 00216 * 00217 * Revision 1.16 2007/03/27 19:10:02 jayhawk_hokie 00218 * Added Switch condition for turning on and off devices. 00219 * 00220 * Revision 1.15 2007/01/12 20:30:08 bwilliam 00221 * Modified to use XML parser and updated hardware maps. 00222 * 00223 * Revision 1.14 2005/02/25 18:40:52 cakinli 00224 * Created Makefiles and organized include directives to reduce the number of 00225 * include paths. Reorganized libraries so that there is now one per source 00226 * directory. Each directory is self-contained in terms of its Makefile. 00227 * The local Makefile in each directory includes src/config.mk, which has all 00228 * the definitions and general and pattern rules. So at most, to see what 00229 * goes into building a target, a person needs to examine the Makefile in 00230 * that directory, and ../config.mk. 00231 * 00232 * Revision 1.13 2004/04/28 19:42:56 bstreetman 00233 * Added Tilt Sensor 00234 * 00235 * Revision 1.12 2003/12/09 02:08:42 simpliciter 00236 * Added GetAccelerometer() function. 00237 * 00238 * Revision 1.11 2003/08/18 19:03:49 mavandyk 00239 * Added initial condition and parameter parsing and pulled out controller and observer stuff. 00240 * 00241 * Revision 1.10 2003/08/13 23:16:07 mavandyk 00242 * Altered structure as outline in meeting. 00243 * 00244 * Revision 1.9 2003/08/06 21:44:49 mavandyk 00245 * Altered to get config parsing to work. 00246 * 00247 * Revision 1.8 2003/08/01 11:17:42 mavandyk 00248 * Fundamental changes to the map structure and fixed bugs. 00249 * 00250 * Revision 1.7 2003/07/25 14:25:04 mavandyk 00251 * Fixed bugs, It compiles. 00252 * 00253 * Revision 1.6 2003/07/22 21:26:19 mavandyk 00254 * Fixed bugs. 00255 * 00256 * Revision 1.5 2003/07/10 19:52:30 mavandyk 00257 * Changed time storage and handling. 00258 * 00259 * Revision 1.4 2003/07/09 21:35:19 cakinli 00260 * Updated Whorl::Initialize(), added getCmdIndex(), and class Measurement. 00261 * 00262 * Revision 1.3 2003/07/07 14:37:58 simpliciter 00263 * Minor modifications. Measurement stuff needs work. 00264 * 00265 * Revision 1.2 2003/07/04 16:12:18 simpliciter 00266 * Fixed variable and function names. 00267 * 00268 * Revision 1.1 2003/07/04 14:08:05 simpliciter 00269 * Rearranged directory tree. 00270 * 00271 * Revision 1.5 2003/07/03 21:18:12 simpliciter 00272 * Added functions based on requirements of Observer and Controller classes. 00273 * 00274 * Revision 1.4 2003/07/03 16:54:48 shoemaker 00275 * Added semi-working versions of DMU code 00276 * 00277 * Revision 1.3 2003/07/02 16:36:32 nicmcp 00278 * added some comments 00279 * 00280 * Revision 1.2 2003/06/17 23:32:28 simpliciter 00281 * Updated based on comments from Andy. 00282 * 00283 * Revision 1.1.1.1 2003/06/06 18:44:15 simpliciter 00284 * Initial submission. 00285 * 00286 * Revision 1.1.1.1 2003/06/06 14:44:15 simpliciter 00287 * Initial import. 00288 * 00289 * 00290 ******************************************************************************/