MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
AircraftInstruments Class Reference

#include <instruments.h>

Inheritance diagram for AircraftInstruments:
Collaboration diagram for AircraftInstruments:

Public Types

enum  Measure {
  AIRSPEED = 1, GROUNDSPEED, ALTITUDE, ATTITUDE,
  BANK, TURN, SLIP, VERTICALSPEED,
  AOA, HEADING, LONGITUDE, LATITUDE,
  ROLLRATE, PITCHRATE, YAWRATE, LASTMEASURE
}
 
- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from AerodynamicElem
enum  Type {
  UNKNOWN = -1, INDUCEDVELOCITY = 0, AEROMODAL, AERODYNAMICBODY,
  AERODYNAMICBEAM, AERODYNAMICEXTERNAL, AERODYNAMICEXTERNALMODAL, AERODYNAMICLOADABLE,
  AIRCRAFTINSTRUMENTS, GENERICFORCE, LASTAEROTYPE
}
 

Public Member Functions

 AircraftInstruments (unsigned int uLabel, const DofOwner *pDO, const StructNode *pN, const Mat3x3 &R, flag fOut)
 
virtual ~AircraftInstruments (void)
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual Elem::Type GetElemType (void) const
 
virtual void Output (OutputHandler &OH) const
 
virtual AerodynamicElem::Type GetAerodynamicElemType (void) const
 
