Marine systems simulation
CVisualRBQuat.h
1/*
2* Class CVisualRBQuat (SimObject)
3* Author: Biao Su
4
5* This class enables visualization of a rigid body with triangular mesh.
6*/
7
12#ifndef CVisualRBQuat_H
13#define CVisualRBQuat_H
14
15#include <string>
16#include <Eigen/Eigen>
17#include <iostream>
18#include <iomanip>
19#include <fstream>
20#include <algorithm>
21#include <vector>
22#include <valarray>
23
24#include "SimObject.h"
25
26#include "sfh/text.h"
27#include "sfh/math/math.h"
28#include "sfh/sim/kinematics.h"
29#include "sfh/constants.h"
30
31
32namespace Visualization {
33
34typedef Eigen::Matrix<double, 3, 1> vec3;
35typedef Eigen::Matrix<int, 3, 1> vec3i;
36typedef Eigen::Quaternion<double> quat;
37
38class CVisualRBQuat : public SimObject
39{
40public:
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42
43 // Constructor
44 CVisualRBQuat(std::string sSimObjectName, ISimObjectCreator* pCreator);
45 virtual ~CVisualRBQuat() {};
46 virtual void InitialConditionSetup(const double T, const double* const X, double* const XDot, ISimObjectCreator* pCreator);
48 virtual void OdeFcn(const double T, const double* const X, double* const XDot, const bool bIsMajorTimeStep);
49
50#ifdef FH_VISUALIZATION
51 // Initial specification of the simObject geometry for rendering.
52 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const pCreator);
53
54 // Updating the simObject for rendering the next frame.
55 virtual void RenderUpdate(const double T, const double* const X);
56#endif
57
58protected:
59
60 // DOF
61 int m_DOFModes[6];
62 int m_DOFNum;
63 std::vector<int> m_DOFIndex;
64 double m_Scale;
65 vec3 m_RelPos;
66
67 // Input ports
68 ISignalPort* m_InPos;
69 bool m_InForce;
70 ISignalPort* m_ForceIn;
71 ISignalPort* m_InQuat;
72 ISignalPort* m_InVel;
73 ISignalPort* m_InOmega;
74
75 // Output ports
76 double m_DOFDirections[6];
77 double m_PosNED[3];
78 const double* PositionNED(const double T, const double* const X);
79 double m_QuatNED[4];
80 const double* QuaternionNED(const double T, const double* const X);
81 double m_ForceCoeffs[6];
82 double m_ForceOut[6];
83 const double* ForceOut(const double T, const double* const X);
84 double m_VelNED[3];
85 const double* VelocityNED(const double T, const double* const X);
86
87#ifdef FH_VISUALIZATION
88 Ogre::SceneNode* m_RenderNode;
89 Ogre::SceneManager* m_SceneMgr;
90#endif
91
92};
93
94};
95
96#endif
Definition: CVisualRBQuat.h:39
virtual void OdeFcn(const double T, const double *const X, double *const XDot, const bool bIsMajorTimeStep)
Calculate the state derivatives.