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

testDynamics.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file testDynamics.cpp
00003 *  \brief Test program for trying out rigid body dynamics.
00004 *  \author $Author: cakinli $
00005 *  \version $Revision: 1.1.1.1 $
00006 *  \date    $Date: 2005/04/26 17:41:00 $
00007 //////////////////////////////////////////////////////////////////////////////////////////////////
00008 *  
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 #include <iostream.h>
00013 #include "rotation/Rotation.h"
00014 #include "dynamics/Dynamics.h"
00015 #include "kinematics/Kinematics.h"
00016 #include "dynamics/Attitude.h"
00017 #include "environment/Environment.h"
00018 #include "environment/EarthCentralBody.h"
00019 #include "environment/Gravity.h"
00020 #include "utils/Units.h"
00021 
00022 Environment* SetupEnvironment(Attitude &_SpacecraftAttitude)
00023 {
00024     Environment *pEarthEnv = new Environment;
00025     EarthCentralBody *pCBEarth = new EarthCentralBody;
00026     pEarthEnv->SetCentralBody(pCBEarth);
00027     EnvFunction GGTorque(GravityGradientTorque);
00028     cout << "Filling Parameters" << endl;
00029     GGTorque.AddParameter((void*)&(_SpacecraftAttitude.GetAttitude()), 1);
00030     GGTorque.AddParameter((void*)&(_SpacecraftAttitude.GetMOI()), 2);
00031     GGTorque.AddParameter((void*)&(pCBEarth->GetWc(500000)),3);
00032     pEarthEnv->AddTorqueFunction(GGTorque);
00033     return pEarthEnv;
00034 }
00035 
00036 int main()
00037 {
00038     Attitude testAttitude;
00039     Rotation rotInit(Quaternion(0.01,0,0,.8));
00040     
00041     testAttitude.SetAttitude(rotInit);
00042     Vector AngularVelocity(3);
00043     Vector ControlTorques(3);
00044     AngularVelocity(VectorIndexBase) = 0.1;
00045     ControlTorques(VectorIndexBase) = 0.0;
00046         
00047     Matrix MOI = eye(3);
00048     Vector time(2); 
00049     time(VectorIndexBase + 0) = 0;
00050     time(VectorIndexBase + 2) = 100;
00051     
00052     // End user specified parameters
00053     testAttitude.SetAngularVelocity(AngularVelocity);
00054     testAttitude.SetControlTorques(ControlTorques);
00055     testAttitude.SetMOI(MOI);
00056     
00057     testAttitude.SetKinematicsEq(&QuaternionKinematics);
00058     testAttitude.SetDynamicsEq(&QuaternionDynamics);
00059     Environment* pEarth = SetupEnvironment(testAttitude);
00060     testAttitude.SetEnvironment(pEarth);
00061 /*    
00062     cout << ~testAttitude.GetAttitude().GetRotation(Quaternion_Type) << endl;
00063     cout << ~testAttitude.GetAttitude().GetRotation(DCM_Type) << endl;
00064     cout << ~testAttitude.GetAttitude().GetRotation(EulerAngle_Type) << endl;
00065     cout << ~testAttitude.GetAttitude().GetRotation(EulerAxisAngle_Type) << endl;
00066 */
00067     cout << "Propagating..." << endl;
00068     testAttitude.Propagate(time);
00069     
00070     cout << "History: "<< endl << testAttitude.GetHistory();
00071 
00072     delete pEarth;
00073     return 0;
00074 }
00075 
00076 // Do not change the comments below - they will be added automatically by CVS
00077 /*****************************************************************************
00078 *       $Log: testDynamics.cpp,v $
00079 *       Revision 1.1.1.1  2005/04/26 17:41:00  cakinli
00080 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00081 *       
00082 *       Revision 1.3  2003/04/23 16:30:59  nilspace
00083 *       Various bugfixes & uploading of all changed code for new programmers.
00084 *       
00085 *       Revision 1.2  2003/03/27 02:47:29  nilspace
00086 *       Updated to propagate a satellite forward for 10 seconds and return the history.
00087 *       
00088 *       Revision 1.1  2003/03/25 02:26:00  nilspace
00089 *       initial submission of test files.
00090 *       
00091 *       
00092 *
00093 ******************************************************************************/

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