humanoid_functions.h
Go to the documentation of this file.
00001 /**************************************************************************************************
00002  Software License Agreement (BSD License)
00003 
00004  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
00005  All rights reserved.
00006 
00007  Redistribution and use in source and binary forms, with or without modification, are permitted
00008  provided that the following conditions are met:
00009 
00010   *Redistributions of source code must retain the above copyright notice, this list of
00011    conditions and the following disclaimer.
00012   *Redistributions in binary form must reproduce the above copyright notice, this list of
00013    conditions and the following disclaimer in the documentation and/or other materials provided
00014    with the distribution.
00015   *Neither the name of the University of Aveiro nor the names of its contributors may be used to
00016    endorse or promote products derived from this software without specific prior written permission.
00017  
00018  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
00019  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00020  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00021  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00024  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00025  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 ***************************************************************************************************/
00034 #ifndef _HUMANOID_FUNCTIONS_H_
00035 #define _HUMANOID_FUNCTIONS_H_
00036 
00037 //Defines for left or right side limbs
00038 #define LEFT     1
00039 #define RIGHT   -1
00040 
00041 // Define for dimension extraction
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 // #define PFLN {printf("Passing through File [%s] @ Line [%d].\n", __FILE__, __LINE__);}
00051 
00052 //includes
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     //FUNCTIONS FOR INVERSE/DIRECT KINEMATICS
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     //THESE FUNCTIONS TRANSFORM JOINT ANGLE VALUES TO THEIR EQUIVALENT SERVOMOTOR VALUES
00168     /* ++++++++++++++++++++++++++++++++++++++++++
00169         ++++++++++++++++++ HEAD ++++++++++++++++++
00170       ++++++++++++++++++++++++++++++++++++++++++*/
00178     short unsigned int Head_Pan_Tilt_Conversion(double joint_angle);
00179     
00180     /* ++++++++++++++++++++++++++++++++++++++++++
00181         ++++++++++++++++++ ARMS ++++++++++++++++++
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         ++++++++++++++++++ TORSO +++++++++++++++++
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         ++++++++++++++++++ LEGS ++++++++++++++++++
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     //THESE FUNCTIONS TRANSFORM SERVOMOTOR VALUES TO THEIR EQUIVALENT JOINT ANGLE VALUES 
00297     /* ++++++++++++++++++++++++++++++++++++++++++
00298         ++++++++++++++++++ HEAD ++++++++++++++++++
00299       ++++++++++++++++++++++++++++++++++++++++++*/
00307     double Head_Pan_Tilt_ServoValue_Conversion(short unsigned int servo_value);
00308     
00309     /* ++++++++++++++++++++++++++++++++++++++++++
00310         ++++++++++++++++++ ARMS ++++++++++++++++++
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        ++++++++++++++++++ TORSO +++++++++++++++++
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         ++++++++++++++++++ LEGS ++++++++++++++++++
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         +++++++++ GET ROBOT DIMENSIONS ++++++++++
00427         ++++++++++++++++++++++++++++++++++++++++++*/
00443     double GetRobotDimension(int dimension);
00444     
00445   private:
00446     
00447     /*~~~~~~~~~~~~~~~~~~~~~~~~~ 
00448     || miscellaneous variables ||
00449       ~~~~~~~~~~~~~~~~~~~~~~~~~*/
00451     double PI;
00452     
00453     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
00454     ||      robot dimensions     ||
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     // || robot joint limitation variables ||
00484     //   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00488     struct{
00489     // <<<< HEAD >>>>   
00490     // Motion range [0...10] vertical to tilted
00491     
00493     double head_min_tilt;
00494     
00496     double head_max_tilt;
00497     
00498     /* <<<< ARMS >>>>*/
00499     /* Shoulder flexion
00500     Motion range [-40...140] back to front
00501     */
00503     double shoulder_min_flexion;
00504     
00506     double shoulder_max_flexion;
00507     
00508     /* Shoulder abduction
00509     Motion range [0...180] back to front
00510     */
00512     double shoulder_min_abduction;
00513     
00515     double shoulder_max_abduction;
00516     
00517     /* Elbow flexion
00518     Motion range [0...120] streched to flected
00519     */
00521     double elbow_min_flexion;
00522     
00524     double elbow_max_flexion;
00525     
00526     /* <<<< TORSO >>>>*/
00527     /* Torso rotation
00528     Motion range [-90...90] left to right
00529     */    
00531     double torso_min_rotation;
00532     
00534     double torso_max_rotation;
00535     
00536     /* Torso flexion
00537     Motion range [-15...90] left to right
00538     */    
00540     double torso_min_flexion;
00541     
00543     double torso_max_flexion;
00544     
00545     /* Torso lateral flexion
00546     Motion range [-90...90] left to right
00547     */
00549     double torso_min_lateral_flexion;
00550     
00552     double torso_max_lateral_flexion;
00553     
00554     /* Ankle inversion
00555     Motion range [-30...45] inside to outside
00556     */
00558     double ankle_min_inversion;
00559     
00561     double ankle_max_inversion;
00562     
00563     /* Ankle flexion
00564     Motion range [-40...20] inside to outside
00565     */
00567     double ankle_min_flexion;
00568     
00570     double ankle_max_flexion;
00571     
00572     /* Knee flexion
00573     Motion range [0...130] inside to outside
00574     */
00576     double knee_min_flexion;
00577     
00579     double knee_max_flexion;
00580     
00581     /* Hip abduction
00582     Motion range [-40...45] inside to outside
00583     */
00585     double hip_min_abduction;
00586     
00588     double hip_max_abduction;
00589     
00590     /* hip flexion
00591     Motion range [-30...120] inside to outside
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 


phua_haptic
Author(s): Pedro Cruz
autogenerated on Thu Nov 20 2014 11:35:52