DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
RigidBody Class Reference

Rigid body dynamics function, calculates derivative of a rigid body, given sum of moments and forces and the acting gravity field. More...

#include <RigidBody.hxx>

Inheritance diagram for RigidBody:
Inheritance graph
[legend]

Public Member Functions

 RigidBody (double mass, double Jxx, double Jyy, double Jzz, double Jxy, double Jxz, double Jyz, int extrastates=0)
 Simple constructor for a rigid body dynamics module.
 
 ~RigidBody ()
 Destructor.
 
void initialize (double x, double y, double z, double u, double v, double w, double phi, double theta, double psi, double p, double q, double r)
 Initialize a state vector x.
 
void derivative (VectorE &xd, double unused=0.0)
 Obtain and calculate the derivative, given sum of forces and moments and the gravitational field acting on the body.
 
template<class V >
void derivative (V &xd, double unused=0.0)
 Obtain and calculate the derivative, given sum of forces and moments and the gravitational field acting on the body.
 
void specific (Vector &sp)
 Calculate specific forces and moments, forces stored in elements 0, 1, and 2, moments in elements 3, 4 and 6.
 
void zeroForces ()
 Initialize sum of forces on the body to zero.
 
void applyBodyForce (const Vector3 &Fb, const Vector3 &point)
 Apply a force expressed in body coordinates.
 
void applyInertialForce (const Vector &Fi, const Vector &point)
 Apply a force expressed in inertial coordinates, at a specific body point, give in body coordinates.
 
void applyBodyMoment (const Vector &M)
 Apply a moment expressed in body coordinates.
 
void changeState (const Vector &dx)
 Change the state vector by a quantity dx.
 
void addInertialGravity (const Vector &g)
 Add a gravitational field; 3 element vector, gravitation expressed in the inertial system.
 
void setState (const Vector &newx)
 Put in a new state vector.
 
void changeMass (const double dm)
 Add to the mass of the body.
 
void setMass (const double newm)
 Set a new mass.
 
void output ()
 Calculate auxiliary outputs, V, \(\alpha\), \(\beta\), \(\phi\), \(\theta\) and \(\Psi\).
 
const VectorX () const
 Obtain the state, 13 elements.
 
const double V () const
 Obtain speed.
 
const double alpha () const
 Obtain alpha.
 
const double beta () const
 Obtain beta.
 
const double getMass () const
 Get current mass.
 
const double phi () const
 Get euler angle phi.
 
const double theta () const
 Get euler angle theta.
 
const double psi () const
 Get euler angle psi.
 
const Matrix3A ()
 Get the transformation matrix, for transforming a vector in earth coordinates to one in the body's coordinate system.
 

Protected Attributes

Vector x
 State vector.
 

Detailed Description

Rigid body dynamics function, calculates derivative of a rigid body, given sum of moments and forces and the acting gravity field.

The contents of the state vector are:

u, v, w, x, y, z, p, q, r, l1, l2, l3, L

Note that the RigidBody class only calculates the derivatives. If you want to integrate the equations of motion, you need an integration routine. Two templated integration functions are available, integrate_euler() and integrate_rungekutta().

The normal procedure would be to create a class that derives from the RigidBody class. You can also indicate that a number of additional state variables is needed, the RigidBody class will make these available to you, from index 13 onward.

The normal "work cycle" would be to call RigidBody::zeroForces(), which zeroes forces and gravity applied to the body, then repeatedly call RigidBody::applyBodyForce(), RigidBody::applyInertialForce(), RigidBody::applyBodyMoment() RigidBody::addInertialGravity() as needed, until all forces (drag, lift, wheel forces, thrusters, whatever) and all gravitational effects have been applied.

Then call RigidBody::derivative() to obtain the derivative.

RigidBody::specific(), RigidBody::X() and RigidBody::phi(), RigidBody::theta(), RigidBody::psi() can be used to get your outputs.

Examples
PulsedBody.cxx, and PulsedBody.hxx.

Constructor & Destructor Documentation

◆ RigidBody()

RigidBody::RigidBody ( double mass,
double Jxx,
double Jyy,
double Jzz,
double Jxy,
double Jxz,
double Jyz,
int extrastates = 0 )

Simple constructor for a rigid body dynamics module.

Note that motion is always described around center of mass.

Parameters
massmass of the object
JxxMoment of inertia around x axis
JyyMoment of inertia around y axis
JzzMoment of inertia around z axis
JxyInertia cross product x and y
JxzInertia cross product x and z
JyzInertia cross product y and z
extrastatesNumber of additional states needed by derived classes.

Member Function Documentation

◆ initialize()

void RigidBody::initialize ( double x,
double y,
double z,
double u,
double v,
double w,
double phi,
double theta,
double psi,
double p,
double q,
double r )

Initialize a state vector x.

Remember that x has 13 elements, due to the use of a quaternion representation.

Parameters
xCarthesian position, x direction
yCarthesian position, y direction
zCarthesian position, z direction
uVelocity, along body x axis
vVelocity, along body y axis
wVelocity, along body z axis
phiEuler angle phi
thetaEuler angle theta
psiEuler angle psi
pRotational velocity, along body x axis
qRotational velocity, along body y axis
rRotational velocity, along body z axis

◆ derivative() [1/2]

void RigidBody::derivative ( VectorE & xd,
double unused = 0.0 )

Obtain and calculate the derivative, given sum of forces and moments and the gravitational field acting on the body.

Parameters
xdResultant derivative vector
unusedUnused variable, for compatibility with integration functions.
Examples
PulsedBody.cxx.

◆ derivative() [2/2]

template<class V >
void RigidBody::derivative ( V & xd,
double unused = 0.0 )
inline

Obtain and calculate the derivative, given sum of forces and moments and the gravitational field acting on the body.

Template Parameters
VVector type
Parameters
xdResultant derivative vector
unusedUnused variable, for compatibility with integration functions.

◆ specific()

void RigidBody::specific ( Vector & sp)

Calculate specific forces and moments, forces stored in elements 0, 1, and 2, moments in elements 3, 4 and 6.

Forces and moments calculated in body coordinates.

Parameters
spVector with 6 elements, for result.
Examples
PulsedBody.cxx.

◆ zeroForces()

void RigidBody::zeroForces ( )

Initialize sum of forces on the body to zero.

Call before applying a new set of forces and moments.

Examples
PulsedBody.cxx.

◆ applyBodyForce()

void RigidBody::applyBodyForce ( const Vector3 & Fb,
const Vector3 & point )

Apply a force expressed in body coordinates.

at a specific body point.

Examples
PulsedBody.cxx.

◆ setState()

void RigidBody::setState ( const Vector & newx)

Put in a new state vector.

Note that you need a 13-element vector

◆ A()

const Matrix3 & RigidBody::A ( )
inline

Get the transformation matrix, for transforming a vector in earth coordinates to one in the body's coordinate system.

Note that for the reverse translation, you need the transpose of this matrix. Example:

// suspension_point_b is a vector in the body coordinate system,
// defining the location of the wheel suspension
// point. This calculates that position in earth coordinates
mult(trans(body.A()), suspension_point_b, body.X()(3,6),
suspension_point_e);
// Mult(A, x, y, z) z <- A x + y, see MTL documentation. State
// elements 3, 4, 5 (body.X()(3,6)) contain the c.g. position in
// earth coordinates.

Member Data Documentation

◆ x

Vector RigidBody::x
protected

State vector.

Contents: u, v, w, x, y, z, then p, q, r, l1, l2, l3, L. After this, thus from state 13 onwards, the state vector contains states for derived classes.

Examples
PulsedBody.cxx.

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