#include <iostream>
{
public:
double tau_e;
double dt;
Vector force;
Vector fpoint;
Vector gravity;
PulsedBody(double dt);
~PulsedBody();
void step();
};
PulsedBody::PulsedBody(double dt) :
RigidBody(100.0, 5.0, 6.0, 9.0, 0.0, 0.0, 0.0, 1),
tau_e(1.2),
dt(dt),
force(Vector::Zero(3)),
fpoint(Vector::Zero(3)),
gravity(Vector::Zero(3)),
workspace(14)
{
fpoint[2] = -1.0;
fpoint[0] = 1e-8;
gravity[2] = 9.810665;
}
PulsedBody::~PulsedBody()
{
}
void PulsedBody::derivative(
VectorE& xd,
double dt_offset)
{
xd[13] = (1330.0 - x[13]) / tau_e;
zeroForces();
force.setZero();
force[2] = -x[13];
applyBodyForce(force, fpoint);
addInertialGravity(gravity);
return;
}
void PulsedBody::step()
{
std::cout << X() << std::endl;
output();
std::cout << "psi=" << psi() << " theta=" << theta() << " phi=" << phi()
<< " V=" << V() << " alpha=" << alpha() << " beta=" << beta() << std::endl;
specific(sp);
std::cout << sp << std::endl;
}
int main()
{
PulsedBody pb(0.1);
for (int ii = 1000; ii--; ) {
pb.step();
}
return 0;
}
Helper class for implementing rigid body vehicle simulation.
Eigen::Map< Eigen::VectorXd > VectorE
a vector that takes external storage
Definition RigidBody.hxx:49
Rigid body dynamics function, calculates derivative of a rigid body, given sum of moments and forces ...
Definition RigidBody.hxx:108
void derivative(VectorE &xd, double unused=0.0)
Obtain and calculate the derivative, given sum of forces and moments and the gravitational field acti...
This defines a "data-pack", with room for workspace for the Runge-Kutta integration.
Definition integrate_rungekutta.hxx:38
Here a template function for Runge-Kutta integration is defined.
void integrate_rungekutta(MOD &model, RungeKuttaWorkspace &ws, double dt)
This function applies one Runge Kutta integration step to the state given in the kinematics argument.
Definition integrate_rungekutta.hxx:101