DHParam.h
Go to the documentation of this file.
00001 
00019 #ifndef URDF2GRASPIT_DHPARAM_H
00020 #define URDF2GRASPIT_DHPARAM_H
00021 // Copyright Jennifer Buehler
00022 
00023 #include <urdf/model.h>
00024 #include <urdf_traverser/Types.h>
00025 #include <Eigen/Core>
00026 #include <Eigen/Geometry>
00027 
00028 namespace urdf2graspit
00029 {
00030 
00040 class DHParam
00041 {
00042 public:
00043     typedef urdf_traverser::EigenTransform EigenTransform;
00044     typedef urdf_traverser::JointConstPtr JointConstPtr;
00045     typedef urdf_traverser::LinkConstPtr LinkConstPtr;
00046 
00047     DHParam():
00048         joint(JointConstPtr()),
00049         dof_index(-1),
00050         d(0),
00051         r(0),
00052         theta(0),
00053         alpha(0) { }
00054     DHParam(const DHParam& p):
00055         joint(p.joint),
00056         childLink(p.childLink),
00057         dof_index(p.dof_index),
00058         d(p.d),
00059         r(p.r),
00060         theta(p.theta),
00061         alpha(p.alpha) { }
00062 
00063     // URDF joint which is located at reference frame (i).
00064     // The DH parameters transform to frame (i+1).
00065     JointConstPtr joint;
00066     LinkConstPtr childLink;
00067     int dof_index;   // < index of this dh-parameter in the list of DOF specifications of graspit
00068     double d;  // < distance along previous z
00069     double r;  // < orthogonal distance from previous z axis to current z
00070     double theta;  // < rotation of previous x around previous z to current x
00071     double alpha;  // < rotation of previous z to current z
00072 
00073     DHParam& operator=(const DHParam& p)
00074     {
00075         if (&p == this) return *this;
00076         joint = p.joint;
00077         childLink = p.childLink;
00078         dof_index = p.dof_index;
00079         d = p.d;
00080         r = p.r;
00081         theta = p.theta;
00082         alpha = p.alpha;
00083         return *this;
00084     }
00085 
00086 
00087     friend std::ostream& operator<<(std::ostream& o, const DHParam& p)
00088     {
00089         o << p.joint->name << ": d=" << p.d << ", r=" << p.r << ", theta=" << p.theta
00090           << ", alpha=" << p.alpha << ", dof_idx=" << p.dof_index;
00091         if (p.joint->type == urdf::Joint::REVOLUTE)
00092          o << " (revolute)";
00093         else if (p.joint->type == urdf::Joint::CONTINUOUS)
00094          o << " (continuous)";
00095         else if (p.joint->type == urdf::Joint::PRISMATIC)
00096          o << " (prismatic)";
00097         else
00098          o << " (other type = " << p.joint->type << ")";
00099         return o;
00100     }
00101 
00118     static bool toDenavitHartenberg(DHParam& param,
00119                                     const Eigen::Vector3d& zi_1,
00120                                     const Eigen::Vector3d& xi_1,
00121                                     const Eigen::Vector3d& pi_1,
00122                                     const Eigen::Vector3d& zi,
00123                                     const Eigen::Vector3d& pi,
00124                                     Eigen::Vector3d& xi);
00125 
00129     static EigenTransform getTransform(const DHParam& p);
00130 
00131 
00140     static bool getTransforms(const std::vector<DHParam>& dh, const bool dh2urdf, std::map<std::string,EigenTransform>& transforms);
00141 
00142 private:
00151 /*
00152      * \param r the distance between them along the common normal \e xi.
00153      static bool getRAndAlpha(const Eigen::Vector3d& zi_1, const Eigen::Vector3d& zi,
00154                              const Eigen::Vector3d& pi_1, const Eigen::Vector3d& pi, double& r, double& alpha,
00155                              Eigen::Vector3d& commonNormal, Eigen::Vector3d& nOriginOnZi_1);*/
00156       static bool getAlpha(const Eigen::Vector3d& zi_1, const Eigen::Vector3d& zi,
00157                            const Eigen::Vector3d& pi_1, const Eigen::Vector3d& pi,
00158                            const Eigen::Vector3d& xi,
00159                            double& alpha);
00160 
00161 
00162 
00167     static bool getDAndTheta(const Eigen::Vector3d& zi_1, const Eigen::Vector3d& xi_1, const Eigen::Vector3d& pi_1,
00168                              const Eigen::Vector3d& xi, const Eigen::Vector3d& normOriginOnZi_1,
00169                              double& d, double& theta);
00170 
00171 
00179     static bool getCommonNormal(const Eigen::Vector3d& zi_1, const Eigen::Vector3d& zi, const Eigen::Vector3d& pi_1,
00180                                 const Eigen::Vector3d& pi, Eigen::Vector3d& commonNormal,
00181                                 Eigen::Vector3d& nOriginOnZi_1, double& shortestDistance, bool& parallel);
00182 
00183 
00184     static EigenTransform getTransform(const urdf::Pose& p);
00185 
00186     // Get joint transform to parent
00187     static EigenTransform getTransform(const DHParam::JointConstPtr& joint);
00188 
00189 };
00190 
00191 }  //  namespace urdf2graspit
00192 #endif  //  URDF2GRASPIT_DHPARAM_H


urdf2graspit
Author(s): Jennifer Buehler
autogenerated on Wed May 8 2019 02:53:45