All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
parser_urdf.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef URDF2SDF_HH
18 #define URDF2SDF_HH
19 
20 #include <tinyxml.h>
21 #include <vector>
22 #include <string>
23 #include <map>
24 
25 #include "sdf/Types.hh"
26 #include "sdf/Console.hh"
27 
28 namespace sdf
29 {
32 
35  {
36  private: SDFExtension()
37  {
38  material.clear();
39  visual_blobs.clear();
40  setStaticFlag = false;
41  gravity = true;
42  isDampingFactor = false;
43  isMaxContacts = false;
44  isMaxVel = false;
45  isMinDepth = false;
46  fdir1.clear();
47  isMu1 = false;
48  isMu2 = false;
49  isKp = false;
50  isKd = false;
51  selfCollide = false;
52  isLaserRetro = false;
53  isStopCfm = false;
54  isStopErp = false;
55  isStopKp = false;
56  isStopKd = false;
57  isInitialJointPosition = false;
58  isFudgeFactor = false;
59  isProvideFeedback = false;
60  isImplicitSpringDamper = false;
61  blobs.clear();
62 
63  dampingFactor = 0;
64  maxContacts = 0;
65  maxVel = 0;
66  minDepth = 0;
67  mu1 = 0;
68  mu2 = 0;
69  kp = 100000000;
70  kd = 1;
71  laserRetro = 101;
72  stopCfm = 0;
73  stopErp = 0.1;
74  stopKp = 100000000;
75  stopKd = 1;
77  fudgeFactor = 1;
78 
79  provideFeedback = false;
80  implicitSpringDamper = false;
81  };
82 
83  private: SDFExtension(const SDFExtension &ge)
84  {
85  material = ge.material;
88  gravity = ge.gravity;
91  isMaxVel = ge.isMaxVel;
93  fdir1 = ge.fdir1;
94  isMu1 = ge.isMu1;
95  isMu2 = ge.isMu2;
96  isKp = ge.isKp;
97  isKd = ge.isKd;
100  isStopKp = ge.isStopKp;
101  isStopKd = ge.isStopKd;
102  isStopCfm = ge.isStopCfm;
103  isStopErp = ge.isStopErp;
112  blobs = ge.blobs;
113 
116  maxVel = ge.maxVel;
117  minDepth = ge.minDepth;
118  mu1 = ge.mu1;
119  mu2 = ge.mu2;
120  kp = ge.kp;
121  kd = ge.kd;
122  laserRetro = ge.laserRetro;
123  stopKp = ge.stopKp;
124  stopKd = ge.stopKd;
125  stopCfm = ge.stopCfm;
126  stopErp = ge.stopErp;
129  };
130 
131  // for reducing fixed joints and removing links
132  public: std::string oldLinkName;
134 
135  // visual
136  public: std::string material;
137  public: std::vector<boost::shared_ptr<TiXmlElement> > visual_blobs;
138 
139  // body, default off
140  public: bool setStaticFlag;
141  public: bool gravity;
142  public: bool isDampingFactor;
143  public: double dampingFactor;
144  public: bool isMaxContacts;
145  public: int maxContacts;
146  public: bool isMaxVel;
147  public: double maxVel;
148  public: bool isMinDepth;
149  public: double minDepth;
150  public: bool selfCollide;
151 
152  // geom, contact dynamics
153  public: bool isMu1, isMu2, isKp, isKd;
154  public: double mu1, mu2, kp, kd;
155  public: std::string fdir1;
156  public: bool isLaserRetro;
157  public: double laserRetro;
158 
159  // joint, joint limit dynamics
162  public: bool isProvideFeedback;
163  public: bool provideFeedback;
165  public: bool implicitSpringDamper;
166  private: bool isStopKp, isStopKd;
167  private: double stopKp, stopKd;
168 
169  // blobs into body or robot
170  public: std::vector<boost::shared_ptr<TiXmlElement> > blobs;
171 
172  friend class URDF2SDF;
173  };
174 
176  class URDF2SDF
177  {
179  public: URDF2SDF();
180 
182  public: ~URDF2SDF();
183 
187  public: TiXmlDocument InitModelDoc(TiXmlDocument* _xmlDoc);
188 
192  public: TiXmlDocument InitModelFile(const std::string &_filename);
193 
199  public: TiXmlDocument InitModelString(const std::string &_urdfStr,
200  bool _enforceLimits = true);
201 
204  private: void ParseSDFExtension(TiXmlDocument &_urdfXml);
205 
207  private: void ListSDFExtensions();
208 
210  private: void ListSDFExtensions(const std::string &_reference);
211  };
213 }
214 
215 #endif
bool isFudgeFactor
Definition: parser_urdf.hh:160
bool isDampingFactor
Definition: parser_urdf.hh:142
std::string oldLinkName
Definition: parser_urdf.hh:129
bool isMaxContacts
Definition: parser_urdf.hh:144
bool isInitialJointPosition
Definition: parser_urdf.hh:160
bool isMinDepth
Definition: parser_urdf.hh:148
double mu2
Definition: parser_urdf.hh:154
bool isStopErp
Definition: parser_urdf.hh:160
double stopErp
Definition: parser_urdf.hh:161
A class for holding sdf extension elements in urdf.
Definition: parser_urdf.hh:34
double laserRetro
Definition: parser_urdf.hh:157
bool isMaxVel
Definition: parser_urdf.hh:146
bool isProvideFeedback
Definition: parser_urdf.hh:162
int maxContacts
Definition: parser_urdf.hh:145
double minDepth
Definition: parser_urdf.hh:149
bool provideFeedback
Definition: parser_urdf.hh:163
~URDF2SDF()
destructor
bool isKd
Definition: parser_urdf.hh:153
TiXmlDocument InitModelDoc(TiXmlDocument *_xmlDoc)
convert urdf xml document string to sdf xml document
std::string material
Definition: parser_urdf.hh:136
double initialJointPosition
Definition: parser_urdf.hh:161
TiXmlDocument InitModelString(const std::string &_urdfStr, bool _enforceLimits=true)
convert urdf string to sdf xml document, with option to enforce limits.
bool isMu1
Definition: parser_urdf.hh:153
TiXmlDocument InitModelFile(const std::string &_filename)
convert urdf file to sdf xml document
double fudgeFactor
Definition: parser_urdf.hh:161
bool isImplicitSpringDamper
Definition: parser_urdf.hh:164
double kp
Definition: parser_urdf.hh:154
bool selfCollide
Definition: parser_urdf.hh:150
sdf::Pose reductionTransform
Definition: parser_urdf.hh:133
bool setStaticFlag
Definition: parser_urdf.hh:140
bool isLaserRetro
Definition: parser_urdf.hh:156
bool isKp
Definition: parser_urdf.hh:153
double maxVel
Definition: parser_urdf.hh:147
bool isStopCfm
Definition: parser_urdf.hh:160
double kd
Definition: parser_urdf.hh:154
bool gravity
Definition: parser_urdf.hh:141
double dampingFactor
Definition: parser_urdf.hh:143
bool isMu2
Definition: parser_urdf.hh:153
URDF2SDF()
constructor
std::vector< TiXmlElement > * visual_blobs
Definition: parser_urdf.hh:137
double stopCfm
Definition: parser_urdf.hh:161
double mu1
Definition: parser_urdf.hh:154
bool implicitSpringDamper
Definition: parser_urdf.hh:165
std::string fdir1
Definition: parser_urdf.hh:155
std::vector< TiXmlElement > * blobs
Definition: parser_urdf.hh:170
URDF to SDF converter.
Definition: parser_urdf.hh:176
Encapsulates a position and rotation in three space.
Definition: Types.hh:580