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;
86 initialJointPosition = 0;
92 material = ge.material;
93 setStaticFlag = ge.setStaticFlag;
95 isDampingFactor = ge.isDampingFactor;
96 isMaxVel = ge.isMaxVel;
97 isMinDepth = ge.isMinDepth;
103 selfCollide = ge.selfCollide;
104 isLaserRetro = ge.isLaserRetro;
105 isStopCfm = ge.isStopCfm;
106 isStopErp = ge.isStopErp;
107 isInitialJointPosition = ge.isInitialJointPosition;
108 isFudgeFactor = ge.isFudgeFactor;
109 provideFeedback = ge.provideFeedback;
110 cfmDamping = ge.cfmDamping;
111 oldLinkName = ge.oldLinkName;
112 reductionTransform = ge.reductionTransform;
115 dampingFactor = ge.dampingFactor;
117 minDepth = ge.minDepth;
122 laserRetro = ge.laserRetro;
123 stopCfm = ge.stopCfm;
124 stopErp = ge.stopErp;
125 initialJointPosition = ge.initialJointPosition;
126 fudgeFactor = ge.fudgeFactor;
130 private: std::string oldLinkName;
134 private: std::string material;
137 private:
bool setStaticFlag;
138 private:
bool gravity;
139 private:
bool isDampingFactor;
140 private:
double dampingFactor;
141 private:
bool isMaxVel;
142 private:
double maxVel;
143 private:
bool isMinDepth;
144 private:
double minDepth;
145 private:
bool selfCollide;
148 private:
bool isMu1, isMu2, isKp, isKd;
149 private:
double mu1, mu2, kp, kd;
150 private: std::string fdir1;
151 private:
bool isLaserRetro;
152 private:
double laserRetro;
155 private:
bool isStopCfm, isStopErp, isInitialJointPosition, isFudgeFactor;
156 private:
double stopCfm, stopErp, initialJointPosition, fudgeFactor;
157 private:
bool provideFeedback;
158 private:
bool cfmDamping;
161 private: std::vector<TiXmlElement*> blobs;
177 public: TiXmlDocument
InitModelDoc(TiXmlDocument* _xmlDoc);
182 public: TiXmlDocument
InitModelFile(
const std::string &_filename);
190 bool _enforceLimits =
true);
196 private: urdf::Vector3 ParseVector3(TiXmlNode* _key,
double _scale = 1.0);
202 private: std::string Values2str(
unsigned int _count,
const double *_values);
207 private: std::string Vector32Str(
const urdf::Vector3 _vector);
213 private:
void AddKeyValue(TiXmlElement *_elem,
const std::string &_key,
214 const std::string &_value);
217 private:
void AddTransform(TiXmlElement *_elem,
218 const::gazebo::math::Pose& _transform);
224 private:
void PrintMass(
const std::string &_linkName, dMass _mass);
227 private: std::string GetKeyValueAsString(TiXmlElement* _elem);
231 private:
void ParseGazeboExtension(TiXmlDocument &_urdfXml);
234 private:
void InsertGazeboExtensionCollision(TiXmlElement *_elem,
235 const std::string &_linkName);
238 private:
void InsertGazeboExtensionVisual(TiXmlElement *_elem,
239 const std::string &_linkName);
242 private:
void InsertGazeboExtensionLink(TiXmlElement *_elem,
243 const std::string &_linkName);
246 private:
void InsertGazeboExtensionJoint(TiXmlElement *_elem,
247 const std::string &_jointName);
250 private:
void InsertGazeboExtensionRobot(TiXmlElement *_elem);
253 private:
void ListGazeboExtensions();
256 private:
void ListGazeboExtensions(
const std::string &_reference);
260 private:
void ReduceFixedJoints(TiXmlElement *_root,
UrdfLinkPtr _link);
263 private:
void ReduceInertialToParent(
UrdfLinkPtr _link);
266 private:
void ReduceVisualsToParent(
UrdfLinkPtr _link);
269 private:
void ReduceCollisionsToParent(
UrdfLinkPtr _link);
272 private:
void ReduceJointsToParent(
UrdfLinkPtr _link);
275 private:
void ReduceVisualToParent(
UrdfLinkPtr _link,
276 const std::string &_groupName,
280 private:
void ReduceCollisionToParent(
UrdfLinkPtr _link,
281 const std::string &_groupName,
294 private:
void ReduceGazeboExtensionToParent(
UrdfLinkPtr _link);
303 private:
void ReduceGazeboExtensionPluginFrameReplace(
304 std::vector<TiXmlElement*>::iterator _blobIt,
310 private:
void ReduceGazeboExtensionProjectorFrameReplace(
311 std::vector<TiXmlElement*>::iterator _blobIt,
316 private:
void ReduceGazeboExtensionGripperFrameReplace(
317 std::vector<TiXmlElement*>::iterator _blobIt,
322 private:
void ReduceGazeboExtensionJointFrameReplace(
323 std::vector<TiXmlElement*>::iterator _blobIt,
328 private:
void ReduceGazeboExtensionContactSensorFrameReplace(
329 std::vector<TiXmlElement*>::iterator _blobIt,
338 private:
void ReduceGazeboExtensionSensorTransformReduction(
339 std::vector<TiXmlElement*>::iterator _blobIt,
344 private:
void ReduceGazeboExtensionProjectorTransformReduction(
345 std::vector<TiXmlElement*>::iterator _blobIt,
349 private: urdf::Pose TransformToParentFrame(
350 urdf::Pose _transformInLinkFrame,
351 urdf::Pose _parentToLinkTransform);
355 urdf::Pose _parentToLinkTransform);
363 urdf::Pose _parentToLinkTransform);
371 private: std::string GetGeometryBoundingBox(
372 boost::shared_ptr<urdf::Geometry> _geometry,
double *_sizeVals);
376 private:
void PrintCollisionGroups(
UrdfLinkPtr _link);
379 private:
void CreateSDF(TiXmlElement *_root,
384 private:
void CreateLink(TiXmlElement *_root,
389 private:
void CreateCollisions(TiXmlElement* _elem,
393 private:
void CreateVisuals(TiXmlElement* _elem,
397 private:
void CreateInertial(TiXmlElement *_elem,
401 private:
void CreateCollision(TiXmlElement* _elem,
404 const std::string &_oldLinkName = std::string(
""));
407 private:
void CreateVisual(TiXmlElement *_elem,
410 const std::string &_oldLinkName = std::string(
""));
413 private:
void CreateJoint(TiXmlElement *_root,
418 private:
void CreateGeometry(TiXmlElement* _elem,
419 boost::shared_ptr<urdf::Geometry> _geometry);
421 private: std::map<std::string, std::vector<GazeboExtension*> > extensions;
423 private:
bool enforceLimits;
424 private:
bool reduceFixedJoints;