54 using namespace ROBOOP;
57 const Real PUMA560_data_DH[] =
58 {0, 0, 0, 0, M_PI/2.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0, 0, 0,
59 0, 0, 0, 0.4318, 0, 0, 0, 0, 17.4, -0.3638, 0.006, 0.2275, 0.13, 0, 0, 0.524, 0, 0.539, 0,
60 0, 0, 0.15005, 0.0203, -M_PI/2.0, 0, 0, 0, 4.8, -0.0203, -0.0141, 0.07, 0.066, 0, 0, 0.086, 0, 0.0125, 0,
61 0, 0, 0.4318, 0.0, M_PI/2.0, 0, 0, 0, 0.82, 0, 0.019, 0, 0.0018, 0, 0, 0.0013, 0, 0.0018, 0,
62 0, 0, 0, 0.0, -M_PI/2.0, 0, 0, 0, 0.34, 0.0, 0.0, 0.0, 0.0003, 0.0, 0.0, 0.0004, 0.0, 0.0003, 0,
63 0, 0, 0, 0, 0, 0, 0, 0, 0.09, 0.0, 0.0, 0.032, 0.00015, 0.0, 0.0, 0.00015, 0.0, 0.00004, 0};
64 Real PUMA560_data_mDH[] =
66 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0,
67 0, 0, 0, 0.0, -M_PI/2, 0, 0, 0, 17.4, 0.068, 0.006, -0.016, 0.13, 0, 0, 0.524, 0, 0.539, 0,
68 0, 0, -0.15005, 0.4318, 0, 0, 0, 0, 4.8, 0, -0.070, 0.014, 0.066, 0, 0, 0.0125, 0, 0.066, 0,
69 0, 0, -0.4318, 0.0203, -M_PI/2.0, 0, 0, 0, 0.82, 0.0, 0.0, -0.019, 0.0018, 0, 0, 0.0018, 0, 0.0013, 0,
70 0, 0, 0, 0, M_PI/2.0, 0, 0, 0, 0.34, 0, 0, 0.0, 0.0003, 0, 0, 0.0003, 0, 0.0004, 0,
71 0, 0, 0, 0, -M_PI/2, 0, 0, 0, 0.09, 0, 0, 0.032, 0.00015, 0, 0, 0.00015, 0, 0.00004, 0};
72 const Real PUMA560_motor[] =
73 {200e-6, -62.6111, 1.48e-3, 0,
74 200e-6, 107.815, .817e-3, 0,
75 200e-6, -53.7063, 1.38e-3, 0,
76 33e-6, 76.0364, 71.2e-6, 0,
77 33e-6, 71.923, 82.6e-6, 0,
78 33e-6, 76.686, 36.7e-6, 0};
80 const Real STANFORD_data_DH[] =
81 {0.0, 0.0, 0.4120, 0.0, -M_PI/2, 0,0,0,9.29, 0.0, 0.0175, -0.1105, 0.276, 0.0, 0, 0.255, 0.0, 0.071,0,0,0,0,0,
82 0.0, 0.0, 0.1540, 0.0, M_PI/2.0, 0,0,0,5.01, 0.0, -1.054, 0.0, 0.108, 0.0, 0.0, 0.018, 0.0, 0.1,0,0,0,0,0,
83 1.0, -M_PI/2.0, 0.0, 0.0, 0.0, 0,0,0,4.25, 0.0, 0.0, -6.447, 2.51, 0.0, 0.0, 2.51, 0.0, 0.006,0,0,0,0,0,
84 0.0, 0.0, 0.0, 0.0, -M_PI/2.0, 0,0,0,1.08, 0.0, 0.092, -0.054, 0.002, 0.0, 0.0, 0.001, 0.0, 0.001,0,0,0,0,0,
85 0.0, 0.0, 0.0, 0.0, M_PI/2.0, 0,0,0,0.63, 0.0, 0.0, 0.566, 0.003, 0.0, 0.0, 0.003, 0.0, 0.0004,0,0,0,0,0,
86 0.0, 0.0, 0.2630, 0.0, 0.0, 0,0,0,0.51, 0.0, 0.0, 1.5540, 0.013, 0.0, 0.0, 0.013, 0.0, 0.0003,0,0,0,0,0};
92 infile.open(
"source/test.txt");
94 cerr <<
"Cannot open file:";
95 cerr <<
"source/test.txt\n";
98 Matrix Test(4,4), p1(3,1);
99 Real a, eps = FloatingPointPrecision::Epsilon();
101 cout <<
"=====================================================\n";
102 cout <<
" ROBOOP -- A robotics object oriented package in C++ \n";;
103 cout <<
" TEST program \n";
104 cout <<
"=====================================================\n";
106 cout <<
"Machine epsilon = " << eps << endl;
109 cout <<
"Testing translation : ";
110 Real ott[] = {1.0,2.0,3.0};
112 for(i = 1; i <= 4; i++) {
113 for(
int j = 1; j <= 4; j++) {
117 a = (Test-
trans(p1)).MaximumAbsoluteValue();
119 cout <<
"Erreur = " << a << endl;
121 cout <<
"Ok" << endl;
124 cout <<
"Testing rotx : ";
125 for(i = 1; i <= 4; i++) {
126 for(
int j = 1; j <= 4; j++) {
130 a = (Test-
rotx(M_PI/6)).MaximumAbsoluteValue();
132 cout <<
"Erreur = " << a << endl;
134 cout <<
"Ok" << endl;
137 cout <<
"Testing roty : ";
138 for(i = 1; i <= 4; i++) {
139 for(
int j = 1; j <= 4; j++) {
143 a = (Test-
roty(M_PI/6)).MaximumAbsoluteValue();
145 cout <<
"Erreur = " << a << endl;
147 cout <<
"Ok" << endl;
150 cout <<
"Testing rotz : ";
151 for(i = 1; i <= 4; i++) {
152 for(
int j = 1; j <= 4; j++) {
156 a = (Test-
rotz(M_PI/6)).MaximumAbsoluteValue();
158 cout <<
"Erreur = " << a << endl;
160 cout <<
"Ok" << endl;
163 cout <<
"Testing roll-pitch-yaw : ";
164 for(i = 1; i <= 4; i++) {
165 for(
int j = 1; j <= 4; j++) {
169 a = (Test-
rpy(p1)).MaximumAbsoluteValue();
171 cout <<
"Erreur = " << a << endl;
173 cout <<
"Ok" << endl;
176 cout <<
"Testing rotation around vector : ";
177 for(i = 1; i <= 4; i++) {
178 for(
int j = 1; j <= 4; j++) {
182 a = (Test-
rotk(M_PI/2,p1)).MaximumAbsoluteValue();
184 cout <<
"Erreur = " << a << endl;
186 cout <<
"Ok" << endl;
190 cout <<
"Testing quaternion to rotation matrix : ";
191 for(i = 1; i <= 3; i++) {
192 for(
int j = 1; j <= 3; j++) {
198 ColumnVector v(3); v(1)=v(2)=0.0; v(3)=1.0;
200 a = (Test.SubMatrix(1,3,1,3)-q.R()).MaximumAbsoluteValue();
202 cout <<
"Erreur = " << a << endl;
204 cout <<
"Ok" << endl;
208 cout <<
"Testing quaternion to rotation matrix : ";
209 for(i = 1; i <= 3; i++) {
210 for(
int j = 1; j <= 3; j++) {
219 a = (Test.SubMatrix(1,3,1,3)-q.R()).MaximumAbsoluteValue();
221 cout <<
"Erreur = " << a << endl;
223 cout <<
"Ok" << endl;
226 cout <<
"Testing quaternion to transformation matrix : ";
227 for(i = 1; i <= 4; i++) {
228 for(
int j = 1; j <= 4; j++) {
232 a = (Test-q.T()).MaximumAbsoluteValue();
234 cout <<
"Erreur = " << a << endl;
236 cout <<
"Ok" << endl;
239 cout <<
"Testing rotation matrix to quaternion : ";
240 ColumnVector quat(4);
243 for(i = 1; i <= 4; i++) {
247 quat.SubMatrix(2,4,1,1) = qq.v();
248 a = (Test-quat).MaximumAbsoluteValue();
250 cout <<
"Erreur = " << a << endl;
252 cout <<
"Ok" << endl;
255 cout <<
"Testing transformation matrix to quaternion : ";
258 for(i = 1; i <= 4; i++) {
262 quat.SubMatrix(2,4,1,1) = qq.v();
263 a = (Test-quat).MaximumAbsoluteValue();
265 cout <<
"Erreur = " << a << endl;
267 cout <<
"Ok" << endl;
279 ColumnVector qr, q, qd, qdd;
280 ColumnVector Fext(3), Next(3);
283 cout <<
"Testing Puma 560 (DH) forward kinematic : ";
285 for(i = 1; i <= 4; i++) {
286 for(
int j = 1; j <= 4; j++) {
290 initrob = Matrix(6,19);
291 initrobm = Matrix(6,4);
292 initrob << PUMA560_data_DH;
293 initrobm << PUMA560_motor;
294 robot_DH =
Robot(initrob, initrobm);
296 qr = ColumnVector(dof);
299 a = (Test-robot_DH.
kine()).MaximumAbsoluteValue();
301 cout <<
"Erreur = " << a << endl;
303 cout <<
"Ok" << endl;
306 cout <<
"Testing Puma 560 (DH) jacobian in base frame : ";
308 for(i = 1; i <= 6; i++) {
309 for(
int j = 1; j <= 6; j++) {
313 a = (Test-robot_DH.
jacobian()).MaximumAbsoluteValue();
315 cout <<
"Erreur = " << a << endl;
317 cout <<
"Ok" << endl;
320 cout <<
"Testing Puma 560 (DH) jacobian in tool frame : ";
321 for(i = 1; i <= 6; i++) {
322 for(
int j = 1; j <= 6; j++) {
326 a = (Test-robot_DH.
jacobian(dof)).MaximumAbsoluteValue();
328 cout <<
"Erreur = " << a << endl;
330 cout <<
"Ok" << endl;
333 initrobm = Matrix(6,4);
335 robot_DH =
Robot(initrob,initrobm);
336 Test = Matrix(dof,1); Test = 0;
337 cout <<
"Testing Puma 560 (DH) torque : ";
338 for(i = 1; i <= dof; i++) {
344 a = (Test-robot_DH.
torque(qr, qd, qdd)).MaximumAbsoluteValue();
346 cout <<
"Erreur = " << a << endl;
348 cout <<
"Ok" << endl;
351 cout <<
"Testing Puma 560 (DH) inertia : ";
353 for(i = 1; i <= 6; i++) {
354 for(
int j = 1; j <= 6; j++){
358 a = (Test-robot_DH.
inertia(qr)).MaximumAbsoluteValue();
360 cout <<
"Erreur = " << a << endl;
362 cout <<
"Ok" << endl;
365 initrobm = Matrix(6,4);
366 initrobm << PUMA560_motor;
367 robot_DH =
Robot(initrob,initrobm);
370 cout <<
"Testing Puma 560 (DH) motor, torque : ";
371 Test = Matrix(dof,1);
372 for(i = 1; i <= dof; i++) {
375 a = (Test-robot_DH.
torque(qr, qd, qdd)).MaximumAbsoluteValue();
377 cout <<
"Erreur = " << a << endl;
379 cout <<
"Ok" << endl;
383 cout <<
"Testing Stanford (DH) forward kinematic : ";
385 for(i = 1; i <= 4; i++) {
386 for(
int j = 1; j <= 4; j++) {
390 initrob = Matrix(6,23);
391 initrob << STANFORD_data_DH;
392 robot_DH =
Robot(initrob);
394 qr = ColumnVector(dof);
397 a = (Test-robot_DH.
kine()).MaximumAbsoluteValue();
399 cout <<
"Erreur = " << a << endl;
401 cout <<
"Ok" << endl;
404 cout <<
"Testing Stanford (DH) jacobian in base frame : ";
406 for(i = 1; i <= 6; i++) {
407 for(
int j = 1; j <= 6; j++) {
411 a = (Test-robot_DH.
jacobian()).MaximumAbsoluteValue();
413 cout <<
"Erreur = " << a << endl;
415 cout <<
"Ok" << endl;
418 cout <<
"Testing Stanford (DH) jacobian in tool frame : ";
419 for(i = 1; i <= 6; i++) {
420 for(
int j = 1; j <= 6; j++) {
424 a = (Test-robot_DH.
jacobian(dof)).MaximumAbsoluteValue();
426 cout <<
"Erreur = " << a << endl;
428 cout <<
"Ok" << endl;
431 Test = Matrix(dof,1); Test = 0;
432 cout <<
"Testing Stanford (DH) torque : ";
433 for(i = 1; i <= dof; i++) {
436 a = (Test-robot_DH.
torque(qr, qd, qdd)).MaximumAbsoluteValue();
438 cout <<
"Erreur = " << a << endl;
440 cout <<
"Ok" << endl;
443 cout <<
"Testing Stanford (DH) torque with load on link n: ";
444 Fext(1)=10; Fext(2)=5; Fext(3)=7;
445 Next(1)=11; Next(2)=22; Next(3)=33;
446 for(i = 1; i <= dof; i++) {
449 a = (Test-robot_DH.
torque(qr, qd, qdd, Fext, Next)).MaximumAbsoluteValue();
451 cout <<
"Erreur = " << a << endl;
453 cout <<
"Ok" << endl;
456 cout <<
"Testing Stanford (DH) inertia : ";
457 Test = Matrix(6,6); Test = 0;
458 for(i = 1; i <= 6; i++) {
459 for(
int j = 1; j <= 6; j++){
463 a = (Test-robot_DH.
inertia(qr)).MaximumAbsoluteValue();
465 cout <<
"Erreur = " << a << endl;
467 cout <<
"Ok" << endl;
474 cout <<
"Testing Puma 560 (mDH) forward kinematic : ";
475 for(i = 1; i <= 4; i++) {
476 for(
int j = 1; j <= 4; j++) {
480 initrob = Matrix(6,19);
481 initrob << PUMA560_data_mDH;
482 initrobm = Matrix(6,4);
484 robot_mDH =
mRobot(initrob, initrobm);
486 qr = ColumnVector(dof);
489 a = (Test-robot_mDH.
kine()).MaximumAbsoluteValue();
491 cout <<
"Erreur = " << a << endl;
493 cout <<
"Ok" << endl;
497 cout <<
"Testing Puma 560 (mDH) jacobian in base frame : ";
499 for(i = 1; i <= 6; i++) {
500 for(
int j = 1; j <= 6; j++) {
504 a = (Test-robot_mDH.
jacobian()).MaximumAbsoluteValue();
506 cout <<
"Erreur = " << a << endl;
508 cout <<
"Ok" << endl;
511 cout <<
"Testing Puma 560 (mDH) jacobian in tool frame : ";
512 for(i = 1; i <= 6; i++) {
513 for(
int j = 1; j <= 6; j++) {
517 a = (Test-robot_mDH.
jacobian(dof)).MaximumAbsoluteValue();
519 cout <<
"Erreur = " << a << endl;
521 cout <<
"Ok" << endl;
524 initrobm = Matrix(6,4);
526 robot_mDH =
mRobot(initrob,initrobm);
528 cout <<
"Testing Puma 560 (mDH) torque : ";
529 Test = Matrix(dof,1);
530 for(i = 1; i <= dof; i++) {
533 a = (Test-robot_mDH.
torque(qr, qd, qdd)).MaximumAbsoluteValue();
535 cout <<
"Erreur = " << a << endl;
537 cout <<
"Ok" << endl;
540 cout <<
"Testing Puma 560 (mDH) inertia : ";
541 Test = Matrix(6,6); Test = 0;
542 for(i = 1; i <= 6; i++) {
543 for(
int j = 1; j <= 6; j++){
547 a = (Test-robot_mDH.
inertia(qr)).MaximumAbsoluteValue();
549 cout <<
"Erreur = " << a << endl;
551 cout <<
"Ok" << endl;
554 cout <<
"Testing Puma 560 (mDH) motor, torque : ";
555 initrobm = Matrix(6,4);
556 initrobm << PUMA560_motor;
557 robot_mDH =
mRobot(initrob,initrobm);
558 Test = Matrix(dof,1);
559 for(i = 1; i <= dof; i++) {
562 a = (Test-robot_mDH.
torque(qr, qd, qdd)).MaximumAbsoluteValue();
564 cout <<
"Erreur = " << a << endl;
566 cout <<
"Ok" << endl;
569 cout <<
"Testing Puma 560 (mDH) motor, torque with load on link n: ";
570 Fext(1)=10; Fext(2)=5; Fext(3)=7;
571 Next(1)=11; Next(2)=22; Next(3)=33;
572 for(i = 1; i <= dof; i++) {
575 a = (Test-robot_mDH.
torque(qr, qd, qdd, Fext, Next)).MaximumAbsoluteValue();
577 cout <<
"Erreur = " << a << endl;
579 cout <<
"Ok" << endl;