00001
00002
00003
00004
00005
00006
00007 #include <jaco_driver/jaco_arm_kinematics.h>
00008
00009 namespace jaco {
00010 JacoKinematics::JacoKinematics(void) {
00011
00012 }
00013 void JacoKinematics::UpdateForward(float q1, float q2, float q3, float q4,
00014 float q5, float q6) {
00015 tf::Transform transform;
00016 tf::Quaternion rotation_q(0, 0, 0, 0);
00017 tf::Matrix3x3 rot_matrix(0, 0, 0, 0, 0, 0, 0, 0, 0);
00018 tf::Vector3 translation_v(0, 0, 0);
00019
00020
00021
00022 rotation_q.setValue(0, 0, 0, 0);
00023 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00024
00025
00026
00027
00028
00029
00030
00031
00032 rot_matrix.setValue(cos(M_PI_2), -sin(M_PI_2), 0, sin(M_PI_2), cos(M_PI_2), 0, 0, 0, 1);
00033 rot_matrix.getRotation(rotation_q);
00034
00035 #ifdef PRINT_DEBUG_INFO
00036
00037 ROS_INFO(
00038 "API Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00039 #endif
00040 transform.setRotation(rotation_q);
00041
00042
00043 translation_v.setValue(0, 0, 0);
00044
00045
00046
00047
00048
00049
00050
00051
00052 translation_v.setValue(0, 0, 0);
00053
00054 #ifdef PRINT_DEBUG_INFO
00055
00056
00057 ROS_INFO(
00058 "API Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00059 #endif
00060
00061 transform.setOrigin(translation_v);
00062
00063
00064 br.sendTransform(
00065 tf::StampedTransform(transform, ros::Time::now(), "arm_base",
00066 "jaco_base"));
00067
00068
00069
00070 rotation_q.setValue(0, 0, 0, 0);
00071 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 rot_matrix.setValue(1,0,0,0,1,0,0,0,1);
00082
00083 rot_matrix.getRotation(rotation_q);
00084
00085 #ifdef PRINT_DEBUG_INFO
00086
00087 ROS_INFO(
00088 "API Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00089 #endif
00090 transform.setRotation(rotation_q);
00091
00092
00093 translation_v.setValue(0, 0, 0);
00094
00095
00096
00097
00098
00099
00100
00101
00102 translation_v.setValue(0, 0, 0.028);
00103
00104 #ifdef PRINT_DEBUG_INFO
00105
00106
00107 ROS_INFO(
00108 "API Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00109 #endif
00110
00111 transform.setOrigin(translation_v);
00112
00113
00114 br.sendTransform(
00115 tf::StampedTransform(transform, ros::Time::now(), "jaco_base",
00116 "jaco_api_origin"));
00117
00118
00119
00120
00121
00122 rotation_q.setValue(0, 0, 0, 0);
00123 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00124
00125
00126
00127
00128
00129
00130
00131
00132 rot_matrix.setValue(cos(q1), -sin(q1), 0, -sin(q1), -cos(q1), 0, 0, 0, -1);
00133 rot_matrix.getRotation(rotation_q);
00134
00135 #ifdef PRINT_DEBUG_INFO
00136
00137 ROS_INFO(
00138 "Joint 1 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00139 #endif
00140 transform.setRotation(rotation_q);
00141
00142
00143 translation_v.setValue(0, 0, 0);
00144
00145
00146
00147
00148
00149
00150
00151
00152 translation_v.setValue(0, 0, this->BaseToJ1());
00153
00154 #ifdef PRINT_DEBUG_INFO
00155
00156
00157 ROS_INFO(
00158 "Joint 1 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00159 #endif
00160
00161 transform.setOrigin(translation_v);
00162
00163
00164 br.sendTransform(
00165 tf::StampedTransform(transform, ros::Time::now(), "jaco_base",
00166 "jaco_joint_1"));
00167
00168
00169
00170
00171 rotation_q.setValue(0, 0, 0, 0);
00172 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00173
00174
00175
00176
00177
00178
00179 rot_matrix.setValue(sin(q2), cos(q2), 0, 0, 0, 1, cos(q2), -sin(q2), 0);
00180
00181 rot_matrix.getRotation(rotation_q);
00182
00183 #ifdef PRINT_DEBUG_INFO
00184
00185 ROS_INFO(
00186 "Joint 2 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00187 #endif
00188 transform.setRotation(rotation_q);
00189
00190
00191 translation_v.setValue(0, 0, 0);
00192
00193
00194
00195
00196
00197
00198
00199
00200 translation_v.setValue(0, 0 , -this->J1ToJ2());
00201
00202 #ifdef PRINT_DEBUG_INFO
00203
00204
00205 ROS_INFO(
00206 "Joint 2 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00207 #endif
00208
00209 transform.setOrigin(translation_v);
00210
00211
00212 br.sendTransform(
00213 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_1",
00214 "jaco_joint_2"));
00215
00216
00217
00218
00219 rotation_q.setValue(0, 0, 0, 0);
00220 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00221
00222
00223
00224
00225
00226
00227 rot_matrix.setValue(-cos(q3), sin(q3), 0, sin(q3), cos(q3), 0, 0, 0, -1);
00228
00229 rot_matrix.getRotation(rotation_q);
00230
00231 #ifdef PRINT_DEBUG_INFO
00232
00233 ROS_INFO(
00234 "Joint 3 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00235 #endif
00236 transform.setRotation(rotation_q);
00237
00238
00239 translation_v.setValue(0, 0, 0);
00240
00241
00242
00243
00244
00245
00246
00247
00248 translation_v.setValue(this->J2ToJ3(), 0, 0);
00249
00250 #ifdef PRINT_DEBUG_INFO
00251
00252
00253 ROS_INFO(
00254 "Joint 3 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00255 #endif
00256
00257 transform.setOrigin(translation_v);
00258
00259
00260 br.sendTransform(
00261 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_2",
00262 "jaco_joint_3"));
00263
00264
00265
00266
00267 rotation_q.setValue(0, 0, 0, 0);
00268 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00269
00270
00271
00272
00273
00274
00275 rot_matrix.setValue(1, 0, 0, 0, 1, 0, 0, 0, 1);
00276
00277 rot_matrix.getRotation(rotation_q);
00278
00279 #ifdef PRINT_DEBUG_INFO
00280
00281 ROS_INFO(
00282 "Joint 3 Offset Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00283 #endif
00284 transform.setRotation(rotation_q);
00285
00286
00287 translation_v.setValue(0, 0, 0);
00288
00289
00290
00291
00292
00293
00294
00295
00296 translation_v.setValue(0, 0, -this->J3Offset());
00297
00298 #ifdef PRINT_DEBUG_INFO
00299
00300
00301 ROS_INFO(
00302 "Joint 3 Offset Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00303 #endif
00304
00305 transform.setOrigin(translation_v);
00306
00307
00308 br.sendTransform(
00309 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_3",
00310 "jaco_joint_3_offset"));
00311
00312
00313
00314
00315
00316 rotation_q.setValue(0, 0, 0, 0);
00317 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00318
00319
00320
00321
00322
00323
00324 rot_matrix.setValue(0,0,-1, sin(q4), cos(q4), 0, cos(q4), -sin(q4), 0);
00325
00326 rot_matrix.getRotation(rotation_q);
00327
00328 #ifdef PRINT_DEBUG_INFO
00329
00330 ROS_INFO(
00331 "Joint 4 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00332 #endif
00333 transform.setRotation(rotation_q);
00334
00335
00336 translation_v.setValue(0, 0, 0);
00337
00338
00339
00340
00341
00342
00343
00344
00345 translation_v.setValue(this->J3ToJ4(), 0, 0);
00346
00347 #ifdef PRINT_DEBUG_INFO
00348
00349
00350 ROS_INFO(
00351 "Joint 4 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00352 #endif
00353
00354 transform.setOrigin(translation_v);
00355
00356
00357 br.sendTransform(
00358 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_3_offset",
00359 "jaco_joint_4"));
00360
00361
00362
00363
00364 rotation_q.setValue(0, 0, 0, 0);
00365 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00366
00367
00368
00369
00370
00371
00372
00373 rot_matrix.setValue(cos((this->deg_to_rad(-55)))*cos(q5),cos((this->deg_to_rad(-55)))*-sin(q5),sin((this->deg_to_rad(-55))), sin(q5), cos(q5), 0, -sin((this->deg_to_rad(-55)))*cos(q5), sin((this->deg_to_rad(-55)))*sin(q5), cos((this->deg_to_rad(-55))));
00374
00375 rot_matrix.getRotation(rotation_q);
00376
00377 #ifdef PRINT_DEBUG_INFO
00378
00379 ROS_INFO(
00380 "Joint 5 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00381 #endif
00382 transform.setRotation(rotation_q);
00383
00384
00385 translation_v.setValue(0, 0, 0);
00386
00387
00388
00389
00390
00391
00392
00393
00394 translation_v.setValue(cos(this->deg_to_rad(55))*this->J4ToJ5(), 0, -sin(this->deg_to_rad(55))*this->J4ToJ5());
00395
00396 #ifdef PRINT_DEBUG_INFO
00397
00398
00399 ROS_INFO(
00400 "Joint 5 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00401 #endif
00402
00403 transform.setOrigin(translation_v);
00404
00405
00406 br.sendTransform(
00407 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_4",
00408 "jaco_joint_5"));
00409
00410
00411
00412
00413
00414 rotation_q.setValue(0, 0, 0, 0);
00415 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00416
00417
00418
00419
00420
00421
00422
00423 rot_matrix.setValue(cos((this->deg_to_rad(55)))*cos(q6),cos((this->deg_to_rad(55)))*-sin(q6),sin((this->deg_to_rad(55))), sin(q6), cos(q6), 0, -sin((this->deg_to_rad(55)))*cos(q6), sin((this->deg_to_rad(55)))*sin(q6), cos((this->deg_to_rad(55))));
00424
00425 rot_matrix.getRotation(rotation_q);
00426
00427 #ifdef PRINT_DEBUG_INFO
00428
00429 ROS_INFO(
00430 "Joint 6 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00431 #endif
00432 transform.setRotation(rotation_q);
00433
00434
00435 translation_v.setValue(0, 0, 0);
00436
00437
00438
00439
00440
00441
00442
00443
00444 translation_v.setValue(-cos(this->deg_to_rad(55))*this->J5ToJ6(), 0, -sin(this->deg_to_rad(55))*this->J5ToJ6());
00445
00446 #ifdef PRINT_DEBUG_INFO
00447
00448
00449 ROS_INFO(
00450 "Joint 6 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00451 #endif
00452
00453 transform.setOrigin(translation_v);
00454
00455
00456 br.sendTransform(
00457 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_5",
00458 "jaco_joint_6"));
00459
00460
00461
00462
00463 rotation_q.setValue(0, 0, 0, 0);
00464 rot_matrix.setValue(0, 0, 0, 0, 0, 0, 0, 0, 0);
00465
00466
00467
00468
00469
00470
00471
00472 rot_matrix.setValue(1,0,0,0,1,0,0,0,1);
00473
00474 rot_matrix.getRotation(rotation_q);
00475
00476 #ifdef PRINT_DEBUG_INFO
00477
00478 ROS_INFO(
00479 "Joint 6 Rotation: X = %f, Y = %f, Z = %f, W = %f", rotation_q.getX(), rotation_q.getY(), rotation_q.getZ(), rotation_q.getW());
00480 #endif
00481 transform.setRotation(rotation_q);
00482
00483
00484 translation_v.setValue(0, 0, 0);
00485
00486
00487
00488
00489
00490
00491
00492
00493 translation_v.setValue(0,0,-this->J6ToEnd());
00494
00495 #ifdef PRINT_DEBUG_INFO
00496
00497
00498 ROS_INFO(
00499 "Joint 6 Translation: X = %f, Y = %f, Z = %f", translation_v.getX(), translation_v.getY(), translation_v.getZ());
00500 #endif
00501
00502 transform.setOrigin(translation_v);
00503
00504
00505 br.sendTransform(
00506 tf::StampedTransform(transform, ros::Time::now(), "jaco_joint_6",
00507 "jaco_end_effector"));
00508
00509
00510 }
00511 }