All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules
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 #include "sdf/system_util.hh"
28 
29 namespace sdf
30 {
33 
36  {
37  private: SDFExtension()
38  {
39  material.clear();
40  visual_blobs.clear();
41  setStaticFlag = false;
42  gravity = true;
43  isDampingFactor = false;
44  isMaxContacts = false;
45  isMaxVel = false;
46  isMinDepth = false;
47  fdir1.clear();
48  isMu1 = false;
49  isMu2 = false;
50  isKp = false;
51  isKd = false;
52  selfCollide = false;
53  isLaserRetro = false;
54  isStopCfm = false;
55  isStopErp = false;
56  isStopKp = false;
57  isStopKd = false;
58  isInitialJointPosition = false;
59  isFudgeFactor = false;
60  isProvideFeedback = false;
61  isImplicitSpringDamper = false;
62  blobs.clear();
63 
64  dampingFactor = 0;
65  maxContacts = 0;
66  maxVel = 0;
67  minDepth = 0;
68  mu1 = 0;
69  mu2 = 0;
70  kp = 100000000;
71  kd = 1;
72  laserRetro = 101;
73  stopCfm = 0;
74  stopErp = 0.1;
75  stopKp = 100000000;
76  stopKd = 1;
77  initialJointPosition = 0;
78  fudgeFactor = 1;
79 
80  provideFeedback = false;
81  implicitSpringDamper = false;
82  };
83 
84  private: SDFExtension(const SDFExtension &ge)
85  {
86  material = ge.material;
87  visual_blobs = ge.visual_blobs;
88  setStaticFlag = ge.setStaticFlag;
89  gravity = ge.gravity;
90  isDampingFactor = ge.isDampingFactor;
91  isMaxContacts = ge.isMaxContacts;
92  isMaxVel = ge.isMaxVel;
93  isMinDepth = ge.isMinDepth;
94  fdir1 = ge.fdir1;
95  isMu1 = ge.isMu1;
96  isMu2 = ge.isMu2;
97  isKp = ge.isKp;
98  isKd = ge.isKd;
99  selfCollide = ge.selfCollide;
100  isLaserRetro = ge.isLaserRetro;
101  isStopKp = ge.isStopKp;
102  isStopKd = ge.isStopKd;
103  isStopCfm = ge.isStopCfm;
104  isStopErp = ge.isStopErp;
105  isInitialJointPosition = ge.isInitialJointPosition;
106  isFudgeFactor = ge.isFudgeFactor;
107  isProvideFeedback = ge.isProvideFeedback;
108  isImplicitSpringDamper = ge.isImplicitSpringDamper;
109  provideFeedback = ge.provideFeedback;
110  implicitSpringDamper = ge.implicitSpringDamper;
111  oldLinkName = ge.oldLinkName;
112  reductionTransform = ge.reductionTransform;
113  blobs = ge.blobs;
114 
115  dampingFactor = ge.dampingFactor;
116  maxContacts = ge.maxContacts;
117  maxVel = ge.maxVel;
118  minDepth = ge.minDepth;
119  mu1 = ge.mu1;
120  mu2 = ge.mu2;
121  kp = ge.kp;
122  kd = ge.kd;
123  laserRetro = ge.laserRetro;
124  stopKp = ge.stopKp;
125  stopKd = ge.stopKd;
126  stopCfm = ge.stopCfm;
127  stopErp = ge.stopErp;
128  initialJointPosition = ge.initialJointPosition;
129  fudgeFactor = ge.fudgeFactor;
130  };
131 
132  // for reducing fixed joints and removing links
133  public: std::string oldLinkName;
135 
136  // visual
137  public: std::string material;
138  public: std::vector<boost::shared_ptr<TiXmlElement> > visual_blobs;
139 
140  // body, default off
141  public: bool setStaticFlag;
142  public: bool gravity;
143  public: bool isDampingFactor;
144  public: double dampingFactor;
145  public: bool isMaxContacts;
146  public: int maxContacts;
147  public: bool isMaxVel;
148  public: double maxVel;
149  public: bool isMinDepth;
150  public: double minDepth;
151  public: bool selfCollide;
152 
153  // geom, contact dynamics
154  public: bool isMu1, isMu2, isKp, isKd;
155  public: double mu1, mu2, kp, kd;
156  public: std::string fdir1;
157  public: bool isLaserRetro;
158  public: double laserRetro;
159 
160  // joint, joint limit dynamics
161  public: bool isStopCfm, isStopErp, isInitialJointPosition, isFudgeFactor;
162  public: double stopCfm, stopErp, initialJointPosition, fudgeFactor;
163  public: bool isProvideFeedback;
164  public: bool provideFeedback;
166  public: bool implicitSpringDamper;
167  private: bool isStopKp, isStopKd;
168  private: double stopKp, stopKd;
169 
170  // blobs into body or robot
171  public: std::vector<boost::shared_ptr<TiXmlElement> > blobs;
172 
174  };
175 
178  {
180  public: URDF2SDF();
181 
183  public: ~URDF2SDF();
184 
188  public: TiXmlDocument InitModelDoc(TiXmlDocument* _xmlDoc);
189 
193  public: TiXmlDocument InitModelFile(const std::string &_filename);
194 
200  public: TiXmlDocument InitModelString(const std::string &_urdfStr,
201  bool _enforceLimits = true);
202 
205  private: void ParseSDFExtension(TiXmlDocument &_urdfXml);
206 
208  private: void ListSDFExtensions();
209 
211  private: void ListSDFExtensions(const std::string &_reference);
212  };
214 }
215 
216 #endif
bool isFudgeFactor
Definition: parser_urdf.hh:161
bool isDampingFactor
Definition: parser_urdf.hh:143
std::string oldLinkName
Definition: parser_urdf.hh:130
bool isMaxContacts
Definition: parser_urdf.hh:145
bool isInitialJointPosition
Definition: parser_urdf.hh:161
bool isMinDepth
Definition: parser_urdf.hh:149
double mu2
Definition: parser_urdf.hh:155
bool isStopErp
Definition: parser_urdf.hh:161
double stopErp
Definition: parser_urdf.hh:162
A class for holding sdf extension elements in urdf.
Definition: parser_urdf.hh:35
double laserRetro
Definition: parser_urdf.hh:158
bool isMaxVel
Definition: parser_urdf.hh:147
bool isProvideFeedback
Definition: parser_urdf.hh:163
int maxContacts
Definition: parser_urdf.hh:146
double minDepth
Definition: parser_urdf.hh:150
bool provideFeedback
Definition: parser_urdf.hh:164
bool isKd
Definition: parser_urdf.hh:154
std::string material
Definition: parser_urdf.hh:137
double initialJointPosition
Definition: parser_urdf.hh:162
bool isMu1
Definition: parser_urdf.hh:154
double fudgeFactor
Definition: parser_urdf.hh:162
bool isImplicitSpringDamper
Definition: parser_urdf.hh:165
double kp
Definition: parser_urdf.hh:155
bool selfCollide
Definition: parser_urdf.hh:151
sdf::Pose reductionTransform
Definition: parser_urdf.hh:134
bool setStaticFlag
Definition: parser_urdf.hh:141
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
bool isLaserRetro
Definition: parser_urdf.hh:157
bool isKp
Definition: parser_urdf.hh:154
double maxVel
Definition: parser_urdf.hh:148
bool isStopCfm
Definition: parser_urdf.hh:161
double kd
Definition: parser_urdf.hh:155
bool gravity
Definition: parser_urdf.hh:142
double dampingFactor
Definition: parser_urdf.hh:144
bool isMu2
Definition: parser_urdf.hh:154
std::vector< TiXmlElement > * visual_blobs
Definition: parser_urdf.hh:138
double stopCfm
Definition: parser_urdf.hh:162
double mu1
Definition: parser_urdf.hh:155
bool implicitSpringDamper
Definition: parser_urdf.hh:166
namespace for Simulation Description Format parser
Definition: Console.hh:29
std::string fdir1
Definition: parser_urdf.hh:156
std::vector< TiXmlElement > * blobs
Definition: parser_urdf.hh:171
URDF to SDF converter.
Definition: parser_urdf.hh:177
Encapsulates a position and rotation in three space.
Definition: Types.hh:582