Marine systems simulation
CBall Class Reference
+ Inheritance diagram for CBall:
+ Collaboration diagram for CBall:

Public Member Functions

 CBall (std::string simObjectName, ISimObjectCreator *creator)
 Reads parameters, registers states, input/output ports and shared resources. More...
 
void OdeFcn (const double T, const double *const X, double *const XDot, const bool IsMajorTimeStep)
 Cleans up dynamically allocated memory. More...
 
const double * ForceOut (const double T, const double *const X)
 Returns the force acting from the balls on the box. More...
 

Protected Member Functions

void CalcForces (const double T, const double *const X)
 Calculates contact forces between balls and box. More...
 
void ForceInterBall (const double T, const double *const X)
 Calculates contact forces between the balls. More...
 
virtual const double * Position (const double T, const double *const X)
 Returns the velocity of the balls. More...
 
virtual const double * Velocity (const double T, const double *const X)
 Returns the position of the balls. More...
 

Protected Attributes

int m_count
 
double m_gravity
 Number of balls [#].
 
double * m_mass
 The gravity (assumed along z-axis) [kgms^-2].
 
double * m_radius
 The masses of the balls. [kg].
 
double * m_stiffness
 The radii of the balls. [m].
 
double m_boxDim [3]
 The linear stiffnesses of the ball. [N/m].
 
Eigen::Vector3d m_norms [6]
 The dimensions of the box Lx, Ly, Lz [m].
 
int m_planeSide [6]
 Array of box unit normal vectors [-].
 
Eigen::VectorXd m_forces
 Side of the plane, relative normal vector (-1: inside, 1: outside, else: undef)
 
Eigen::VectorXd m_interForces
 3-DOF force acting on each ball i (col(F_i)) from the box. [N]
 
ISignalPort * m_inBoxPos
 3-DOF force acting between each ball i (col(F_i)). [N]
 
ISignalPort * m_inBoxRot
 Centroid of the box [m].
 
int m_iStatePos
 Orientation of the box, Euler angles, x,y,z [rad].
 
int m_iStateVel
 The index of the position state.
 
double m_outForce [3]
 The index of the velocity state.
 
double m_time
 The force acting on the box. [N].
 

Constructor & Destructor Documentation

◆ CBall()

CBall::CBall ( std::string  simObjectName,
ISimObjectCreator *  creator 
)

This constructor performs all initial setup for a ball SimObject. Reading in parameters, setting up communication interface i.e. output ports, input ports, and states, plus additional 'one time only' resource setup.

Parameters
[in]simObjectName-> The name of the simobject. Used primarily by superclass constructor
[in]creator-> Retrieve parameters. Register states, ports and shared resources

Member Function Documentation

◆ CalcForces()

void CBall::CalcForces ( const double  T,
const double *const  X 
)
protected

Updates the forces acting between balls as well as the the forces acting on each plane of the box if the not calculated for this time step. This function calls ForceInterBall.

Parameters
[in]T-> time
[in]X-> states

◆ ForceInterBall()

void CBall::ForceInterBall ( const double  T,
const double *const  X 
)
protected

Updates the forces acting between each ball.

Parameters
[in]T-> time
[in]X-> states

◆ ForceOut()

const double * CBall::ForceOut ( const double  T,
const double *const  X 
)

Returns the net force from the balls on the box. 3-dof.

Parameters
[in]T-> time
[in]X-> states
Returns
-> 3-dof force array

◆ OdeFcn()

void CBall::OdeFcn ( const double  T,
const double *const  X,
double *const  XDot,
const bool  IsMajorTimeStep 
)

Computes object derivatives as a function of time, states and input ports

Returns state derivatives. Velocity as derivative of position, external-force/mass and gravity as derivative of velocity.

Parameters
[in]T-> current simulation time
[in]X-> current simulation state
[out]XDot-> state derivatives
[in]IsMajorTimeStep-> Is this a major time step?

◆ Position()

virtual const double * CBall::Position ( const double  T,
const double *const  X 
)
protectedvirtual
Parameters
[in]T-> time
[in]X-> states
Returns
-> The velocities n*3

◆ Velocity()

virtual const double * CBall::Velocity ( const double  T,
const double *const  X 
)
protectedvirtual
Parameters
[in]T-> time
[in]X-> states
Returns
-> The velocities n*3

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