DUECA/DUSIME
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...

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. More...
 
 ~RigidBody ()
 Destructor. More...
 
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. More...
 
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. More...
 
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. More...
 
void specific (Vector &sp)
 Calculate specific forces and moments, forces stored in elements 0, 1, and 2, moments in elements 3, 4 and 6. More...
 
void zeroForces ()
 Initialize sum of forces on the body to zero. More...
 
void applyBodyForce (const Vector3 &Fb, const Vector3 &point)
 Apply a force expressed in body coordinates. More...
 
void applyInertialForce (const Vector &Fi, const Vector &point)
 Apply a force expressed in inertial coordinates, at a specific body point, give in body coordinates. More...
 
void applyBodyMoment (const Vector &M)
 Apply a moment expressed in body coordinates. More...
 
void changeState (const Vector &dx)
 Change the state vector by a quantity dx. More...
 
void addInertialGravity (const Vector &g)
 Add a gravitational field; 3 element vector, gravitation expressed in the inertial system. More...
 
void setState (const Vector &newx)
 Put in a new state vector. More...
 
void changeMass (const double dm)
 Add to the mass of the body. More...
 
void setMass (const double newm)
 Set a new mass. More...
 
void output ()
 Calculate auxiliary outputs, V, \(\alpha\), \(\beta\), \(\phi\), \(\theta\) and \(\Psi\). More...
 
const VectorX () const
 Obtain the state, 13 elements. More...
 
const double V () const
 Obtain speed. More...
 
const double alpha () const
 Obtain alpha. More...
 
const double beta () const
 Obtain beta. More...
 
const double getMass () const
 Get current mass. More...
 
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. More...
 

Protected Attributes

Vector x
 State vector. More...
 

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.

◆ ~RigidBody()

RigidBody::~RigidBody ( )

Destructor.

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.

◆ applyInertialForce()

void RigidBody::applyInertialForce ( const Vector Fi,
const Vector point 
)

Apply a force expressed in inertial coordinates, at a specific body point, give in body coordinates.

◆ applyBodyMoment()

void RigidBody::applyBodyMoment ( const Vector M)

Apply a moment expressed in body coordinates.

◆ changeState()

void RigidBody::changeState ( const Vector dx)

Change the state vector by a quantity dx.

◆ addInertialGravity()

void RigidBody::addInertialGravity ( const Vector g)

Add a gravitational field; 3 element vector, gravitation expressed in the inertial system.

Examples:
PulsedBody.cxx.

◆ setState()

void RigidBody::setState ( const Vector newx)

Put in a new state vector.

Note that you need a 13-element vector

◆ changeMass()

void RigidBody::changeMass ( const double  dm)

Add to the mass of the body.

◆ setMass()

void RigidBody::setMass ( const double  newm)

Set a new mass.

◆ output()

void RigidBody::output ( )

Calculate auxiliary outputs, V, \(\alpha\), \(\beta\), \(\phi\), \(\theta\) and \(\Psi\).

Examples:
PulsedBody.cxx.

◆ X()

const Vector& RigidBody::X ( ) const
inline

Obtain the state, 13 elements.

Examples:
PulsedBody.cxx.

◆ V()

const double RigidBody::V ( ) const
inline

Obtain speed.

Examples:
PulsedBody.cxx.

◆ alpha()

const double RigidBody::alpha ( ) const
inline

Obtain alpha.

Examples:
PulsedBody.cxx.

◆ beta()

const double RigidBody::beta ( ) const
inline

Obtain beta.

Examples:
PulsedBody.cxx.

◆ getMass()

const double RigidBody::getMass ( ) const
inline

Get current mass.

◆ 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: