Go to the documentation of this file.00001
00019 #ifndef URDF2GRASPIT_URDF2GRASPIT_H
00020 #define URDF2GRASPIT_URDF2GRASPIT_H
00021
00022
00023
00024 #include <urdf/model.h>
00025
00026 #include <iostream>
00027 #include <string>
00028 #include <map>
00029 #include <vector>
00030
00031 #include <Eigen/Core>
00032 #include <Eigen/Geometry>
00033
00034 #include <baselib_binding/SharedPtr.h>
00035 #include <urdf2graspit/Urdf2GraspItBase.h>
00036
00037 #include <urdf2graspit/DHParam.h>
00038 #include <urdf2graspit/ConversionResult.h>
00039 #include <urdf2graspit/OutputStructure.h>
00040
00041
00042
00043 #define U2G_EPSILON 1e-07
00044
00045 namespace urdf2graspit
00046 {
00047
00063 class Urdf2GraspIt: public Urdf2GraspItBase
00064 {
00065 public:
00066 typedef urdf2graspit::ConversionResult GraspItConversionResult;
00067 typedef baselib_binding::shared_ptr<GraspItConversionResult>::type GraspItConversionResultPtr;
00068
00069 typedef urdf2graspit::ConversionParameters GraspItConversionParameters;
00070 typedef baselib_binding::shared_ptr<GraspItConversionParameters>::type GraspItConversionParametersPtr;
00071
00072
00078 explicit Urdf2GraspIt(UrdfTraverserPtr& traverser, float _scaleFactor = 1000, bool _negateJointMoves = false):
00079 Urdf2GraspItBase(traverser, _scaleFactor),
00080 negateJointMoves(_negateJointMoves),
00081 isDHScaled(false),
00082 dhTransformed(false)
00083 {
00084 urdf2inventor::Urdf2Inventor::MESH_OUTPUT_DIRECTORY_NAME = "iv";
00085 }
00086
00087 ~Urdf2GraspIt()
00088 {
00089 }
00090
00110 ConversionResultPtr processAll(const std::string& urdfFilename,
00111 const std::string& rootLinkName,
00112 const std::vector<std::string>& fingerRootNames,
00113 const std::string& material,
00114 const EigenTransform& addVisualTransform);
00115
00116
00128 bool getDHParams(std::vector<DHParam>& dhparams, const std::string& fromLinkName) const;
00129
00130
00138 bool toDenavitHartenberg(const std::string& fromLink);
00139
00140 private:
00141
00142 bool checkConversionPrerequisites(const GraspItConversionParametersPtr& param) const;
00143
00144 virtual ConversionResultPtr preConvert(const ConversionParametersPtr& params);
00145 virtual ConversionResultPtr postConvert(const ConversionParametersPtr& rootLink, ConversionResultPtr& result);
00146
00161 bool getDHParams(std::vector<DHParam>& dhparameters, const JointConstPtr& joint,
00162 const EigenTransform& parentWorldTransform,
00163 const Eigen::Vector3d& parentX, const Eigen::Vector3d& parentZ,
00164 const Eigen::Vector3d& parentPos, bool asRootJoint,
00165 EigenTransform& parentWorldTransformDH) const;
00166
00170 bool getDHParams(std::vector<DHParam>& dhparameters, const LinkConstPtr& from_link) const;
00171
00172
00176 void scaleParams(std::vector<DHParam>& dh, double scale_factor) const;
00177
00181 void printParams(const std::vector<DHParam>& dh) const;
00182
00194 bool linksToDHReferenceFrames(const std::vector<DHParam>& dh);
00195
00196
00201 void getLimits(const urdf::Joint& j, float& min, float& max);
00202
00206 void getJointMoves(const urdf::Joint& j, float& velocity, float& effort);
00207
00208
00218 bool getXML(const std::vector<DHParam>& dhparams, const std::vector<std::string>& rootFingerJoints,
00219 const std::string& palmLinkName, const std::string * eigenXML,
00220 const std::string * contactsVGR, const std::string& mesh_pathprepend, std::string& result);
00221
00222
00223 inline bool isRevoluting(const JointPtr& joint) const
00224 {
00225 return (joint->type == urdf::Joint::REVOLUTE) || (joint->type == urdf::Joint::CONTINUOUS);
00226 }
00227
00228
00229 inline bool isContinuous(const JointPtr& joint) const
00230 {
00231 return (joint->type == urdf::Joint::CONTINUOUS);
00232 }
00233
00234
00235 inline bool isPrismatic(const JointPtr& joint) const
00236 {
00237 return (joint->type == urdf::Joint::PRISMATIC);
00238 }
00239
00246
00247
00248
00249
00250
00251
00255 void toGlobalCoordinates(const EigenTransform& transform,
00256 const Eigen::Vector3d& input, Eigen::Vector3d& output);
00257
00263 void getGlobalCoordinates(const JointConstPtr& joint,
00264 const EigenTransform& parentWorldTransform,
00265 Eigen::Vector3d& rotationAxis, Eigen::Vector3d& position) const;
00266
00267
00272 bool getDHTransform(const JointPtr& joint, const std::vector<DHParam>& dh, EigenTransform& result) const;
00273
00277 std::string getWorldFileTemplate(const std::string& robotName,
00278 const std::vector<DHParam>& dhparams,
00279 const std::string& prependpath);
00280
00290
00291
00292
00293 bool negateJointMoves;
00294 bool isDHScaled;
00295 bool dhTransformed;
00296
00297 std::vector<DHParam> dh_parameters;
00298 };
00299
00300 }
00301 #endif // URDF2GRASPIT_URDF2GRASPIT_H