00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00034 #ifndef _HUMANOID_FUNCTIONS_H_
00035 #define _HUMANOID_FUNCTIONS_H_
00036
00037
00038 #define LEFT 1
00039 #define RIGHT -1
00040
00041
00042 #define ARM_LENGTH 100
00043 #define FOREARM_LENGTH 110
00044 #define LEG_LENGTH 200
00045 #define THIGH_LENGTH 210
00046 #define FOOT_LENGTH 220
00047 #define ANKLE_HEIGHT 230
00048 #define FOOT_WIDTH 240
00049
00050
00051
00052
00053 #include <math.h>
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <iostream>
00057
00058 #include <Eigen/Dense>
00059
00066 class humanoid
00067 {
00068 public:
00075 humanoid(void);
00076
00083 ~humanoid(void);
00084
00085
00097 void Dir_Kin_3DOF_Arm(double t1, double t2, double t3, short int SIDE, double *end_pos_n_RPY);
00098
00110 void Inv_Kin_3DOF_Arm(double X, double Y, double Z, double *req_angle);
00111
00122 void CalculateArmJacobian(double theta_1, double theta_2, double theta_3, Eigen::Matrix3d *jacobian);
00123
00135 void CalculateArmAlternateJacobian_No_Theta3_Singularity(double theta_1, double theta_2, double theta_3, Eigen::MatrixXd *jacobian);
00136
00149 void Dir_Kin_4DOF_Detached_Leg(double t1, double t2, double t3, double t4, short int SIDE, double *end_pos_n_RPY);
00150
00161 void Inv_Kin_3DOF_Detached_Leg(double X, double Y, double Z, double *req_angle);
00162
00163 void Calculate_Detached_Leg_3DOF_Jacobian(double theta_1, double theta_2, double theta_3, Eigen::Matrix3d *jacobian);
00164
00165 void Calculate_Detached_Leg_3DOF_COG(double theta_1, double theta_2, double theta_3, int SIDE, Eigen::Vector3d *COG);
00166
00167
00168
00169
00170
00178 short unsigned int Head_Pan_Tilt_Conversion(double joint_angle);
00179
00180
00181
00182
00191 short unsigned int Shoulder_Flexion_Extension_Conversion(short int SIDE, double joint_angle);
00192
00201 short unsigned int Shoulder_Abduction_Adduction_Conversion(short int SIDE, double joint_angle);
00202
00211 short unsigned int Elbow_Flexion_Extension_Conversion(short int SIDE, double joint_angle);
00212
00213
00214
00215
00223 short unsigned int Torso_Rotation_Conversion(double joint_angle);
00224
00232 short unsigned int Torso_Flexion_Extension_Conversion(double joint_angle);
00233
00241 short unsigned int Torso_Lateral_Flexion_Extension_Conversion(double joint_angle);
00242
00243
00244
00245
00254 short unsigned int Ankle_Inversion_Eversion_Conversion(short int SIDE, double joint_angle);
00255
00264 short unsigned int Ankle_Flexion_Conversion(short int SIDE, double joint_angle);
00265
00274 short unsigned int Knee_Conversion(short int SIDE, double joint_angle);
00275
00284 short unsigned int Hip_Abduction_Hiperabduction_Conversion(short int SIDE, double joint_angle);
00285
00294 short unsigned int Hip_Flexion_Conversion(short int SIDE, double joint_angle);
00295
00296
00297
00298
00299
00307 double Head_Pan_Tilt_ServoValue_Conversion(short unsigned int servo_value);
00308
00309
00310
00311
00320 double Shoulder_Flexion_Extension_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00321
00330 double Shoulder_Abduction_Adduction_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00331
00340 double Elbow_Flexion_Extension_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00341
00342
00343
00344
00352 double Torso_Rotation_ServoValue_Conversion(short unsigned int servo_value);
00353
00361 double Torso_Flexion_Extension_ServoValue_Conversion(short unsigned int servo_value);
00362
00370 double Torso_Lateral_Flexion_Extension_ServoValue_Conversion(short unsigned int servo_value);
00371
00372
00373
00374
00383 double Ankle_Inversion_Eversion_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00384
00393 double Ankle_Flexion_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00394
00403 double Knee_Flexion_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00404
00413 double Hip_Abduction_Hiperabduction_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00414
00423 double Hip_Flexion_ServoValue_Conversion(short int SIDE, short unsigned int servo_value);
00424
00425
00426
00427
00443 double GetRobotDimension(int dimension);
00444
00445 private:
00446
00447
00448
00449
00451 double PI;
00452
00453
00454
00455
00459 struct{
00461 double arm_length;
00462
00464 double forearm_length;
00465
00467 double shin_length;
00468
00470 double thigh_length;
00471
00473 double foot_length;
00474
00476 double foot_width;
00477
00479 double ankle_height;
00480 } robot_dimensions;
00481
00482
00483
00484
00488 struct{
00489
00490
00491
00493 double head_min_tilt;
00494
00496 double head_max_tilt;
00497
00498
00499
00500
00501
00503 double shoulder_min_flexion;
00504
00506 double shoulder_max_flexion;
00507
00508
00509
00510
00512 double shoulder_min_abduction;
00513
00515 double shoulder_max_abduction;
00516
00517
00518
00519
00521 double elbow_min_flexion;
00522
00524 double elbow_max_flexion;
00525
00526
00527
00528
00529
00531 double torso_min_rotation;
00532
00534 double torso_max_rotation;
00535
00536
00537
00538
00540 double torso_min_flexion;
00541
00543 double torso_max_flexion;
00544
00545
00546
00547
00549 double torso_min_lateral_flexion;
00550
00552 double torso_max_lateral_flexion;
00553
00554
00555
00556
00558 double ankle_min_inversion;
00559
00561 double ankle_max_inversion;
00562
00563
00564
00565
00567 double ankle_min_flexion;
00568
00570 double ankle_max_flexion;
00571
00572
00573
00574
00576 double knee_min_flexion;
00577
00579 double knee_max_flexion;
00580
00581
00582
00583
00585 double hip_min_abduction;
00586
00588 double hip_max_abduction;
00589
00590
00591
00592
00594 double hip_min_flexion;
00595
00597 double hip_max_flexion;
00598 } robot_joint_limits;
00599
00603 struct{
00605 double head_servo_offset;
00606
00608 double shoulder_flexion_servo_offset_left;
00609
00611 double shoulder_flexion_servo_offset_right;
00612
00614 double shoulder_abduction_servo_offset_left;
00615
00617 double shoulder_abduction_servo_offset_right;
00618
00620 double elbow_flexion_servo_offset_left;
00621
00623 double elbow_flexion_servo_offset_right;
00624
00626 double torso_rotation_servo_offset;
00627
00629 double torso_flexion_servo_offset;
00630
00632 double torso_lateral_flexion_servo_offset;
00633
00635 double knee_flexion_b_value_left;
00636
00638 double knee_flexion_b_value_right;
00639
00641 double hip_flexion_b_value_left;
00642
00644 double hip_flexion_b_value_right;
00645 } robot_servo_conversion;
00646
00650 struct{
00652 double foot_mass;
00653
00655 double shin_mass;
00656
00658 double thigh_mass;
00659
00660 } robot_element_mass;
00661
00665 struct{
00667 Eigen::Vector3d foot_COM;
00668
00670 Eigen::Vector3d shin_COM;
00671
00673 Eigen::Vector3d thigh_COM;
00674
00675 } robot_relative_COM;
00676
00677 };
00678
00679 #endif
00680