|
| | CBall (std::string simObjectName, ISimObjectCreator *creator) |
| | Reads parameters, registers states, input/output ports and shared resources.
|
| |
| void | OdeFcn (const double T, const double *const X, double *const XDot) const |
| | Cleans up dynamically allocated memory.
|
| |
|
bool | HasJacobians () const override |
| |
|
void | OdeJacobian (double T, const double *X, double *J, int nStates) override |
| |
|
int | GetJacobianSparsity (int nStates, int *rowPtr, int *colIdx) override |
| |
| const double * | ForceOut (const double T, const double *const X) |
| | Returns the force acting from the balls on the box.
|
| |
|
| void | CalcForces (const double T, const double *const X) const |
| | Calculates contact forces between balls and box.
|
| |
| void | ForceInterBall (const double T, const double *const X) const |
| | Calculates contact forces between the balls.
|
| |
| void | AddWallStiffness (const double T, const double *const X, Eigen::MatrixXd &forceJacobian) const |
| |
| void | AddInterBallStiffness (const double *const X, Eigen::MatrixXd &forceJacobian) const |
| |
| void | BoxPlanes (const double T, const double *const X, Eigen::Vector3d norms[6], Eigen::Vector3d planePositions[6]) const |
| |
|
void | LatchPlaneSide (int pl, double s) const |
| | Fixes m_planeSide[pl] from the signed distance s to the wall at the first evaluation.
|
| |
| bool | IsWallContact (int pl, double s, double dL, double radius) const |
| |
| virtual const double * | Position (const double T, const double *const X) |
| | Returns the velocity of the balls.
|
| |
| virtual const double * | Velocity (const double T, const double *const X) |
| | Returns the position of the balls.
|
| |
| int | LocalIndex (int globalStateIndex) const |
| | The index of the velocity state.
|
| |
|
|
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 std::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] |
| |
◆ 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 |
◆ AddInterBallStiffness()
| void CBall::AddInterBallStiffness |
( |
const double *const |
X, |
|
|
Eigen::MatrixXd & |
forceJacobian |
|
) |
| const |
|
protected |
Adds d(m_interForces)/d(pos), the contact stiffness between the balls, to forceJacobian.
Each pair in contact, as ForceInterBall tests it, pushes the two balls apart equally.
- Parameters
-
| [in] | X | -> model-global states |
| [in,out] | forceJacobian | -> 3*Count by 3*Count, rows ball forces, columns ball positions |
◆ AddWallStiffness()
| void CBall::AddWallStiffness |
( |
const double |
T, |
|
|
const double *const |
X, |
|
|
Eigen::MatrixXd & |
forceJacobian |
|
) |
| const |
|
protected |
Adds d(-m_forces)/d(pos), the contact stiffness of the walls, to forceJacobian.
Uses the same contact test as CalcForces, and latches m_planeSide as it does.
- Parameters
-
| [in] | T | -> time |
| [in] | X | -> model-global states |
| [in,out] | forceJacobian | -> 3*Count by 3*Count, rows ball forces, columns ball positions |
◆ BoxPlanes()
| void CBall::BoxPlanes |
( |
const double |
T, |
|
|
const double *const |
X, |
|
|
Eigen::Vector3d |
norms[6], |
|
|
Eigen::Vector3d |
planePositions[6] |
|
) |
| const |
|
protected |
Unit outward normals of the six walls and one point on each, from the box ports.
- Parameters
-
| [in] | T | -> time |
| [in] | X | -> model-global states |
| [out] | norms | -> unit normal of each wall |
| [out] | planePositions | -> a point in each wall |
◆ CalcForces()
| void CBall::CalcForces |
( |
const double |
T, |
|
|
const double *const |
X |
|
) |
| const |
|
protected |
Updates the forces acting between balls as well as the the forces acting on each plane of the box, from the states it is given, at every call. This function calls ForceInterBall.
- Parameters
-
| [in] | T | -> time |
| [in] | X | -> states |
◆ ForceInterBall()
| void CBall::ForceInterBall |
( |
const double |
T, |
|
|
const double *const |
X |
|
) |
| const |
|
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
◆ IsWallContact()
| bool CBall::IsWallContact |
( |
int |
pl, |
|
|
double |
s, |
|
|
double |
dL, |
|
|
double |
radius |
|
) |
| const |
|
protected |
Whether wall pl pushes on a ball at signed distance s and distance dL of radius radius.
A ball on the outside of the wall is always pushed back; one on the inside only when it overlaps the wall.
◆ LocalIndex()
| int CBall::LocalIndex |
( |
int |
globalStateIndex | ) |
const |
|
inlineprotected |
Turns a model-global state index into one local to this SimObject.
OdeFcn and the port functions are handed the whole model's state vector, so they use the global indices AddState returned directly. OdeJacobian is handed this object's own slice, whose first element is the first ball's Pos, so every index it uses goes through this function (BASE-0033).
◆ OdeFcn()
| void CBall::OdeFcn |
( |
const double |
T, |
|
|
const double *const |
X, |
|
|
double *const |
XDot |
|
) |
| const |
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:
- webfhsim/reloadrepos/fhsim_base/src/ballbox/CBall.h