Marine systems simulation
CBall.h
1
2#ifndef CBALL_H
3#define CBALL_H
4
88// Includes
89#include "SimObject.h"
90
91#include "sfh/timers/Timer.h"
92
93#include <Eigen/Core>
94#include <Eigen/Geometry>
95
96#include <limits>
97#include <ostream>
98#include <string>
99#include <vector>
100
101class CBall : public SimObject
102{
103 public:
115 CBall(std::string simObjectName, ISimObjectCreator* creator);
116
117 ~CBall();
118
119#ifdef FH_VISUALIZATION
120
122 virtual void RenderInit(Ogre::Root* const OgreRoot, ISimObjectCreator* const creator);
123
125 virtual void RenderUpdate(const double T, const double* const X);
126#endif
127
139 void OdeFcn(const double T, const double* const X, double* const XDot, const bool IsMajorTimeStep);
140
150 const double* ForceOut(const double T, const double* const X);
151
152 protected:
162 void CalcForces(const double T, const double* const X);
163
172 void ForceInterBall(const double T, const double* const X);
173
181 virtual const double* Position(const double T, const double* const X);
182
190 virtual const double* Velocity(const double T, const double* const X);
191
192 // Member variables
193 int m_count;
194 double m_gravity;
195 double* m_mass;
196 double* m_radius;
197 double* m_stiffness;
198 double m_boxDim[3];
199 Eigen::Vector3d m_norms[6];
200 int m_planeSide[6];
201 Eigen::VectorXd m_forces;
202 Eigen::VectorXd m_interForces;
203
204 ISignalPort* m_inBoxPos;
205 ISignalPort* m_inBoxRot;
208
209 double m_outForce[3];
210 double m_time;
211
212
213#ifdef FH_VISUALIZATION
214 std::string m_material;
215 std::string m_meshName;
216 double m_scale;
217 Ogre::SceneManager* m_sceneMgr;
218 vector<Ogre::SceneNode*> m_renderNodes;
219 vector<Ogre::Entity*> m_renderEntities;
220#endif
221};
222
223#endif
Definition: CBall.h:102
Eigen::VectorXd m_interForces
3-DOF force acting on each ball i (col(F_i)) from the box. [N]
Definition: CBall.h:202
virtual const double * Velocity(const double T, const double *const X)
Returns the position of the balls.
const double * ForceOut(const double T, const double *const X)
Returns the force acting from the balls on the box.
CBall(std::string simObjectName, ISimObjectCreator *creator)
Reads parameters, registers states, input/output ports and shared resources.
void CalcForces(const double T, const double *const X)
Calculates contact forces between balls and box.
void ForceInterBall(const double T, const double *const X)
Calculates contact forces between the balls.
int m_iStatePos
Orientation of the box, Euler angles, x,y,z [rad].
Definition: CBall.h:206
Eigen::VectorXd m_forces
Side of the plane, relative normal vector (-1: inside, 1: outside, else: undef)
Definition: CBall.h:201
double m_time
The force acting on the box. [N].
Definition: CBall.h:210
double m_outForce[3]
The index of the velocity state.
Definition: CBall.h:209
ISignalPort * m_inBoxPos
3-DOF force acting between each ball i (col(F_i)). [N]
Definition: CBall.h:204
double * m_radius
The masses of the balls. [kg].
Definition: CBall.h:196
double m_gravity
Number of balls [#].
Definition: CBall.h:194
Eigen::Vector3d m_norms[6]
The dimensions of the box Lx, Ly, Lz [m].
Definition: CBall.h:199
void OdeFcn(const double T, const double *const X, double *const XDot, const bool IsMajorTimeStep)
Cleans up dynamically allocated memory.
double * m_mass
The gravity (assumed along z-axis) [kgms^-2].
Definition: CBall.h:195
double m_boxDim[3]
The linear stiffnesses of the ball. [N/m].
Definition: CBall.h:198
int m_planeSide[6]
Array of box unit normal vectors [-].
Definition: CBall.h:200
double * m_stiffness
The radii of the balls. [m].
Definition: CBall.h:197
int m_iStateVel
The index of the position state.
Definition: CBall.h:207
ISignalPort * m_inBoxRot
Centroid of the box [m].
Definition: CBall.h:205
virtual const double * Position(const double T, const double *const X)
Returns the velocity of the balls.