00001 //======================================= 00002 // IK_Jacobian.h 00003 // Planner for obstacle avoidance with 00004 // kinematically redundant robots 00005 //======================================= 00006 00007 #ifndef IK_JACOBIAN_H 00008 #define IK_JACOBIAN_H 00009 00010 #pragma warning( disable : 4250 ) 00011 00012 #include <vector> 00013 #include "planners/inversekin/IK_InvKinBase.h" 00014 #include "Kinematics/Jacobian.h" 00015 #include "Robots/R_OpenChain.h" 00016 #include "math/math2.h" 00017 00018 typedef struct 00019 { 00020 // no need to record obstacle link number since it's always 0 00021 int robFrame; // the link of the robot where rob_pts lies 00022 double distance; // distance between obs_pts and rob_pts 00023 double obs_pts[3]; // coordinate of the point on obstacle closest to robot 00024 double rob_pts[3]; // coordinate of the point on robot closest to obstacle, w.r.t frame $robFrame$ 00025 } closeValues; 00026 00027 class IK_Jacobian: 00028 virtual public IK_InvKinBase 00029 { 00030 public: 00031 // Default Constructor & Destructor 00032 IK_Jacobian(); 00033 virtual ~IK_Jacobian(); 00034 00035 virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector); 00036 virtual bool Plan (); 00037 00038 //Set the given end-effector trajectory/path 00039 void SetTrajectory(std::vector<Frame> &traj); 00040 00041 // Set/Get how close the robot can come to obstacles 00042 void SetObstacleTolerance(double tol); 00043 double GetObstacleTolerance() {return m_dObsTol;} 00044 00045 //Set/Get homogeneous gain 00046 void SetHomogeneousGain(double gain) {m_dHomoGain = gain;} 00047 double GetHomogeneousGain() {return m_dHomoGain;} 00048 00049 //Set/Get the obstacle distance feedback gain 00050 void SetObstacleDistGain(double gain) {m_dObsDistGain = gain;} 00051 double GetObstacleDistGain() {return m_dObsDistGain;} 00052 00053 //Set/Get the path tolerance 00054 void SetPathTolerence(double tol) {m_dPathTol = tol;} 00055 double GetPathTolerence() {return m_dPathTol;} 00056 00057 //Set/Get the number of obstacle points to be considered 00058 void SetNumObstaclePt(int num) {m_nObsPoint = (num>1)?num:1;} 00059 int GetNumObstaclePt() {return m_nObsPoint;} 00060 00061 //Get/Set whether or not to consider orienation/position 00062 void SetOrientation(bool bOrient) {m_bOrientation = bOrient;} 00063 bool GetOrientation(bool bOrient) {return m_bOrientation;} 00064 void SetPosition(bool bOrient) {m_bPosition = bOrient;} 00065 bool GetPosition(bool bOrient) {return m_bPosition;} 00066 00067 protected: 00068 //planner parameter 00069 int m_nObsPoint; // Number of obstacle points to be considered 00070 bool m_bPosition; // Whether or not to consider position, usually true 00071 bool m_bOrientation; // Whether or not to consider orienation; 00072 double m_dObsTol; // Closest distance between robot and obstacles without claiming collision 00073 double m_dHomoGain; // Homogeneous gain 00074 double m_dObsDistGain; // Obstacle gain 00075 double m_dAngTol; // Maximum difference of yaw/roll/pitch acceptable for a given end-eff pose 00076 double m_dPathTol; // Maximum difference of position for a given end-eff pose 00077 00078 int m_nDof; // DOF of the robot, for computation efficiency purpose 00079 int m_nToolFrame; // Obsolete, the index of tool frame; 00080 Frame m_frEndEffector; // The tool frame w.r.t 00081 double m_dTotalObsDist; // The total distance of all obstacles considered 00082 R_OpenChain * m_pRobot; // to get DH parameters for Jacobian 00083 00084 std::vector<closeValues> m_vClosestPoints; // used to keep track of the values of the closest points 00085 std::vector<Frame> poses; // given end-effector trajectory, does NOT include start and goal configs 00086 00087 //Empty, derived from base abstract class 00088 void InitNewSearch(); 00089 00090 //Get tool frame, obsolete, it's from the base class: IK_InvKinBase 00091 //Matrix4x4 GetToolFrame( const Configuration& config ) const; 00092 00093 // finds the closest m_nObsPoint number of points and their distances, 00094 bool GetClosestValues(const Configuration& config); 00095 00096 //Check whether the jont variable execeed the limits. 00097 void CheckJointLimits(Configuration& config); 00098 00099 //Check whether the joint velocity execeed the limits. 00100 void CheckJointVelocities(Configuration& config); 00101 00102 //Compute the distance between two Frames, actully just consider position part. 00103 double Distance(Frame &frame1, Frame &frame2); 00104 00105 //Computed joint velocity that brought by homogeneous term. 00106 VectorN ComputeHomogeneousTerm(CJacobian &jacobian, Matrixmxn &mJEnd, Matrixmxn &mJEndInv, VectorN &vEndEffVel); 00107 00108 //Compute end-effector velocity according the given trajectory; 00109 VectorN ComputeEndEffVel(Frame &frStart, Frame &frEnd); 00110 00111 }; 00112 00113 #endif