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

templateController.cpp

Go to the documentation of this file.
00001 /************************************************************************************************/
00002 /*! \file templateController.cpp
00003 *  \brief A template file to run an attitude control simulation on Whrol-I and II. The specific 
00004 *               controller and observer are specified in the configuration file (.xml).
00005 *  \author $Author: jayhawk_hokie $
00006 *  \version $Revision: 1.1 $
00007 *  \date    $Date: 2007/07/24 10:36:52 $
00008 ************************************************************************************************/
00009 /*!
00010 *
00011 ************************************************************************************************/
00012 
00013 // Standard System includes
00014 #include <iostream.h>
00015 #include <iomanip.h>
00016 #include <fstream.h>
00017 
00018 // Simulator Interface Includes
00019 #include "Base/Whorl.h"
00020 #include "Base/WhorlSim.h"
00021 #include "Logging/WhorlHistory.h"
00022 
00023 // XML Parser Include
00024 #include <dsacssinterface.h>
00025 
00026 using namespace O_SESSAME;
00027 
00028 // Specify Xml File to Parse
00029 const char *fileName = "./DSACSSConfig.xml";
00030 
00031 int main()
00032 {
00033 
00034 
00035         /******************************************************************
00036         *  Load Configuration Parameters from xml file 
00037         *******************************************************************/
00038         // Declare TiXmlDocument
00039         TiXmlDocument config( fileName );
00040         // Load Xml File
00041         bool loadOkay = config.LoadFile();
00042         checkLoadFile(loadOkay, fileName, config);
00043         // Declare TiXmlHandle
00044         TiXmlHandle docHandle( &config );
00045 
00046         /******************************************************************
00047         * Setup Hardware-in-the-loop Attitude Simualation
00048         *******************************************************************/
00049 
00050         /* Setup WhorlHistory to collect data. Note must be changed for 
00051         each simulator. */
00052         WhorlHistory WhorlData( docHandle, "WHORL-I" );
00053         
00054         /* Create Whorl Object */
00055         Whorl whorlOne;
00056         /* Initialize Whorl Object */
00057         whorlOne.Initialize( docHandle );
00058 
00059         /* Create WhorlSim Object */
00060         WhorlSim whorlOneSim( &whorlOne );
00061         /* Initialize WhorlSim Object */
00062         whorlOneSim.Initialize( docHandle );
00063 
00064         /* Setup Time values */
00065         ssfTime currentTime;
00066 
00067         /* Setup Vectors */
00068         Vector attitudeState(7);
00069         Vector attitudeControl(3);
00070         Vector MRP(3);
00071         Vector referenceAttitudeState(7);
00072         Vector referenceMRP(3);
00073         Vector controlError(6);
00074         
00075         /******************************************************************
00076         * Run Attitude Control Simulation 
00077         *******************************************************************/
00078         cerr << "\n--------------------------------------------------------------" << endl;
00079         cerr << "Start of Program " << endl;
00080         cerr << "--------------------------------------------------------------" << endl;
00081 
00082         for ( int ii = 0; ii <= 200 ; ii++ ) 
00083         {
00084                 /* Get Current attitude state */
00085                 whorlOneSim.Observe();
00086         
00087                 /* Control based on attitude state */
00088                 whorlOneSim.Control();
00089 
00090                 /* Get Current Time */
00091                 currentTime = Now( );           
00092 
00093                 /* Get attitude state vector (7x1) [ quaternion, angular rates [rad/s] ] */
00094                 attitudeState = whorlOne.GetState( );
00095 
00096                 /* Get attitude Control vector (3x1) [N-m]*/
00097                 attitudeControl = whorlOne.GetControl( );
00098                 
00099                 /* Get MRP vector */
00100                 MRP = whorlOne.GetMRP( );
00101 
00102                 /* Get reference attitude state (7x1) */
00103                 referenceAttitudeState( _(1,4) ) = whorlOne.GetReferenceQuaternion( );
00104                 referenceAttitudeState( _(5,7) ) = whorlOne.GetReferenceOmegaBL( );
00105                 referenceMRP = whorlOne.GetReferenceMRP( );
00106 
00107                 /* Get control error */
00108                 controlError = whorlOne.GetControlError( );
00109 
00110                 cerr << "Error Vector: " << ~controlError << endl;
00111 
00112                 /* Save data to file specified in configuration file */
00113                 WhorlData.AppendHistory( currentTime, attitudeState, attitudeControl, MRP, 
00114                         referenceAttitudeState, referenceMRP, controlError );
00115         
00116                 /* Pause */
00117                 usleep( 500000 );
00118         };
00119 
00120         cout << "END of program " << endl;
00121 
00122         return( 0 );
00123 }
00124 
00125 
00126 // Do not change the comments below - they will be added automatically by CVS
00127 /*****************************************************************************
00128 *       $Log: templateController.cpp,v $
00129 *       Revision 1.1  2007/07/24 10:36:52  jayhawk_hokie
00130 *       Initial Submission.
00131 *
00132 *
00133 *
00134 *
00135 ******************************************************************************/

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