JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGGyro.cpp

00001 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00002 
00003  Module:       FGGyro.cpp
00004  Author:       Jon Berndt
00005  Date started: 29 August 2009
00006 
00007  ------------- Copyright (C) 2009 -------------
00008 
00009  This program is free software; you can redistribute it and/or modify it under
00010  the terms of the GNU Lesser General Public License as published by the Free Software
00011  Foundation; either version 2 of the License, or (at your option) any later
00012  version.
00013 
00014  This program is distributed in the hope that it will be useful, but WITHOUT
00015  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00017  details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License along with
00020  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021  Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023  Further information about the GNU Lesser General Public License can also be found on
00024  the world wide web at http://www.gnu.org.
00025 
00026 FUNCTIONAL DESCRIPTION
00027 --------------------------------------------------------------------------------
00028 
00029 HISTORY
00030 --------------------------------------------------------------------------------
00031 
00032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00033 COMMENTS, REFERENCES,  and NOTES
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 
00036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00037 INCLUDES
00038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00039 
00040 #include "FGGyro.h"
00041 #include <iostream>
00042 
00043 #include "models/FGAccelerations.h"
00044 
00045 using namespace std;
00046 
00047 namespace JSBSim {
00048 
00049 static const char *IdSrc = "$Id: FGGyro.cpp,v 1.7 2012/11/17 18:03:19 jberndt Exp $";
00050 static const char *IdHdr = ID_GYRO;
00051 
00052 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00053 CLASS IMPLEMENTATION
00054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00055 
00056 FGGyro::FGGyro(FGFCS* fcs, Element* element) : FGSensor(fcs, element),
00057                                                FGSensorOrientation(element)
00058 {
00059   Accelerations = fcs->GetExec()->GetAccelerations();
00060   
00061   Debug(0);
00062 }
00063 
00064 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00065 
00066 FGGyro::~FGGyro()
00067 {
00068   Debug(1);
00069 }
00070 
00071 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00072 
00073 bool FGGyro::Run(void )
00074 {
00075   // There is no input assumed. This is a dedicated angular acceleration sensor.
00076   
00077   //aircraft rates
00078   vAccel = mT * Accelerations->GetPQRdot();
00079 
00080   Input = vAccel(axis);
00081 
00082   ProcessSensorSignal();
00083 
00084   if (IsOutput) SetOutput();
00085 
00086   return true;
00087 }
00088 
00089 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00090 //    The bitmasked value choices are as follows:
00091 //    unset: In this case (the default) JSBSim would only print
00092 //       out the normally expected messages, essentially echoing
00093 //       the config files as they are read. If the environment
00094 //       variable is not set, debug_lvl is set to 1 internally
00095 //    0: This requests JSBSim not to output any messages
00096 //       whatsoever.
00097 //    1: This value explicity requests the normal JSBSim
00098 //       startup messages
00099 //    2: This value asks for a message to be printed out when
00100 //       a class is instantiated
00101 //    4: When this value is set, a message is displayed when a
00102 //       FGModel object executes its Run() method
00103 //    8: When this value is set, various runtime state variables
00104 //       are printed out periodically
00105 //    16: When set various parameters are sanity checked and
00106 //       a message is printed out when they go out of bounds
00107 
00108 void FGGyro::Debug(int from)
00109 {
00110   string ax[4] = {"none", "X", "Y", "Z"};
00111 
00112   if (debug_lvl <= 0) return;
00113 
00114   if (debug_lvl & 1) { // Standard console startup message output
00115     if (from == 0) { // Constructor
00116       cout << "        Axis: " << ax[axis] << endl;
00117     }
00118   }
00119   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
00120     if (from == 0) cout << "Instantiated: FGGyro" << endl;
00121     if (from == 1) cout << "Destroyed:    FGGyro" << endl;
00122   }
00123   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
00124   }
00125   if (debug_lvl & 8 ) { // Runtime state variables
00126   }
00127   if (debug_lvl & 16) { // Sanity checking
00128   }
00129   if (debug_lvl & 64) {
00130     if (from == 0) { // Constructor
00131       cout << IdSrc << endl;
00132       cout << IdHdr << endl;
00133     }
00134   }
00135 }
00136 }