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

testController.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file testController.cpp
00003 *  \brief Template file for implementation of an attitude controller using the hardware simulators.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.1 $
00006 *  \date    $Date: 2007/07/24 09:22:24 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*! 
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 
00013 #include "testController.h"
00014 
00015 /*! /brief Constructor for testController */
00016 testController::testController( )
00017 {
00018 }
00019 
00020 /*! /brief Constructor for testController
00021  *
00022  *  @param ptr_whorl is a pointer to the Whorl object.
00023  */
00024 testController::testController( Whorl* ptr_whorl )
00025 {
00026         m_whorl = ptr_whorl;
00027         
00028         Initialize( );
00029 
00030 }
00031 
00032 /*! /brief De-Constructor for testController */
00033 testController::~testController( ) 
00034 {
00035 }
00036 
00037 /*! /brief Initialize testController */
00038 int testController::Initialize( ) 
00039 {
00040         /* Initialize control vector */
00041         m_controlTorque.initialize(3); // [N-m]
00042 
00043         /* Specify Max Wheel Torque */
00044         m_uMax = 1.5; // [N-m]
00045         
00046         /* Initialize contorl gain matrix */
00047         m_gainMatrix.initialize(3,3);
00048         m_gainMatrix(1,1) = 0;
00049         m_gainMatrix(2,2) = 0;
00050         m_gainMatrix(3,3) = 2;
00051         
00052        /* Get orientation of Momentum Wheels. Defined in Controller Class. */
00053         A = FindA( );
00054 
00055         /* Get Momentum Wheel spin axis MOI. Defined in Controller Class */
00056         MOI_sw = FindMOI_sw( );
00057 
00058         /* Reference Model. Initialized in Controller.cpp */
00059         Quaternion qri( 0.0, 0.0, 0.0, 1.0 );
00060         m_quaternionReference(1) = qri(1);
00061         m_quaternionReference(2) = qri(2);
00062         m_quaternionReference(3) = qri(3);
00063         m_quaternionReference(4) = qri(4);
00064         m_mrpReference = ModifiedRodriguezParameters( qri );
00065         m_angularRateReference(1) = 0.0; // [rad/s]
00066         m_angularRateReference(2) = 0.0; // [rad/s]
00067         m_angularRateReference(3) = 0.0; // [rad/s] 
00068 
00069         return( 0 );
00070 }
00071 
00072 int testController::Run()
00073 {
00074 
00075         cerr << "Start of testController algorithm" << endl;
00076 
00077         /* Attitude Reference Model */
00078 
00079         /* Error Vectors */
00080         Vector angularRateError(3);
00081         ModifiedRodriguezParameters mrpError;
00082 
00083        /* Set Whorl Error Values */
00084         m_whorl->SetMRPError( mrpError );
00085         m_whorl->SetAngularRateError( angularRateError );
00086 
00087         /* Set Whorl Reference Parameters */
00088         m_whorl->SetReferenceOmegaBL( m_angularRateReference );
00089         m_whorl->SetReferenceQuaternion( m_quaternionReference );
00090 
00091        /* Reaction Wheel Speed */
00092         static Vector wheelSpeed(3);
00093         double measurementTime;
00094         m_whorl->GetMomentumWheel("REACTION_X")->GetWheelSpeed( wheelSpeed(1), measurementTime );
00095         m_whorl->GetMomentumWheel("REACTION_Y")->GetWheelSpeed( wheelSpeed(2), measurementTime );
00096         m_whorl->GetMomentumWheel("REACTION_Z")->GetWheelSpeed( wheelSpeed(3), measurementTime );
00097 
00098         /* Control law */
00099         m_controlTorque(1) = 0; // [N-m]
00100         m_controlTorque(2) = 0; // [N-m]
00101         m_controlTorque(3) = 0; // [N-m]
00102 
00103         /* Wheel Saturation Function. Max control specified in constructor. */
00104         m_controlTorque = WheelSaturation( m_controlTorque ); // [N-m]
00105 
00106         /* Set the desird contorl torque in the whorl object */
00107         m_whorl->SetControl( m_controlTorque ); // [N-m]
00108 
00109         /* Set the torque for the momentum wheels to produce */
00110         SetWheelTorque( m_controlTorque ); // [N-m]
00111 
00112         cerr << "End of testController algorithm" << endl;
00113 
00114         return( 0 );
00115 }
00116 
00117 // Do not change the comments below - they will be added automatically by CVS
00118 /*****************************************************************************
00119 *       $Log: testController.cpp,v $
00120 *       Revision 1.1  2007/07/24 09:22:24  jayhawk_hokie
00121 *       Initial submission.
00122 *       
00123 *       
00124 *       
00125 *
00126 ******************************************************************************/

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