Project.cpp
Go to the documentation of this file.
1 #include <sys/param.h>
2 #include <iostream>
3 #include <boost/algorithm/string.hpp>
4 
5 #include <libxml/parser.h>
6 #include <libxml/xmlreader.h>
7 #include <libxml/xpath.h>
8 #include <libxml/xpathInternals.h>
9 #include <hrpModel/Config.h>
10 #include "Project.h"
11 
13  showScale(true), showCoM(false), showCoMonFloor(false), showCollision(true){
14  double r = 5.0, pan = M_PI/4, tilt = M_PI/16;
15  double cp = cos(pan), sp = sin(pan);
16  double ct = cos(tilt), st = sin(tilt);
17 
18  hrp::Matrix33 Rp = hrp::rotFromRpy(0,pan,0);
19  hrp::Matrix33 Rt = hrp::rotFromRpy(-tilt, 0, 0);
20  hrp::Matrix33 R = hrp::rotFromRpy(0, M_PI/2,0)*hrp::rotFromRpy(0, 0, M_PI/2)*Rp*Rt;
21  T[ 0] = R(0,0); T[ 1] = R(0,1); T[ 2] = R(0,2); T[ 3] = r*cp*ct;
22  T[ 4] = R(1,0); T[ 5] = R(1,1); T[ 6] = R(1,2); T[ 7] = r*sp*ct;
23  T[ 8] = R(2,0); T[ 9] = R(2,1); T[10] = R(2,2); T[11] = r*st + 0.8;
24  T[12] = 0; T[13] = 0; T[14] = 0; T[15] = 1.0;
25 }
26 
28  m_timeStep(0.001), m_logTimeStep(0.01), m_totalTime(1.0), m_gravity(9.8), m_isEuler(true), m_kinematicsOnly(false), m_realTime(false)
29 {
30 }
31 
32 bool Project::parse(const std::string& filename)
33 {
34  xmlInitParser();
35  xmlDocPtr doc = xmlParseFile(filename.c_str());
36  if ( doc == NULL ) {
37  std::cerr << "unable to parse file(" << filename << ")" << std::endl;
38  return false;
39  }
40 
41  /* Create xpath evaluation context */
42  xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
43  if ( xpathCtx == NULL ) {
44  std::cerr << "unable to create new XPath context" << std::endl;
45  xmlFreeDoc(doc);
46  return false;
47  }
48 
49  /* Evaluate xpath expression */
50  xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "/grxui/mode/item", xpathCtx);
51  if ( xmlXPathNodeSetIsEmpty(xpathObj->nodesetval) ) {
52  std::cerr << "unable to find <mode>" << std::endl;
53  }
54 
55  int size;
56  size = xpathObj->nodesetval->nodeNr;
57 
58  for (int i = 0; i < size; i++ ) {
59  xmlNodePtr node = xpathObj->nodesetval->nodeTab[i];
60  //std::cerr << i << " class:" << xmlGetProp(node, (xmlChar *)"class") << std::endl;
61  if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxSimulationItem") ) {
62  xmlNodePtr cur_node = node->children;
63  while ( cur_node ) {
64  if ( cur_node->type == XML_ELEMENT_NODE ) {
65  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"integrate") ) {
66  m_kinematicsOnly = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "false";
67 
68  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"viewsimulate") ) {
69  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"totalTime") ) {
70  m_totalTime = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
71  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"timeStep") ) {
72  m_timeStep = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
73  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"realTime") ) {
74  m_realTime = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "true";
75  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"gravity") ) {
76  m_gravity = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
77  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"method") ) {
78  m_isEuler = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == std::string("EULER");
79  } else {
80 #if 0
81  std::cerr << "Unknown tag : " << cur_node->name << " "
82  << "name=" << xmlGetProp(cur_node, (xmlChar *)"name")
83  << "value=" << xmlGetProp(cur_node, (xmlChar *)"value") << std::endl;
84 #endif
85  }
86  }
87  cur_node = cur_node->next;
88  }
89  } else if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxRTSItem") ) {
90  xmlNodePtr cur_node = node->children;
91  while ( cur_node ) {
92  if ( cur_node->type == XML_ELEMENT_NODE ) {
93  std::string name = (char *)xmlGetProp(cur_node, (xmlChar *)"name");
94  std::string value = (char *)xmlGetProp(cur_node, (xmlChar *)"value");
95  //std::cout << name << "," << value << std::endl;
96 
97  if (name == "connection"){
98  int pos = value.find(':');
99  if (pos < 0){
100  std::cerr << "can't find a separator(:) in "
101  << value << std::endl;
102  }else{
103  std::string p1 = value.substr(0,pos);
104  std::string p2 = value.substr(pos+1);
105  m_rts.connections.push_back(std::make_pair(p1, p2));
106  }
107  }else{
108  int pos = name.find('.');
109  if (pos < 0){
110  std::cerr << "unknown property name:" << name
111  << std::endl;
112  }else{
113  std::string comp = name.substr(0,pos);
114  std::string cat = name.substr(pos+1);
115  RTSItem::rtc &rtc = m_rts.components[comp];
116  if (cat == "factory"){
117  rtc.path = value;
118  int pos = value.find_last_of("/");
119  rtc.name = value.substr(pos+1);
120  }else if (cat == "period") {
121  rtc.period = atof(value.c_str());
122  }else{
123  rtc.configuration.push_back(std::make_pair(cat, value));
124  }
125  }
126  }
127  }
128  cur_node = cur_node->next;
129  }
130  } else if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxModelItem") ) {
131  //std::cerr << "GrxModelItem name:" << xmlGetProp(node, (xmlChar *)"name") << ", url:" << xmlGetProp(node, (xmlChar *)"url") << std::endl;
132  std::string path = (char *)xmlGetProp(node, (xmlChar *)"url");
133  if ( path.find("$(CURRENT_DIR)") != std::string::npos ) {
134  if (filename.find_last_of("/") != std::string::npos){
135  path.replace(path.find("$(CURRENT_DIR)"),14,
136  filename.substr(0, filename.find_last_of("/")));
137  }else{
138  path.replace(path.find("$(CURRENT_DIR)"),15, "");
139  }
140  if (path[0] != '/'){
141  char buf[MAXPATHLEN];
142  path = std::string(getcwd(buf, MAXPATHLEN))+"/"+path;
143  }
144  }
145  if ( path.find("$(PROJECT_DIR)") != std::string::npos ) {
146  std::string shdir = OPENHRP_SHARE_DIR;
147  std::string pjdir = shdir + "/sample/project";
148  path.replace(path.find("$(PROJECT_DIR)"),14, pjdir);
149  }
150  ModelItem m;
151  m.url = std::string("file://")+path;
152  xmlNodePtr cur_node = node->children;
153  while ( cur_node ) {
154  if ( cur_node->type == XML_ELEMENT_NODE ) {
155  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"isRobot") ) {
156  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"value"),(xmlChar *)"true")) {
157  //isRobot = true;
158  }
159  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"controlTime") ) {
160  //controlTimeStep = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
161  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"rtcName") ) {
162  m.rtcName = (char *)xmlGetProp(cur_node, (xmlChar *)"value");
163  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"inport") ) {
164  m.inports.push_back((char *)xmlGetProp(cur_node, (xmlChar *)"value"));
165  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"outport") ) {
166  m.outports.push_back((char *)xmlGetProp(cur_node, (xmlChar *)"value"));
167  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".angle") != std::string::npos ) {
168  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
169  name.erase(name.rfind(".angle"));
170  m.joint[name].angle = atof((char *)xmlGetProp(cur_node, (xmlChar *)"value"));
171  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".mode") != std::string::npos ) {
172  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
173  name.erase(name.rfind(".mode"));
174  m.joint[name].isHighGain = xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"value"), (xmlChar *)"HighGain");
175  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".NumOfAABB") != std::string::npos ) {
176  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
177  name.erase(name.rfind(".NumOfAABB"));
178  m.joint[name].NumOfAABB = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
179  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".collisionShape") != std::string::npos ) {
180  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
181  name.erase(name.rfind(".collisionShape"));
182  m.joint[name].collisionShape = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
183  boost::trim(m.joint[name].collisionShape);
184  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".translation") != std::string::npos ) {
185  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
186  name.erase(name.rfind(".translation"));
187  float x, y, z;
188  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
189  m.joint[name].translation[0] = x; m.joint[name].translation[1] = y; m.joint[name].translation[2] = z;
190  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".rotation") != std::string::npos ) {
191  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
192  name.erase(name.rfind(".rotation"));
193  float x, y, z, w;
194  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f %f", &x, &y, &z, &w);
195  hrp::calcRodrigues(m.joint[name].rotation, hrp::Vector3(x, y, z), w);
196  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".velocity") != std::string::npos ) {
197  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
198  name.erase(name.rfind(".velocity"));
199  float x, y, z;
200  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
201  m.joint[name].linearVelocity << x, y, z;
202  } else if ( std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name")).rfind(".angularVelocity") != std::string::npos ) {
203  std::string name = std::string((char *)xmlGetProp(cur_node, (xmlChar *)"name"));
204  name.erase(name.rfind(".angularVelocity"));
205  float x, y, z;
206  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
207  m.joint[name].angularVelocity << x, y, z;
208  } else {
209 #if 0
210  std::cerr << "Unknown tag : " << cur_node->name << " "
211  << "name=" << xmlGetProp(cur_node, (xmlChar *)"name") << " "
212  << "value=" << xmlGetProp(cur_node, (xmlChar *)"value") << std::endl;
213 #endif
214  }
215  }
216  cur_node = cur_node->next;
217  }
218  std::string n = std::string((char *)xmlGetProp(node, (xmlChar *)"name"));
219  m_models[n] = m;
220  } else if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxWorldStateItem") ) {
221  xmlNodePtr cur_node = node->children;
222  while ( cur_node ) {
223  if ( cur_node->type == XML_ELEMENT_NODE ) {
224  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"logTimeStep") ) {
225  m_logTimeStep = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
226  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"timeStep") ) {
227  m_timeStep = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
228  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"totalTime") ) {
229  m_totalTime = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
230  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"method") ) {
231  m_isEuler = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == std::string("EULER");
232  }
233  }
234  cur_node = cur_node->next;
235  }
236  } else if ( xmlStrEqual ( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxCollisionPairItem") ) {
238  xmlNodePtr cur_node = node->children;
239  while ( cur_node ) {
240  if ( cur_node->type == XML_ELEMENT_NODE ) {
241  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"objectName1") ) {
242  c.objectName1 = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
243  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"objectName2") ) {
244  c.objectName2 = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
245  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"jointName1") ) {
246  c.jointName1 = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
247  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"jointName2") ) {
248  c.jointName2 = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
249  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"slidingFriction") ) {
250  c.slidingFriction = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
251  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"staticFriction") ) {
252  c.staticFriction = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
253  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"cullingThresh") ) {
254  c.cullingThresh = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
255  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"Restitution") ) {
256  c.restitution = atof((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
257  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"sprintDamperModel") ) {
258  c.sprintDamperModel = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
259  } else {
260 #if 0
261  std::cerr << "Unknown tag : " << cur_node->name << " "
262  << ", name=" << xmlGetProp(cur_node, (xmlChar *)"name")
263  << ", value=" << xmlGetProp(cur_node, (xmlChar *)"value") << std::endl;
264 #endif
265  }
266  }
267  cur_node = cur_node->next;
268  }
269  m_collisionPairs.push_back(c);
270  } else if ( xmlStrEqual ( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.item.GrxExtraJointItem") ) {
272  xmlNodePtr cur_node = node->children;
273  while ( cur_node ) {
274  if ( cur_node->type == XML_ELEMENT_NODE ) {
275  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"object1Name") ) {
276  c.object1Name = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
277  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"object2Name") ) {
278  c.object2Name = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
279  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"link1Name") ) {
280  c.link1Name = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
281  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"link2Name") ) {
282  c.link2Name = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
283  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"jointType") ) {
284  c.jointType = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
285  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"jointAxis") ) {
286  float x, y, z;
287  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
288  c.jointAxis[0] = x; c.jointAxis[1] = y; c.jointAxis[2] = z;
289  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"link1LocalPos") ) {
290  float x, y, z;
291  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
292  c.link1LocalPos[0] = x; c.link1LocalPos[1] = y; c.link1LocalPos[2] = z;
293  } else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"link2LocalPos") ) {
294  float x, y, z;
295  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%f %f %f", &x, &y, &z);
296  c.link2LocalPos[0] = x; c.link2LocalPos[1] = y; c.link2LocalPos[2] = z;
297  } else {
298 #if 0
299  std::cerr << "Unknown tag : " << cur_node->name << " "
300  << ", name=" << xmlGetProp(cur_node, (xmlChar *)"name")
301  << ", value=" << xmlGetProp(cur_node, (xmlChar *)"value") << std::endl;
302 #endif
303  }
304  }
305  cur_node = cur_node->next;
306  }
307  m_extraJoints.push_back(c);
308  }
309  }
310 
311  /* Cleanup Xpath Data */
312  xmlXPathFreeObject(xpathObj);
313  xmlXPathFreeContext(xpathCtx);
314 
315  {
316  /* Create xpath evaluation context */
317  xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
318  if ( xpathCtx == NULL ) {
319  std::cerr << "unable to create new XPath context" << std::endl;
320  xmlFreeDoc(doc);
321  return false;
322  }
323 
324  xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "/grxui/mode/view", xpathCtx);
325  if ( xmlXPathNodeSetIsEmpty(xpathObj->nodesetval) ) {
326  std::cerr << "unable to find <mode>" << std::endl;
327  }
328 
329  int size;
330  size = xpathObj->nodesetval->nodeNr;
331 
332  for (int i = 0; i < size; i++ ) {
333  xmlNodePtr node = xpathObj->nodesetval->nodeTab[i];
334  //std::cerr << i << " class:" << xmlGetProp(node, (xmlChar *)"class") << std::endl;
335  if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.view.GrxRobotHardwareClientView") ) {
336  xmlNodePtr cur_node = node->children;
337  while ( cur_node ) {
338  if ( cur_node->type == XML_ELEMENT_NODE ) {
339  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"robotHost") ) {
340  m_rhview.hostname = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
341  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"robotPort") ) {
342  m_rhview.port = atoi((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
343  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"interval") ) {
344  m_rhview.interval = atoi((char *)(xmlGetProp(cur_node, (xmlChar *)"value")));
345  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"stateProvider") ) {
346  m_rhview.RobotHardwareName = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
347  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"StateHolderRTC") ) {
348  m_rhview.StateHolderName = (char *)(xmlGetProp(cur_node, (xmlChar *)"value"));
349  }
350  }
351  cur_node = cur_node->next;
352  }
353  } else if ( xmlStrEqual( xmlGetProp(node, (xmlChar *)"class"), (xmlChar *)"com.generalrobotix.ui.view.Grx3DView") ) {
354  xmlNodePtr cur_node = node->children;
355  while ( cur_node ) {
356  if ( cur_node->type == XML_ELEMENT_NODE ) {
357  if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"showScale") ) {
358  m_3dview.showScale = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "true";
359  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"showCoM") ) {
360  m_3dview.showCoM = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "true";
361  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"showCoMonFloor") ) {
362  m_3dview.showCoMonFloor = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "true";
363  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"showCollision") ) {
364  m_3dview.showCollision = std::string((char *)(xmlGetProp(cur_node, (xmlChar *)"value"))) == "true";
365  }else if ( xmlStrEqual(xmlGetProp(cur_node, (xmlChar *)"name"),(xmlChar *)"eyeHomePosition") ) {
366  sscanf(((char *)xmlGetProp(cur_node, (xmlChar *)"value")),"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf ",
367  &m_3dview.T[0],&m_3dview.T[1],&m_3dview.T[2],&m_3dview.T[3],
368  &m_3dview.T[4],&m_3dview.T[5],&m_3dview.T[6],&m_3dview.T[7],
369  &m_3dview.T[8],&m_3dview.T[9],&m_3dview.T[10],&m_3dview.T[11]);
370  }
371  }
372  cur_node = cur_node->next;
373  }
374  }
375  }
376  xmlXPathFreeObject(xpathObj);
377  xmlXPathFreeContext(xpathCtx);
378  }
379 
380  /* free the document */
381  xmlFreeDoc(doc);
382  xmlCleanupParser();
383 
384  return true;
385 }
386 
std::map< std::string, rtc > components
Definition: Project.h:79
bool showScale
Definition: Project.h:97
Project()
Definition: Project.cpp:27
std::string jointType
Definition: Project.h:57
double m_totalTime
Definition: Project.h:122
bool parse(const std::string &filename)
Definition: Project.cpp:32
double slidingFriction
Definition: Project.h:15
png_uint_32 size
png_infop png_charpp name
std::vector< CollisionPairItem > m_collisionPairs
Definition: Project.h:128
png_voidp int value
std::string hostname
Definition: Project.h:89
bool m_kinematicsOnly
Definition: Project.h:125
w
std::string objectName1
Definition: Project.h:11
png_uint_32 i
std::string link1Name
Definition: Project.h:57
std::vector< std::string > outports
Definition: Project.h:66
std::string jointName2
Definition: Project.h:14
ThreeDView m_3dview
Definition: Project.h:132
Eigen::Vector3d Vector3
bool showCoM
Definition: Project.h:97
Matrix33 rotFromRpy(const Vector3 &rpy)
Eigen::Matrix3d Matrix33
std::string url
Definition: Project.h:62
RTSItem m_rts
Definition: Project.h:130
std::string object1Name
Definition: Project.h:57
cur_node
std::string rtcName
Definition: Project.h:64
std::string name
Definition: Project.h:74
std::string RobotHardwareName
Definition: Project.h:89
double restitution
Definition: Project.h:18
HRP_UTIL_EXPORT void calcRodrigues(Matrix44 &out_R, const Vector3 &axis, double q)
bool showCoMonFloor
Definition: Project.h:97
double staticFriction
Definition: Project.h:16
std::map< std::string, ModelItem > m_models
Definition: Project.h:127
std::string link2Name
Definition: Project.h:57
n
std::string sprintDamperModel
Definition: Project.h:19
RobotHardwareClientView m_rhview
Definition: Project.h:131
png_bytep buf
path
std::string jointName1
Definition: Project.h:13
double period
Definition: Project.h:76
hrp::Vector3 link2LocalPos
Definition: Project.h:56
std::vector< ExtraJointItem > m_extraJoints
Definition: Project.h:129
std::vector< std::string > inports
Definition: Project.h:65
std::vector< std::pair< std::string, std::string > > configuration
Definition: Project.h:77
#define M_PI
std::string objectName2
Definition: Project.h:12
double m_gravity
Definition: Project.h:123
std::vector< std::pair< std::string, std::string > > connections
Definition: Project.h:80
std::map< std::string, JointItem > joint
Definition: Project.h:63
double T[16]
Definition: Project.h:98
double cullingThresh
Definition: Project.h:17
ThreeDView()
Definition: Project.cpp:12
std::string object2Name
Definition: Project.h:57
bool showCollision
Definition: Project.h:97
std::string path
Definition: Project.h:75
hrp::Vector3 jointAxis
Definition: Project.h:55
bool m_realTime
Definition: Project.h:126
double m_logTimeStep
Definition: Project.h:121
double m_timeStep
Definition: Project.h:121
hrp::Vector3 link1LocalPos
Definition: Project.h:56
std::string StateHolderName
Definition: Project.h:89
bool m_isEuler
Definition: Project.h:124


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:50