rigidBodyDynamics: Added dictionary-based IO of the rigidBodyModel
This commit is contained in:
38
applications/test/rigidBodyDynamics/pendulum/pendulum
Normal file
38
applications/test/rigidBodyDynamics/pendulum/pendulum
Normal file
@ -0,0 +1,38 @@
|
||||
bodies0
|
||||
{
|
||||
pendulum
|
||||
{
|
||||
type rigidBody;
|
||||
parent root;
|
||||
mass 1;
|
||||
centreOfMass (0 -1 0);
|
||||
inertia (0.001 0 0 0.001 0 0.001);
|
||||
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
|
||||
joint
|
||||
{
|
||||
type Rz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bodies
|
||||
{
|
||||
hinge
|
||||
{
|
||||
type masslessBody;
|
||||
parent root;
|
||||
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
|
||||
joint
|
||||
{
|
||||
type Rz;
|
||||
}
|
||||
}
|
||||
weight
|
||||
{
|
||||
type sphere;
|
||||
mergeWith hinge;
|
||||
mass 1;
|
||||
radius 0.05;
|
||||
transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,7 @@ Description
|
||||
#include "masslessBody.H"
|
||||
#include "sphere.H"
|
||||
#include "joints.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
using namespace RBD;
|
||||
@ -42,7 +43,8 @@ using namespace RBD;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool testMerge = false;
|
||||
/*
|
||||
bool testMerge = true;
|
||||
|
||||
// Create a model for the pendulum
|
||||
rigidBodyModel pendulum;
|
||||
@ -55,7 +57,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
pendulum.bodyID("root"),
|
||||
Xt(Zero),
|
||||
joint::New(new joints::Rz(pendulum)),
|
||||
joint::New(new joints::Rz()),
|
||||
autoPtr<rigidBody>(new masslessBody("hinge"))
|
||||
);
|
||||
|
||||
@ -72,10 +74,16 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
pendulum.bodyID("root"),
|
||||
Xt(Zero),
|
||||
joint::New(new joints::Rz(pendulum)),
|
||||
joint::New(new joints::Rz()),
|
||||
rigidBody::New("pendulum", 1, vector(0, -1, 0), 1e-3*I)
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
// Create the pendulum model from dictionary
|
||||
rigidBodyModel pendulum(dictionary(IFstream("pendulum")()));
|
||||
|
||||
pendulum.write(Info);
|
||||
|
||||
// Create the joint-space state fields
|
||||
scalarField q(pendulum.nDoF(), Zero);
|
||||
@ -110,7 +118,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
qdot += 0.5*deltaT*qddot;
|
||||
|
||||
Info<< "Time << " << t << "s, angle = " << q[0] << "rad" << endl;
|
||||
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user