Go to the documentation of this file.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
00027
00034 #ifndef SERVOHUMANOID_H
00035 #define SERVOHUMANOID_H
00036
00037 #define PI 3.141592653589793238462643383279502884197
00038
00039
00040 #define LEFT 1
00041 #define RIGHT -1
00042
00043
00044 #define ARM_LENGTH 100
00045 #define FOREARM_LENGTH 110
00046 #define LEG_LENGTH 200
00047 #define THIGH_LENGTH 210
00048 #define FOOT_LENGTH 220
00049 #define ANKLE_HEIGHT 230
00050 #define FOOT_WIDTH 240
00051
00052
00053
00054
00055 #include <math.h>
00056 #include <stdio.h>
00057 #include <stdlib.h>
00058 #include <iostream>
00059 #include <ros/ros.h>
00060
00061 #include <Eigen/Dense>
00062 #include <hitec5980sg/hitec5980sg.h>
00063
00064
00065 class ServoHumanoid
00066 {
00067
00068 public:
00069 ServoHumanoid(const char* path);
00070
00071 void HomePosition(void);
00072
00073 short unsigned int MoveJoint(short int id, double joint_angle);
00074
00075 short unsigned int SetJointSpeed(short int id, unsigned int speed);
00076
00077 short unsigned int Torso_Rotation_Movement(double joint_angle);
00078
00079 short unsigned int Torso_Flexion_Extension_Movement(double joint_angle);
00080
00081 short unsigned int Torso_Lateral_Flexion_Extension_Movement(double joint_angle);
00082
00083 short unsigned int Ankle_Flexion_Movement(short int id, double joint_angle);
00084
00085 short unsigned int Ankle_Inversion_Eversion_Movement(short int id, double joint_angle);
00086
00087 short unsigned int Knee_Movement(short int id, double joint_angle);
00088
00089 short unsigned int Hip_Abduction_Hiperabduction_Movement(short int id, double joint_angle);
00090
00091 short unsigned int Hip_Flexion_Movement(short int id, double joint_angle);
00092
00093 double ConvertServoValueByID(int id, short unsigned int servo_value);
00094
00095 double Hip_Flexion_ServoValue_Conversion(short int id, short unsigned int servo_value);
00096
00097 double Hip_Abduction_Hiperabduction_ServoValue_Conversion(short int id, short unsigned int servo_value);
00098
00099 double Knee_Flexion_ServoValue_Conversion(short int id, short unsigned int servo_value);
00100
00101 double Ankle_Flexion_ServoValue_Conversion(short int id, short unsigned int servo_value);
00102
00103 double Ankle_Inversion_Eversion_ServoValue_Conversion(short int id, short unsigned int servo_value);
00104
00105 double Torso_Flexion_Extension_ServoValue_Conversion(short unsigned int servo_value);
00106
00107 double Torso_Rotation_ServoValue_Conversion(short unsigned int servo_value);
00108
00109 double Torso_Lateral_Flexion_Extension_ServoValue_Conversion(short unsigned int servo_value);
00110
00111
00112
00113 struct RoboState
00114 {
00115
00116 short unsigned int op_mode;
00117
00118 double speed_g_static;
00119
00120 double speed_wanted[13];
00121
00122
00123 double joint_now[13];
00124
00125
00126 double joint_wanted[13];
00127
00128 } RoboState;
00129
00130 private:
00131
00132
00133 hitec_5980SG* hitec;
00134
00135
00136 void SetParameters(void);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00150 struct{
00152 double arm_length;
00153
00155 double forearm_length;
00156
00158 double shin_length;
00159
00161 double thigh_length;
00162
00164 double foot_length;
00165
00167 double foot_width;
00168
00170 double ankle_height;
00171 } robot_dimensions;
00172
00173
00174
00175
00179 struct{
00180
00181
00182
00184 double head_min_tilt;
00185
00187 double head_max_tilt;
00188
00189
00190
00191
00192
00194 double shoulder_min_flexion;
00195
00197 double shoulder_max_flexion;
00198
00199
00200
00201
00203 double shoulder_min_abduction;
00204
00206 double shoulder_max_abduction;
00207
00208
00209
00210
00212 double elbow_min_flexion;
00213
00215 double elbow_max_flexion;
00216
00217
00218
00219
00220
00222 double torso_min_rotation;
00223
00225 double torso_max_rotation;
00226
00227
00228
00229
00231 double torso_min_flexion;
00232
00234 double torso_max_flexion;
00235
00236
00237
00238
00240 double torso_min_lateral_flexion;
00241
00243 double torso_max_lateral_flexion;
00244
00245
00246
00247
00249 double ankle_min_inversion;
00250
00252 double ankle_max_inversion;
00253
00254
00255
00256
00258 double ankle_min_flexion;
00259
00261 double ankle_max_flexion;
00262
00263
00264
00265
00267 double knee_min_flexion;
00268
00270 double knee_max_flexion;
00271
00272
00273
00274
00276 double hip_min_abduction;
00277
00279 double hip_max_abduction;
00280
00281
00282
00283
00285 double hip_min_flexion;
00286
00288 double hip_max_flexion;
00289 } robot_joint_limits;
00290
00294 struct{
00296 double head_servo_offset;
00297
00299 double shoulder_flexion_servo_offset_left;
00300
00302 double shoulder_flexion_servo_offset_right;
00303
00305 double shoulder_abduction_servo_offset_left;
00306
00308 double shoulder_abduction_servo_offset_right;
00309
00311 double elbow_flexion_servo_offset_left;
00312
00314 double elbow_flexion_servo_offset_right;
00315
00317 double torso_rotation_servo_offset;
00318
00320 double torso_flexion_servo_offset;
00321
00323 double torso_lateral_flexion_servo_offset;
00324
00326 double knee_flexion_b_value_left;
00327
00329 double knee_flexion_b_value_right;
00330
00332 double hip_flexion_b_value_left;
00333
00335 double hip_flexion_b_value_right;
00336 } robot_servo_conversion;
00337
00341 struct {
00343 double head_joint_offset;
00344
00346 double shoulder_flexion_joint_offset_left;
00347
00349 double shoulder_flexion_joint_offset_right;
00350
00352 double shoulder_abduction_joint_offset_left;
00353
00355 double shoulder_abduction_joint_offset_right;
00356
00358 double elbow_flexion_joint_offset_left;
00359
00361 double elbow_flexion_joint_offset_right;
00362
00364 double torso_rotation_joint_offset;
00365
00367 double torso_flexion_joint_offset;
00368
00370 double torso_lateral_flexion_joint_offset;
00371
00373 double knee_flexion_joint_offset_left;
00374
00376 double knee_flexion_joint_offset_right;
00377
00379 double hip_flexion_joint_offset_left;
00380
00382 double hip_flexion_joint_offset_right;
00383
00385 double hip_abduction_joint_offset_left;
00386
00388 double hip_abduction_joint_offset_right;
00389
00391 double feet_flexion_joint_offset_left;
00392
00394 double feet_flexion_joint_offset_right;
00395
00397 double feet_inversion_joint_offset_left;
00398
00400 double feet_inversion_joint_offset_right;
00401
00402 } joint_offset;
00403
00404
00408 struct{
00410 double foot_mass;
00411
00413 double shin_mass;
00414
00416 double thigh_mass;
00417
00418 } robot_element_mass;
00419
00423 struct{
00425 Eigen::Vector3d foot_CoM;
00426
00428 Eigen::Vector3d shin_CoM;
00429
00431 Eigen::Vector3d thigh_CoM;
00432
00433 } robot_relative_COM;
00434
00435
00436 };
00437
00438 #endif