11 #include <jrl/mal/matrixabstractlayer.hh>
14 #include "jrl/dynamics/dynamicsfactory.hh"
16 using namespace dynamicsJRLJapan;
20 if (aJoint == 0)
return;
21 int NbChildren = aJoint->countChildJoints();
22 cout <<
" rank : " << aJoint->rankInConfiguration() << endl;
24 for (
int i = 0;
i < NbChildren;
i++) {
30 std::vector<CjrlJoint *> aVec = aDynamicRobot->jointVector();
32 cout <<
"Number of joints :" <<
r << endl;
33 for (
int i = 0;
i <
r;
i++) {
34 cout << aVec[
i]->rankInConfiguration() << endl;
39 for (
unsigned int i = 0;
i < 6;
i++) {
40 for (
unsigned int j = 0; j < MAL_MATRIX_NB_COLS(aJ); j++) {
44 printf(
"%10.5f ", aJ(
i, j));
52 cout <<
"Mass-inertie property of joint ranked :"
53 << startJoint->rankInConfiguration() << endl;
54 cout <<
"Mass of the body: " << startJoint->linkedBody()->mass() << endl;
55 cout <<
"llimit: " << startJoint->lowerBound(0) * 180 /
M_PI
56 <<
" ulimit: " << startJoint->upperBound(0) * 180 /
M_PI << endl;
57 cout << startJoint->currentTransformation() << endl;
59 if (startJoint->countChildJoints() != 0) {
60 const CjrlJoint *childJoint = startJoint->childJoint(0);
68 int main(
int argc,
char *argv[]) {
70 cerr <<
" This program takes 3 arguments: " << endl;
71 cerr <<
"./TestHumanoidDynamicRobot PATH_TO_VRML_FILE "
72 <<
"VRML_FILE_NAME PATH_TO_SPECIFICITIES_XML" << endl;
76 string aPath = argv[1];
77 string aName = argv[2];
86 dynamicsJRLJapan::ObjectFactory aRobotDynamicsObjectConstructor;
87 CjrlHumanoidDynamicRobot *aHDR =
88 aRobotDynamicsObjectConstructor.createHumanoidDynamicRobot();
92 string SpecificitiesFile = argv[3];
93 string RankFile = argv[3];
95 string RobotFileName = aPath + aName;
96 dynamicsJRLJapan::parseOpenHRPVRMLFile(*aHDR, RobotFileName, RankFile,
99 cout <<
"-> Finished the initialization" << endl;
103 CjrlJoint *rootJoint = aHDR->rootJoint();
107 double dInitPos[40] = {
108 0.0, 0.0, -26.0, 50.0, -24.0, 0.0, 0.0,
109 0.0, -26.0, 50.0, -24.0, 0.0,
113 15.0, -10.0, 0.0, -30.0, 0.0, 0.0, 10.0,
114 15.0, 10.0, 0.0, -30.0, 0.0, 0.0, 10.0,
116 -20.0, 20.0, -20.0, 20.0, -20.0,
117 -10.0, 10.0, -10.0, 10.0, -10.0
120 int NbOfDofs = aHDR->numberDof();
121 cout <<
"NbOfDofs :" << NbOfDofs << endl;
124 MAL_VECTOR_DIM(aCurrentConf,
double, NbOfDofs);
125 for (
int i = 0;
i < ((NbOfDofs < 46) ? NbOfDofs : 46); ++
i)
127 aCurrentConf[
i] = 0.0;
129 aCurrentConf[
i] = dInitPos[
i - 6] *
M_PI / 180.0;
130 aHDR->currentConfiguration(aCurrentConf);
133 MAL_VECTOR_DIM(aCurrentVel,
double, NbOfDofs);
134 for (
int i = 0;
i < NbOfDofs;
i++) aCurrentVel[
i] = 0.0;
135 aHDR->currentVelocity(aCurrentVel);
138 MAL_S3_VECTOR(ZMPval,
double);
139 string Property(
"ComputeZMP");
140 string Value(
"true");
141 aHDR->setProperty(Property, Value);
142 aHDR->computeForwardKinematics();
143 ZMPval = aHDR->zeroMomentumPoint();
144 cout <<
"First value of ZMP : " << ZMPval << endl;
145 cout <<
"Should be equal to the CoM (on x-y): "
146 << aHDR->positionCenterOfMass() << endl;
150 cout <<
"****************************" << endl;
151 cout <<
"Rank of the left hand " << endl;
152 cout << aHDR->leftWrist()->rankInConfiguration() << endl;
154 vector<CjrlJoint *> aVec = aHDR->jointVector();
155 CjrlJoint *aJoint = aVec[22];
156 aJoint->computeJacobianJointWrtConfig();
157 MAL_MATRIX(aJ,
double);
158 aJ = aJoint->jacobianJointWrtConfig();
162 cout <<
"****************************" << endl;
163 rootJoint->computeJacobianJointWrtConfig();
164 aJ = rootJoint->jacobianJointWrtConfig();
165 cout <<
"Rank of Root: " << rootJoint->rankInConfiguration() << endl;
166 aJoint = aHDR->waist();
169 cout <<
"****************************" << endl;
171 aHDR->getJacobianCenterOfMass(*aHDR->rootJoint(), jacobian);
172 cout <<
"Value of the CoM's Jacobian:" << endl << jacobian << endl;
175 cout <<
"****************************" << endl;
177 cout <<
"Mass of the robot " << aHDR->mass() << endl;
178 cout <<
"Force " << aHDR->mass() * 9.81 << endl;
180 cout <<
"****************************" << endl;
181 MAL_VECTOR_FILL(aCurrentVel, 0.0);
182 MAL_VECTOR_DIM(aCurrentAcc,
double, NbOfDofs);
183 MAL_VECTOR_FILL(aCurrentAcc, 0.0);
187 string Properties[4] = {
"TimeStep",
"ComputeAcceleration",
188 "ComputeBackwardDynamics",
"ComputeZMP"};
189 string Values[4] = {
"0.005",
"false",
"false",
"true"};
190 for (
unsigned int i = 0;
i < 4;
i++)
191 aHDR->setProperty(Properties[
i],
Values[
i]);
193 for (
int i = 0;
i < 4;
i++) {
194 aHDR->currentVelocity(aCurrentVel);
195 aHDR->currentAcceleration(aCurrentAcc);
196 aHDR->computeForwardKinematics();
197 ZMPval = aHDR->zeroMomentumPoint();
198 cout <<
i <<
"-th value of ZMP : " << ZMPval << endl;
199 cout <<
"Should be equal to the CoM: " << aHDR->positionCenterOfMass()