virtual void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal, const VectorHandler &, const VectorHandler &)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
virtual void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual unsigned int iGetNumDof (void) const
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual DofOrder::Order GetDofType (unsigned int) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual int GetNumConnectedNodes (void) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual DofOrder::Order GetEqType (unsigned int i) const
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *h=0)
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from AerodynamicElem
 AerodynamicElem (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~AerodynamicElem (void)
 
virtual bool NeedsAirProperties (void) const
 
virtual const InducedVelocitypGetInducedVelocity (void) const
 
- Public Member Functions inherited from ElemWithDofs
 ElemWithDofs (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~ElemWithDofs (void)
 
- Public Member Functions inherited from DofOwnerOwner
 DofOwnerOwner (const DofOwner *pDO)
 
virtual ~DofOwnerOwner ()
 
virtual const DofOwnerpGetDofOwner (void) const
 
virtual integer iGetFirstIndex (void) const
 
virtual void SetInitialValue (VectorHandler &X)
 
- Public Member Functions inherited from AirPropOwner
 AirPropOwner (void)
 
virtual ~AirPropOwner (void)
 
virtual void PutAirProperties (const AirProperties *pAP)
 
virtual flag fGetAirVelocity (Vec3 &Velocity, const Vec3 &X) const
 
virtual doublereal dGetAirDensity (const Vec3 &X) const
 
virtual doublereal dGetAirPressure (const Vec3 &X) const
 
virtual doublereal dGetAirTemperature (const Vec3 &X) const
 
virtual doublereal dGetSoundSpeed (const Vec3 &X) const
 
virtual bool GetAirProps (const Vec3 &X, doublereal &rho, doublereal &c, doublereal &p, doublereal &T) const
 

Protected Member Functions

void Update (void)
 

Protected Attributes

const StructNodepNode
 
Mat3x3 Rh
 
doublereal dMeasure [LASTMEASURE]
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from AirPropOwner
const AirPropertiespAirProperties
 

Detailed Description

Definition at line 39 of file instruments.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

AircraftInstruments::AircraftInstruments ( unsigned int  uLabel,
const DofOwner pDO,
const StructNode pN,
const Mat3x3 R,
flag  fOut 
)

Definition at line 39 of file instruments.cc.

References dMeasure.

42 : Elem(uLabel, fOut),
43 AerodynamicElem(uLabel, pDO, fOut),
44 pNode(pN),
45 Rh(R)
46 {
47  memset(&dMeasure[0], 0, sizeof(dMeasure));
48 }
AerodynamicElem(unsigned int uL, const DofOwner *pDO, flag fOut)
Definition: aerodyn.cc:771
doublereal dMeasure[LASTMEASURE]
Definition: instruments.h:66
unsigned int uLabel
Definition: withlab.h:44
const StructNode * pNode
Definition: instruments.h:63
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
AircraftInstruments::~AircraftInstruments ( void  )
virtual

Definition at line 50 of file instruments.cc.

References NO_OP.

51 {
52  NO_OP;
53 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

VariableSubMatrixHandler & AircraftInstruments::AssJac ( VariableSubMatrixHandler WorkMat,
doublereal  ,
const VectorHandler ,
const VectorHandler  
)
virtual

Implements Elem.

Definition at line 178 of file instruments.cc.

References DEBUGCOUTFNAME, and VariableSubMatrixHandler::SetNullMatrix().

182 {
183  DEBUGCOUTFNAME("AircraftInstruments::AssJac");
184 
185  WorkMat.SetNullMatrix();
186 
187  return WorkMat;
188 }
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
void SetNullMatrix(void)
Definition: submat.h:1159

Here is the call graph for this function:

SubVectorHandler & AircraftInstruments::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 192 of file instruments.cc.

References VectorHandler::Resize(), and Update().

196 {
197  WorkVec.Resize(0);
198 
199  Update();
200 
201  return WorkVec;
202 }
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

doublereal AircraftInstruments::dGetPrivData ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 249 of file instruments.cc.

References dMeasure, WithLabel::GetLabel(), LASTMEASURE, and MBDYN_EXCEPT_ARGS.

250 {
251  if (i <= 0 || i >= LASTMEASURE) {
252  silent_cerr("AircraftInstruments(" << GetLabel() << "): "
253  "illegal measure " << i << std::endl);
255  }
256 
257  return dMeasure[i];
258 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal dMeasure[LASTMEASURE]
Definition: instruments.h:66
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

virtual AerodynamicElem::Type AircraftInstruments::GetAerodynamicElemType ( void  ) const
inlinevirtual
void AircraftInstruments::GetConnectedNodes ( std::vector< const Node * > &  connectedNodes) const
virtual

Reimplemented from Elem.

Definition at line 261 of file instruments.cc.

References pNode.

262 {
263  connectedNodes.resize(1);
264  connectedNodes[0] = pNode;
265 }
const StructNode * pNode
Definition: instruments.h:63
Elem::Type AircraftInstruments::GetElemType ( void  ) const
virtual

Implements Elem.

Definition at line 56 of file instruments.cc.

References Elem::AERODYNAMIC.

57 {
58  return Elem::AERODYNAMIC;
59 }
unsigned int AircraftInstruments::iGetNumPrivData ( void  ) const
virtual

Reimplemented from SimulationEntity.

Definition at line 206 of file instruments.cc.

References LASTMEASURE.

207 {
208  return LASTMEASURE-1;
209 }
unsigned int AircraftInstruments::iGetPrivDataIdx ( const char *  s) const
virtual

Reimplemented from SimulationEntity.

Definition at line 212 of file instruments.cc.

References AIRSPEED, ALTITUDE, AOA, ASSERT, ATTITUDE, BANK, GROUNDSPEED, HEADING, LATITUDE, LONGITUDE, PITCHRATE, ROLLRATE, SLIP, TURN, VERTICALSPEED, and YAWRATE.

213 {
214  ASSERT(s != NULL);
215 
216  struct {
217  const char *s;
218  int i;
219  } s2i[] = {
220  { "airspeed", AIRSPEED },
221  { "ground" "speed", GROUNDSPEED },
222  { "altitude", ALTITUDE },
223  { "attitude", ATTITUDE },
224  { "bank", BANK },
225  { "turn", TURN },
226  { "slip", SLIP },
227  { "vertical" "speed", VERTICALSPEED},
228  { "angle" "of" "attack", AOA },
229  { "aoa", AOA },
230  { "heading", HEADING },
231  { "longitude", LONGITUDE },
232  { "latitude", LATITUDE },
233  { "rollrate", ROLLRATE },
234  { "pitchrate", PITCHRATE },
235  { "yawrate", YAWRATE },
236  { 0 }
237  };
238 
239  for (int i = 0; s2i[i].s != 0; i++) {
240  if (strcasecmp(s, s2i[i].s) == 0) {
241  return s2i[i].i;
242  }
243  }
244 
245  return 0;
246 }
#define ASSERT(expression)
Definition: colamd.c:977
void AircraftInstruments::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 154 of file instruments.cc.

References OutputHandler::Aerodynamic(), ToBeOutput::bToBeOutput(), dMeasure, WithLabel::GetLabel(), and LASTMEASURE.

155 {
156  if (bToBeOutput()) {
157  std::ostream& out = OH.Aerodynamic()
158  << std::setw(8) << GetLabel();
159 
160  for (int iCnt = 1; iCnt < LASTMEASURE; iCnt++) {
161  out << " " << dMeasure[iCnt];
162  }
163 
164  out << std::endl;
165  }
166 }
virtual bool bToBeOutput(void) const
Definition: output.cc:890
doublereal dMeasure[LASTMEASURE]
Definition: instruments.h:66
unsigned int GetLabel(void) const
Definition: withlab.cc:62
std::ostream & Aerodynamic(void) const
Definition: output.h:485

Here is the call graph for this function:

std::ostream & AircraftInstruments::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 143 of file instruments.cc.

References WithLabel::GetLabel(), pNode, Rh, and Mat3x3::Write().

144 {
145  out << "aircraft instruments: " << GetLabel()
146  << ", " << pNode->GetLabel()
147  << ", orientation, ", Rh.Write(out)
148  << ";" << std::endl;
149 
150  return out;
151 }
const StructNode * pNode
Definition: instruments.h:63
std::ostream & Write(std::ostream &out, const char *sFill=" ", const char *sFill2=NULL) const
Definition: matvec3.cc:722
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

void AircraftInstruments::Update ( void  )
protected

Definition at line 62 of file instruments.cc.

References AIRSPEED, ALTITUDE, AOA, grad::atan2(), ATTITUDE, BANK, dMeasure, AirPropOwner::fGetAirVelocity(), StructNode::GetRCurr(), StructDispNode::GetVCurr(), Mat3x3::GetVec(), StructNode::GetWCurr(), StructDispNode::GetXCurr(), GROUNDSPEED, HEADING, LATITUDE, LONGITUDE, Mat3x3::MulTV(), PITCHRATE, pNode, R, Rh, ROLLRATE, SLIP, TURN, VERTICALSPEED, YAWRATE, and Zero3.

Referenced by AssRes().

63 {
64  const Vec3& X(pNode->GetXCurr());
65  const Mat3x3& R(pNode->GetRCurr()*Rh);
66  const Vec3& V(pNode->GetVCurr());
67  const Vec3& Omega(pNode->GetWCurr());
68  Vec3 VV = V;
69  const Vec3 e1(R.GetVec(1));
70  const Vec3 e2(R.GetVec(2));
71  const Vec3 e3(R.GetVec(3));
72 
73  /*
74  * Assumptions:
75  * - world is "flat"
76  * - world "z" is positive upward
77  * (flight mechanics conventions?)
78  * - aircraft "x" is positive forward
79  * - aircraft "z" is positive downward
80  * - aircraft "y" is positive towards the right of the pilot
81  * - pitch is positive nose up
82  * - roll is positive right wing down
83  * - yaw is positive right wing backward
84  */
85 
86  Vec3 VTmp(Zero3);
87  if (fGetAirVelocity(VTmp, X)) {
88  VV -= VTmp;
89  }
90 
91  /* airspeed */
92  dMeasure[AIRSPEED] = VV.Norm();
93 
94  /* groundspeed */
95  VTmp = V;
96  VTmp(3) = 0.;
97  dMeasure[GROUNDSPEED] = VTmp.Norm();
98 
99  /* altitude */
100  dMeasure[ALTITUDE] = X(3);
101 
102  /* attitude */
103  /* FIXME: better asin(e1(3)) ? */
104  dMeasure[ATTITUDE] = std::atan2(e1(3), e1(1));
105 
106  /* bank */
107  /* FIXME: better asin(e2(3)) ? */
108  dMeasure[BANK] = -std::atan2(e2(3), e2(2));
109 
110  /* turn */
111  dMeasure[TURN] = 0.; /* FIXME */
112 
113  /* slip */
114  dMeasure[SLIP] = 0.; /* FIXME */
115 
116  /* vertical speed */
117  dMeasure[VERTICALSPEED] = VV(3);
118 
119  /* angle of attack */
120  VTmp = R.MulTV(VV);
121  dMeasure[AOA] = std::atan2(VTmp(3), VTmp(1));
122 
123  /* heading */
124  /* FIXME: assumes a flat world! N={1,0,0}, W={0,1,0} */
125  dMeasure[HEADING] = -std::atan2(e1(2), e1(1));
126 
127  /* longitude */
128  /* FIXME: ??? */
129  dMeasure[LONGITUDE] = -X(2); // /EARTH_RADIUS?
130 
131  /* latitude */
132  /* FIXME: ??? */
133  dMeasure[LATITUDE] = X(1); // /EARTH_RADIUS?
134 
135  VTmp = R.MulTV(Omega);
136  dMeasure[ROLLRATE] = VTmp(1);
137  dMeasure[PITCHRATE] = VTmp(2);
138  dMeasure[YAWRATE] = VTmp(3);
139 }
const Vec3 Zero3(0., 0., 0.)
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
Vec3 GetVec(unsigned short int i) const
Definition: matvec3.h:893
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
doublereal dMeasure[LASTMEASURE]
Definition: instruments.h:66
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
const StructNode * pNode
Definition: instruments.h:63
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
virtual flag fGetAirVelocity(Vec3 &Velocity, const Vec3 &X) const
Definition: aerodyn.cc:725
GradientExpression< BinaryExpr< FuncAtan2, LhsExpr, RhsExpr > > atan2(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2962
Mat3x3 R

Here is the call graph for this function:

void AircraftInstruments::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 170 of file instruments.cc.

171 {
172  *piNumRows = 0;
173  *piNumCols = 0;
174 }

Member Data Documentation

doublereal AircraftInstruments::dMeasure[LASTMEASURE]
protected

Definition at line 66 of file instruments.h.

Referenced by AircraftInstruments(), dGetPrivData(), Output(), and Update().

const StructNode* AircraftInstruments::pNode
protected

Definition at line 63 of file instruments.h.

Referenced by GetConnectedNodes(), Restart(), and Update().

Mat3x3 AircraftInstruments::Rh
protected

Definition at line 64 of file instruments.h.

Referenced by Restart(), and Update().


The documentation for this class was generated from the following files: