17 #ifndef URDF2GAZEBO_HH
18 #define URDF2GAZEBO_HH
20 #include <urdf_model/model.h>
21 #include <urdf_model/link.h>
33 #include "ode/rotation.h"
56 setStaticFlag =
false;
58 isDampingFactor =
false;
70 isInitialJointPosition =
false;
71 isFudgeFactor =
false;
72 provideFeedback =
false;
85 initialJointPosition = 0;
91 material = ge.material;
92 setStaticFlag = ge.setStaticFlag;
94 isDampingFactor = ge.isDampingFactor;
95 isMaxVel = ge.isMaxVel;
96 isMinDepth = ge.isMinDepth;
102 selfCollide = ge.selfCollide;
103 isLaserRetro = ge.isLaserRetro;
104 isStopCfm = ge.isStopCfm;
105 isStopErp = ge.isStopErp;
106 isInitialJointPosition = ge.isInitialJointPosition;
107 isFudgeFactor = ge.isFudgeFactor;
108 provideFeedback = ge.provideFeedback;
109 oldLinkName = ge.oldLinkName;
110 reductionTransform = ge.reductionTransform;
113 dampingFactor = ge.dampingFactor;
115 minDepth = ge.minDepth;
120 laserRetro = ge.laserRetro;
121 stopCfm = ge.stopCfm;
122 stopErp = ge.stopErp;
123 initialJointPosition = ge.initialJointPosition;
124 fudgeFactor = ge.fudgeFactor;
128 private: std::string oldLinkName;
132 private: std::string material;
135 private:
bool setStaticFlag;
136 private:
bool gravity;
137 private:
bool isDampingFactor;
138 private:
double dampingFactor;
139 private:
bool isMaxVel;
140 private:
double maxVel;
141 private:
bool isMinDepth;
142 private:
double minDepth;
143 private:
bool selfCollide;
146 private:
bool isMu1, isMu2, isKp, isKd;
147 private:
double mu1, mu2, kp, kd;
148 private: std::string fdir1;
149 private:
bool isLaserRetro;
150 private:
double laserRetro;
153 private:
bool isStopCfm, isStopErp, isInitialJointPosition, isFudgeFactor;
154 private:
double stopCfm, stopErp, initialJointPosition, fudgeFactor;
155 private:
bool provideFeedback;
158 private: std::vector<TiXmlElement*> blobs;
174 public: TiXmlDocument
InitModelDoc(TiXmlDocument* _xmlDoc);
179 public: TiXmlDocument
InitModelFile(
const std::string &_filename);
187 bool _enforceLimits =
true);
193 private: urdf::Vector3 ParseVector3(TiXmlNode* _key,
double _scale = 1.0);
199 private: std::string Values2str(
unsigned int _count,
const double *_values);
204 private: std::string Vector32Str(
const urdf::Vector3 _vector);
210 private:
void AddKeyValue(TiXmlElement *_elem,
const std::string &_key,
211 const std::string &_value);
214 private:
void AddTransform(TiXmlElement *_elem,
215 const::gazebo::math::Pose& _transform);
221 private:
void PrintMass(
const std::string &_linkName, dMass _mass);
224 private: std::string GetKeyValueAsString(TiXmlElement* _elem);
228 private:
void ParseGazeboExtension(TiXmlDocument &_urdfXml);
231 private:
void InsertGazeboExtensionCollision(TiXmlElement *_elem,
232 const std::string &_linkName);
235 private:
void InsertGazeboExtensionVisual(TiXmlElement *_elem,
236 const std::string &_linkName);
239 private:
void InsertGazeboExtensionLink(TiXmlElement *_elem,
240 const std::string &_linkName);
243 private:
void InsertGazeboExtensionJoint(TiXmlElement *_elem,
244 const std::string &_jointName);
247 private:
void InsertGazeboExtensionRobot(TiXmlElement *_elem);
250 private:
void ListGazeboExtensions();
253 private:
void ListGazeboExtensions(
const std::string &_reference);
257 private:
void ReduceFixedJoints(TiXmlElement *_root,
UrdfLinkPtr _link);
260 private:
void ReduceInertialToParent(
UrdfLinkPtr _link);
263 private:
void ReduceVisualsToParent(
UrdfLinkPtr _link);
266 private:
void ReduceCollisionsToParent(
UrdfLinkPtr _link);
269 private:
void ReduceJointsToParent(
UrdfLinkPtr _link);
272 private:
void ReduceVisualToParent(
UrdfLinkPtr _link,
273 const std::string &_groupName,
277 private:
void ReduceCollisionToParent(
UrdfLinkPtr _link,
278 const std::string &_groupName,
291 private:
void ReduceGazeboExtensionToParent(
UrdfLinkPtr _link);
300 private:
void ReduceGazeboExtensionPluginFrameReplace(
301 std::vector<TiXmlElement*>::iterator _blobIt,
307 private:
void ReduceGazeboExtensionProjectorFrameReplace(
308 std::vector<TiXmlElement*>::iterator _blobIt,
313 private:
void ReduceGazeboExtensionGripperFrameReplace(
314 std::vector<TiXmlElement*>::iterator _blobIt,
319 private:
void ReduceGazeboExtensionJointFrameReplace(
320 std::vector<TiXmlElement*>::iterator _blobIt,
325 private:
void ReduceGazeboExtensionContactSensorFrameReplace(
326 std::vector<TiXmlElement*>::iterator _blobIt,
335 private:
void ReduceGazeboExtensionSensorTransformReduction(
336 std::vector<TiXmlElement*>::iterator _blobIt,
341 private:
void ReduceGazeboExtensionProjectorTransformReduction(
342 std::vector<TiXmlElement*>::iterator _blobIt,
346 private: urdf::Pose TransformToParentFrame(
347 urdf::Pose _transformInLinkFrame,
348 urdf::Pose _parentToLinkTransform);
352 urdf::Pose _parentToLinkTransform);
360 urdf::Pose _parentToLinkTransform);
368 private: std::string GetGeometryBoundingBox(
369 boost::shared_ptr<urdf::Geometry> _geometry,
double *_sizeVals);
373 private:
void PrintCollisionGroups(
UrdfLinkPtr _link);
376 private:
void CreateSDF(TiXmlElement *_root,
381 private:
void CreateLink(TiXmlElement *_root,
386 private:
void CreateCollisions(TiXmlElement* _elem,
390 private:
void CreateVisuals(TiXmlElement* _elem,
394 private:
void CreateInertial(TiXmlElement *_elem,
398 private:
void CreateCollision(TiXmlElement* _elem,
401 const std::string &_oldLinkName = std::string(
""));
404 private:
void CreateVisual(TiXmlElement *_elem,
407 const std::string &_oldLinkName = std::string(
""));
410 private:
void CreateJoint(TiXmlElement *_root,
415 private:
void CreateGeometry(TiXmlElement* _elem,
416 boost::shared_ptr<urdf::Geometry> _geometry);
418 private: std::map<std::string, std::vector<GazeboExtension*> > extensions;
420 private:
bool enforceLimits;
421 private:
bool reduceFixedJoints;