mjcf-graph.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2024 CNRS INRIA
3 //
4 
6 
7 namespace pinocchio
8 {
9  namespace mjcf
10  {
11  namespace details
12  {
14  typedef pinocchio::urdf::details::
15  UrdfVisitor<double, 0, ::pinocchio::JointCollectionDefaultTpl>
17 
18  // supported elements from mjcf
19  static const std::array<std::string, 3> ELEMENTS = {"joint", "geom", "site"};
20 
24  static void copyPtree(const ptree & src, ptree & dst)
25  {
26  for (const ptree::value_type & v : src)
27  dst.put(ptree::path_type(v.first), v.second.data());
28  }
29 
33  static void updateClassElement(ptree & current, const ptree & parent)
34  {
35  for (const std::string & el : ELEMENTS)
36  {
37  std::string path = el + ".<xmlattr>";
38  if (parent.get_child_optional(path))
39  {
40  const ptree default_value = ptree();
41  ptree attr_parent = parent.get_child(path, default_value);
42  const ptree & attr_current = current.get_child(path, default_value);
43  // To only copy non existing attribute in current, we copy all current
44  // attribute (replacing) into a parent copy then we replace current with the new
45  // ptree
46  copyPtree(attr_current, attr_parent);
47  current.put_child(path, attr_parent);
48  }
49  }
50  }
51 
52  static std::string getName(const ptree & el, const boost::filesystem::path & filePath)
53  {
54  auto n = el.get_optional<std::string>("<xmlattr>.name");
55  if (n)
56  return *n;
57  else
58  {
59  if (filePath.extension().empty())
60  throw std::invalid_argument("Cannot find extension for one of the mesh/texture");
61 
62  auto st = filePath.stem();
63  if (!st.empty())
64  return st.string();
65  else
66  throw std::invalid_argument("Cannot find a name for one of the mesh.texture");
67  }
68  }
69 
71  bool strippath,
72  const std::string & dir,
73  const std::string & modelPath,
74  const boost::filesystem::path & filePath)
75  {
76  namespace fs = boost::filesystem;
77 
78  // Check if filename still has Absolute path, like said in mujoco doc
79  if (filePath.is_absolute() && !strippath)
80  return filePath;
81  else
82  {
83  auto filename = filePath;
84  if (strippath)
85  filename = filePath.filename();
86 
87  fs::path meshPath(dir);
88  if (meshPath.is_absolute())
89  return (meshPath / filename);
90  else
91  {
92  fs::path mainPath(modelPath);
93  return (mainPath.parent_path() / meshPath / filename);
94  }
95  }
96  }
97 
98  double MjcfCompiler::convertAngle(const double & angle_) const
99  {
100  return angle_ * angle_converter;
101  }
102 
103  Eigen::Matrix3d MjcfCompiler::convertEuler(const Eigen::Vector3d & angles) const
104  {
105  Eigen::Matrix3d aa1 =
106  Eigen::AngleAxisd(convertAngle(angles(0)), mapEulerAngles.col(0)).toRotationMatrix();
107  Eigen::Matrix3d aa2 =
108  Eigen::AngleAxisd(convertAngle(angles(1)), mapEulerAngles.col(1)).toRotationMatrix();
109  Eigen::Matrix3d aa3 =
110  Eigen::AngleAxisd(convertAngle(angles(2)), mapEulerAngles.col(2)).toRotationMatrix();
111 
112  return aa1 * aa2 * aa3;
113  }
114 
115  template<int Nq, int Nv>
117  {
118  typedef UrdfVisitor::Vector Vector;
119  const double infty = std::numeric_limits<double>::infinity();
120 
121  RangeJoint ret;
122  ret.maxEffort = Vector::Constant(Nv, infty);
123  ret.maxVel = Vector::Constant(Nv, infty);
124  ret.maxConfig = Vector::Constant(Nq, 1.01);
125  ret.minConfig = Vector::Constant(Nq, -1.01);
126  ret.friction = Vector::Constant(Nv, 0.);
127  ret.damping = Vector::Constant(Nv, 0.);
128  ret.armature = armature;
132  return ret;
133  }
134 
135  template<int Nq, int Nv>
137  {
138  assert(range.maxEffort.size() == Nv);
139  assert(range.minConfig.size() == Nq);
140 
141  RangeJoint ret(*this);
142  ret.maxEffort.conservativeResize(maxEffort.size() + Nv);
143  ret.maxEffort.tail(Nv) = range.maxEffort;
144  ret.maxVel.conservativeResize(maxVel.size() + Nv);
145  ret.maxVel.tail(Nv) = range.maxVel;
146 
147  ret.minConfig.conservativeResize(minConfig.size() + Nq);
148  ret.minConfig.tail(Nq) = range.minConfig;
149  ret.maxConfig.conservativeResize(maxConfig.size() + Nq);
150  ret.maxConfig.tail(Nq) = range.maxConfig;
151 
152  ret.damping.conservativeResize(damping.size() + Nv);
153  ret.damping.tail(Nv) = range.damping;
154  ret.friction.conservativeResize(friction.size() + Nv);
155  ret.friction.tail(Nv) = range.friction;
156 
157  ret.springReference.conservativeResize(springReference.size() + 1);
158  ret.springReference.tail(1) = range.springReference;
159  ret.springStiffness.conservativeResize(springStiffness.size() + 1);
160  ret.springStiffness.tail(1) = range.springStiffness;
161  return ret;
162  }
163 
165  const ptree & el, bool use_limits, const MjcfCompiler & currentCompiler)
166  {
167 
168  if (!use_limits && el.get_optional<std::string>("<xmlattr>.range"))
169  throw std::invalid_argument("Range limit is specified but it was not specify to use it.");
170 
171  // Type
172  auto type_s = el.get_optional<std::string>("<xmlattr>.type");
173  if (type_s)
174  jointType = *type_s;
175 
176  // Axis
177  auto ax = el.get_optional<std::string>("<xmlattr>.axis");
178  if (ax)
179  axis = internal::getVectorFromStream<3>(*ax);
180 
181  // Range
182  auto range_ = el.get_optional<std::string>("<xmlattr>.range");
183  if (range_)
184  {
185  Eigen::Vector2d rangeT = internal::getVectorFromStream<2>(*range_);
186  range.minConfig[0] = currentCompiler.convertAngle(rangeT(0));
187  range.maxConfig[0] = currentCompiler.convertAngle(rangeT(1));
188  }
189  // Effort limit
190  range_ = el.get_optional<std::string>("<xmlattr>.actuatorfrcrange");
191  if (range_)
192  {
193  Eigen::Vector2d rangeT = internal::getVectorFromStream<2>(*range_);
194  range.maxEffort[0] = rangeT(1);
195  }
196 
197  // Spring
198  auto value = el.get_optional<double>("<xmlattr>.springref");
199  if (value)
201 
202  // damping
203  value = el.get_optional<double>("<xmlattr>.damping");
204  if (value)
205  range.damping[0] = *value;
206 
207  value = el.get_optional<double>("<xmlattr>.armature");
208  if (value)
209  range.armature = *value;
210 
211  // friction loss
212  value = el.get_optional<double>("<xmlattr>.frictionloss");
213  if (value)
215 
216  value = el.get_optional<double>("<xmlattr>.ref");
217  if (value)
218  {
219  if (jointType == "slide")
220  posRef = *value;
221  else if (jointType == "hinge")
222  posRef = currentCompiler.convertAngle(*value);
223  else
224  throw std::invalid_argument(
225  "Reference position can only be used with hinge or slide joints.");
226  }
227  }
228 
230  const ptree & el, const MjcfBody & currentBody, const MjcfGraph & currentGraph)
231  {
232  bool use_limit = true;
233  // Name
234  auto name_s = el.get_optional<std::string>("<xmlattr>.name");
235  if (name_s)
236  jointName = *name_s;
237  else
238  jointName =
239  currentBody.bodyName + "Joint_" + std::to_string(currentBody.jointChildren.size());
240 
241  // Check if we need to check for limited argument
242  if (!currentGraph.compilerInfo.autolimits)
243  {
244  use_limit = false;
245  auto use_ls = el.get_optional<std::string>("<xmlattr>.limited");
246  use_limit = *use_ls == "true";
247  }
248 
249  // Placement
250  jointPlacement = currentGraph.convertPosition(el);
251 
252  // ChildClass < Class < Real Joint
253  // childClass
254  if (currentBody.childClass != "")
255  {
256  const MjcfClass & classE = currentGraph.mapOfClasses.at(currentBody.childClass);
257  if (auto joint_p = classE.classElement.get_child_optional("joint"))
258  goThroughElement(*joint_p, use_limit, currentGraph.compilerInfo);
259  }
260  // Class
261  auto cl_s = el.get_optional<std::string>("<xmlattr>.class");
262  if (cl_s)
263  {
264  std::string className = *cl_s;
265  const MjcfClass & classE = currentGraph.mapOfClasses.at(className);
266  if (auto joint_p = classE.classElement.get_child_optional("joint"))
267  goThroughElement(*joint_p, use_limit, currentGraph.compilerInfo);
268  }
269  // Joint
270  goThroughElement(el, use_limit, currentGraph.compilerInfo);
271  }
272 
274  {
275  SE3 placement;
276  placement.setIdentity();
277 
278  // position
279  auto pos = el.get_optional<std::string>("<xmlattr>.pos");
280  if (pos)
281  placement.translation() = internal::getVectorFromStream<3>(*pos);
282 
284  // Quaternion (w, x, y, z)
285  auto rot_s = el.get_optional<std::string>("<xmlattr>.quat");
286  if (rot_s)
287  {
288  Eigen::Vector4d quat = internal::getVectorFromStream<4>(*rot_s);
289 
290  Eigen::Quaterniond quaternion(quat(0), quat(1), quat(2), quat(3));
291  quaternion.normalize();
292  placement.rotation() = quaternion.toRotationMatrix();
293  }
294  // Axis Angle
295  else if ((rot_s = el.get_optional<std::string>("<xmlattr>.axisangle")))
296  {
297  Eigen::Vector4d axis_angle = internal::getVectorFromStream<4>(*rot_s);
298 
299  double angle = axis_angle(3);
300 
301  Eigen::AngleAxisd angleAxis(compilerInfo.convertAngle(angle), axis_angle.head(3));
302  placement.rotation() = angleAxis.toRotationMatrix();
303  }
304  // Euler Angles
305  else if ((rot_s = el.get_optional<std::string>("<xmlattr>.euler")))
306  {
307  Eigen::Vector3d angles = internal::getVectorFromStream<3>(*rot_s);
308 
309  placement.rotation() = compilerInfo.convertEuler(angles);
310  }
311  else if ((rot_s = el.get_optional<std::string>("<xmlattr>.xyaxes")))
312  {
313  Eigen::Matrix<double, 6, 1> xyaxes = internal::getVectorFromStream<6>(*rot_s);
314 
315  Eigen::Vector3d xAxis = xyaxes.head(3);
316  xAxis.normalize();
317  Eigen::Vector3d yAxis = xyaxes.tail(3);
318 
319  // make y axis orthogonal to x axis, normalize
320  double d = xAxis.dot(yAxis);
321  yAxis -= xAxis * d;
322  yAxis.normalize();
323 
324  Eigen::Vector3d zAxis = xAxis.cross(yAxis);
325  zAxis.normalize();
326 
327  Eigen::Matrix3d rotation;
328  rotation.col(0) = xAxis;
329  rotation.col(1) = yAxis;
330  rotation.col(2) = zAxis;
331 
332  placement.rotation() = rotation;
333  }
334  else if ((rot_s = el.get_optional<std::string>("<xmlattr>.zaxis")))
335  {
336  Eigen::Vector3d zaxis = internal::getVectorFromStream<3>(*rot_s);
337  // Compute the rotation matrix that maps z_axis to unit z
338  placement.rotation() =
339  Eigen::Quaterniond::FromTwoVectors(Eigen::Vector3d::UnitZ(), zaxis).toRotationMatrix();
340  }
341  return placement;
342  }
343 
345  {
346  double mass = std::max(el.get<double>("<xmlattr>.mass"), compilerInfo.boundMass);
347  ;
348  if (mass < 0)
349  throw std::invalid_argument("Mass of body is not supposed to be negative");
350 
352  auto com_s = el.get_optional<std::string>("<xmlattr>.pos");
353  if (com_s)
354  com = internal::getVectorFromStream<3>(*com_s);
355  else
356  com = Inertia::Vector3::Zero();
357 
358  const Inertia::Matrix3 R = convertPosition(el).rotation();
359 
360  Inertia::Matrix3 I = Eigen::Matrix3d::Identity();
361 
362  auto inertia_s = el.get_optional<std::string>("<xmlattr>.diaginertia");
363  if (inertia_s)
364  {
365  Eigen::Vector3d inertiaDiag = internal::getVectorFromStream<3>(*inertia_s);
366  I = inertiaDiag.asDiagonal();
367  }
368 
369  else if ((inertia_s = el.get_optional<std::string>("<xmlattr>.fullinertia")))
370  {
371  // M(1,1), M(2,2), M(3,3), M(1,2), M(1,3), M(2,3)
372  std::istringstream inertiaStream = internal::getConfiguredStringStream(*inertia_s);
373  inertiaStream >> I(0, 0);
374  inertiaStream >> I(1, 1);
375  inertiaStream >> I(2, 2);
376  inertiaStream >> I(0, 1);
377  inertiaStream >> I(0, 2);
378  inertiaStream >> I(1, 2);
379 
380  I(1, 0) = I(0, 1);
381  I(2, 0) = I(0, 2);
382  I(2, 1) = I(1, 2);
383  }
384 
385  // Extract the diagonal elements as a vector
386  for (int i = 0; i < 3; i++)
387  I(i, i) = std::max(I(i, i), compilerInfo.boundInertia);
388 
389  return Inertia(mass, com, R * I * R.transpose());
390  }
391 
393  const ptree & el,
394  const boost::optional<std::string> & childClass,
395  const std::string & parentName)
396  {
397  MjcfBody currentBody;
398  auto chcl_s = childClass;
399  // if inertiafromgeom is false and inertia does not exist - throw
400  if (!compilerInfo.inertiafromgeom && !el.get_child_optional("inertial"))
401  throw std::invalid_argument("Cannot get inertia from geom and no inertia was found");
402 
403  bool usegeominertia = false;
405  usegeominertia = true;
406  else if (
407  boost::indeterminate(compilerInfo.inertiafromgeom) && !el.get_child_optional("inertial"))
408  usegeominertia = true;
409 
410  for (const ptree::value_type & v : el)
411  {
412  // Current body node
413  if (v.first == "<xmlattr>")
414  {
415  // Name
416  auto name_s = v.second.get_optional<std::string>("name");
417  if (name_s)
418  currentBody.bodyName = *name_s;
419  else
420  currentBody.bodyName = parentName + "Bis";
421 
422  currentBody.bodyParent = parentName;
423  currentBody.bodyPlacement = convertPosition(el);
424 
425  bodiesList.push_back(currentBody.bodyName);
426 
427  if (auto chcl_st = v.second.get_optional<std::string>("childclass"))
428  {
429  chcl_s = chcl_st;
430  currentBody.childClass = *chcl_s;
431  }
432  else if (childClass)
433  currentBody.childClass = *chcl_s;
434 
435  // Class
436  auto cl_s = v.second.get_optional<std::string>("class");
437  if (cl_s)
438  currentBody.bodyClassName = *cl_s;
439 
440  // Still need to deal with gravcomp and figure out if we need mocap, and user param...
441  }
442  // Inertia
443  if (v.first == "inertial" && !usegeominertia)
444  currentBody.bodyInertia = convertInertiaFromMjcf(v.second);
445 
446  // Geom
447  if (v.first == "geom")
448  {
449  MjcfGeom currentGeom;
450  currentGeom.fill(v.second, currentBody, *this);
451  currentBody.geomChildren.push_back(currentGeom);
452  }
453 
454  // Joint
455  if (v.first == "joint")
456  {
457  MjcfJoint currentJoint;
458  currentJoint.fill(v.second, currentBody, *this);
459  currentBody.jointChildren.push_back(currentJoint);
460  }
461  if (v.first == "freejoint")
462  {
463  MjcfJoint currentJoint;
464  currentJoint.jointType = "free";
465  auto jointName = v.second.get_optional<std::string>("<xmlattr>.name");
466  if (jointName)
467  currentJoint.jointName = *jointName;
468  else
469  currentJoint.jointName = currentBody.bodyName + "_free";
470 
471  currentBody.jointChildren.push_back(currentJoint);
472  }
473  if (v.first == "site")
474  {
475  MjcfSite currentSite;
476  currentSite.fill(v.second, currentBody, *this);
477  currentBody.siteChildren.push_back(currentSite);
478  }
479  if (v.first == "body")
480  {
481  parseJointAndBody(v.second, chcl_s, currentBody.bodyName);
482  }
483  }
484  // Add all geom inertias if needed
485  if (usegeominertia)
486  {
487  Inertia inert_temp(Inertia::Zero());
488  for (const auto & geom : currentBody.geomChildren)
489  {
490  if (geom.geomKind != MjcfGeom::VISUAL)
491  inert_temp += geom.geomPlacement.act(geom.geomInertia);
492  }
493  currentBody.bodyInertia = inert_temp;
494  }
495  mapOfBodies.insert(std::make_pair(currentBody.bodyName, currentBody));
496  }
497 
499  {
500  namespace fs = boost::filesystem;
501  MjcfTexture text;
502  auto file = el.get_optional<std::string>("<xmlattr>.file");
503  if (!file)
504  throw std::invalid_argument("Only textures with files are supported");
505 
506  fs::path filePath(*file);
507  std::string name = getName(el, filePath);
508 
509  text.filePath =
511 
512  auto str_v = el.get_optional<std::string>("<xmlattr>.type");
513  if (str_v)
514  text.textType = *str_v;
515 
516  if ((str_v = el.get_optional<std::string>("<xmlattr>.gridsize")))
517  text.gridsize = internal::getVectorFromStream<2>(*str_v);
518 
519  mapOfTextures.insert(std::make_pair(name, text));
520  }
521 
523  {
524  std::string name;
526  auto n = el.get_optional<std::string>("<xmlattr>.name");
527  if (n)
528  name = *n;
529  else
530  throw std::invalid_argument("Material was given without a name");
531 
532  // Class < Attributes
533  auto cl_s = el.get_optional<std::string>("<xmlattr>.class");
534  if (cl_s)
535  {
536  std::string className = *cl_s;
537  const MjcfClass & classE = mapOfClasses.at(className);
538  if (auto mat_p = classE.classElement.get_child_optional("material"))
539  mat.goThroughElement(*mat_p);
540  }
541 
542  mat.goThroughElement(el);
543 
544  mapOfMaterials.insert(std::make_pair(name, mat));
545  }
546 
547  void MjcfGraph::parseMesh(const ptree & el)
548  {
549  namespace fs = boost::filesystem;
550 
551  MjcfMesh mesh;
552  auto file = el.get_optional<std::string>("<xmlattr>.file");
553  if (!file)
554  throw std::invalid_argument("Only meshes with files are supported");
555 
556  fs::path filePath(*file);
557  std::string name = getName(el, filePath);
558 
559  mesh.filePath =
561 
562  auto scale = el.get_optional<std::string>("<xmlattr>.scale");
563  if (scale)
564  mesh.scale = internal::getVectorFromStream<3>(*scale);
565 
566  mapOfMeshes.insert(std::make_pair(name, mesh));
567  }
568 
569  void MjcfGraph::parseAsset(const ptree & el)
570  {
571  for (const ptree::value_type & v : el)
572  {
573  if (v.first == "mesh")
574  parseMesh(v.second);
575 
576  if (v.first == "material")
577  parseMaterial(v.second);
578 
579  if (v.first == "texture")
580  parseTexture(v.second);
581 
582  if (v.first == "hfield")
583  throw std::invalid_argument("hfields are not supported yet");
584  }
585  }
586 
588  {
589  boost::optional<std::string> nameClass;
590  for (ptree::value_type & v : el)
591  {
592  if (v.first == "<xmlattr>")
593  {
594  nameClass = v.second.get_optional<std::string>("class");
595  if (nameClass)
596  {
597  MjcfClass classDefault;
598  classDefault.className = *nameClass;
600  classDefault.classElement = el;
601  mapOfClasses.insert(std::make_pair(*nameClass, classDefault));
602  }
603  else
604  throw std::invalid_argument("Class does not have a name. Cannot parse model.");
605  }
606  if (v.first == "default")
607  parseDefault(v.second, el);
608  }
609  }
610 
612  {
613  // get autolimits
614  auto auto_s = el.get_optional<std::string>("<xmlattr>.autolimits");
615  if (auto_s)
616  if (*auto_s == "true")
617  compilerInfo.autolimits = true;
618 
619  // strip path
620  auto strip_s = el.get_optional<std::string>("<xmlattr>.strippath");
621  if (strip_s)
622  if (*strip_s == "true")
623  compilerInfo.strippath = true;
624 
625  // get dir to mesh and texture
626  auto dir = el.get_optional<std::string>("<xmlattr>.assetdir");
627  if (dir)
628  {
629  compilerInfo.meshdir = *dir;
630  compilerInfo.texturedir = *dir;
631  }
632 
633  if ((dir = el.get_optional<std::string>("<xmlattr>.meshdir")))
634  compilerInfo.meshdir = *dir;
635 
636  if ((dir = el.get_optional<std::string>("<xmlattr>.texturedir")))
637  compilerInfo.texturedir = *dir;
638 
639  auto value_v = el.get_optional<double>("<xmlattr>.boundmass");
640  if (value_v)
641  compilerInfo.boundMass = *value_v;
642 
643  if ((value_v = el.get_optional<double>("<xmlattr>.boundinertia")))
644  compilerInfo.boundInertia = *value_v;
645 
646  auto in_g = el.get_optional<std::string>("<xmlattr>.inertiafromgeom");
647  if (in_g)
648  {
649  if (*in_g == "true")
651  else if (*in_g == "false")
653  }
654 
655  // angle radian or degree
656  auto angle_s = el.get_optional<std::string>("<xmlattr>.angle");
657  if (angle_s)
658  if (*angle_s == "radian")
660 
661  auto eulerS = el.get_optional<std::string>("<xmlattr>.eulerseq");
662  if (eulerS)
663  {
664  std::string eulerseq = *eulerS;
665  if (eulerseq.find_first_not_of("xyzXYZ") != std::string::npos || eulerseq.size() != 3)
666  throw std::invalid_argument(
667  "Model tried to use euler angles but euler sequence is wrong");
668  else
669  {
670  // get index combination
671  for (std::size_t i = 0; i < eulerseq.size(); i++)
672  {
673  auto ci = static_cast<Eigen::Index>(i);
674  switch (eulerseq[i])
675  {
676  case 'x':
677  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitX();
678  break;
679  case 'X':
680  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitX();
681  break;
682  case 'y':
683  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitY();
684  break;
685  case 'Y':
686  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitY();
687  break;
688  case 'z':
689  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitZ();
690  break;
691  case 'Z':
692  compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitZ();
693  break;
694  default:
695  throw std::invalid_argument("Euler Axis does not exist");
696  break;
697  }
698  }
699  }
700  }
701  }
702 
704  {
705  for (const ptree::value_type & v : el)
706  {
707  if (v.first == "key")
708  {
709  auto nameKey = v.second.get_optional<std::string>("<xmlattr>.name");
710  if (nameKey)
711  {
712  auto configVectorS = v.second.get_optional<std::string>("<xmlattr>.qpos");
713  if (configVectorS)
714  {
715  Eigen::VectorXd configVector =
717  mapOfConfigs.insert(std::make_pair(*nameKey, configVector));
718  }
719  }
720  }
721  }
722  }
723 
725  {
727  if (pt.get_child_optional("mujoco"))
728  el = pt.get_child("mujoco");
729  else
730  throw std::invalid_argument("This is not a standard mujoco model. Cannot parse it.");
731 
732  for (const ptree::value_type & v : el)
733  {
734  // get model name
735  if (v.first == "<xmlattr>")
736  {
737  auto n_s = v.second.get_optional<std::string>("model");
738  if (n_s)
739  modelName = *n_s;
740  else
741  throw std::invalid_argument("Model is missing a name. Cannot parse it");
742  }
743 
744  if (v.first == "compiler")
745  parseCompiler(el.get_child("compiler"));
746 
747  if (v.first == "default")
748  parseDefault(el.get_child("default"), el);
749 
750  if (v.first == "asset")
751  parseAsset(el.get_child("asset"));
752 
753  if (v.first == "keyframe")
754  parseKeyFrame(el.get_child("keyframe"));
755 
756  if (v.first == "worldbody")
757  {
758  boost::optional<std::string> childClass;
759  parseJointAndBody(el.get_child("worldbody").get_child("body"), childClass);
760  }
761  }
762  }
763 
764  void MjcfGraph::parseGraphFromXML(const std::string & xmlStr)
765  {
766  boost::property_tree::read_xml(xmlStr, pt);
767  parseGraph();
768  }
769 
770  template<typename TypeX, typename TypeY, typename TypeZ, typename TypeUnaligned>
771  JointModel MjcfGraph::createJoint(const Eigen::Vector3d & axis)
772  {
773  if (axis.isApprox(Eigen::Vector3d::UnitX()))
774  return TypeX();
775  else if (axis.isApprox(Eigen::Vector3d::UnitY()))
776  return TypeY();
777  else if (axis.isApprox(Eigen::Vector3d::UnitZ()))
778  return TypeZ();
779  else
780  return TypeUnaligned(axis.normalized());
781  }
782 
784  const MjcfJoint & joint, const MjcfBody & currentBody, SE3 & bodyInJoint)
785  {
786  const FrameIndex parentFrameId = urdfVisitor.getBodyId(currentBody.bodyParent);
787  // get body pose in body parent
788  const SE3 bodyPose = currentBody.bodyPlacement;
789  Inertia inert = currentBody.bodyInertia;
790  SE3 jointInParent = bodyPose * joint.jointPlacement;
791  bodyInJoint = joint.jointPlacement.inverse();
792  UrdfVisitor::JointType jType;
793 
794  RangeJoint range;
795  if (joint.jointType == "free")
796  {
797  urdfVisitor << "Free Joint " << '\n';
798  range = joint.range.setDimension<7, 6>();
799  jType = UrdfVisitor::FLOATING;
800  }
801  else if (joint.jointType == "slide")
802  {
803  urdfVisitor << "joint prismatic with axis " << joint.axis << '\n';
804  range = joint.range;
805  jType = UrdfVisitor::PRISMATIC;
806  }
807  else if (joint.jointType == "ball")
808  {
809  urdfVisitor << "Sphere Joint " << '\n';
810  range = joint.range.setDimension<4, 3>();
811  jType = UrdfVisitor::SPHERICAL;
812  }
813  else if (joint.jointType == "hinge")
814  {
815  urdfVisitor << "joint revolute with axis " << joint.axis << '\n';
816  range = joint.range;
817  jType = UrdfVisitor::REVOLUTE;
818  }
819  else
820  throw std::invalid_argument("Unknown joint type");
821 
822  urdfVisitor.addJointAndBody(
823  jType, joint.axis, parentFrameId, jointInParent, joint.jointName, inert, bodyInJoint,
824  currentBody.bodyName, range.maxEffort, range.maxVel, range.minConfig, range.maxConfig,
825  range.friction, range.damping);
826 
827  // Add armature info
828  JointIndex j_id = urdfVisitor.getJointId(joint.jointName);
829  urdfVisitor.model.armature[static_cast<Eigen::Index>(j_id) - 1] = range.armature;
830  }
831 
832  void MjcfGraph::fillModel(const std::string & nameOfBody)
833  {
834  typedef UrdfVisitor::SE3 SE3;
835 
836  MjcfBody currentBody = mapOfBodies.at(nameOfBody);
837  // get parent body frame
838  const FrameIndex parentFrameId = urdfVisitor.getBodyId(currentBody.bodyParent);
839  const Frame & frame = urdfVisitor.model.frames[parentFrameId];
840  // get body pose in body parent
841  const SE3 bodyPose = currentBody.bodyPlacement;
842  Inertia inert = currentBody.bodyInertia;
843 
844  // Fixed Joint
845  if (currentBody.jointChildren.size() == 0)
846  {
847  std::string jointName = nameOfBody + "_fixed";
848  urdfVisitor << jointName << " being parsed." << '\n';
849 
850  urdfVisitor.addFixedJointAndBody(parentFrameId, bodyPose, jointName, inert, nameOfBody);
851  return;
852  }
853 
854  bool composite = false;
855  SE3 jointPlacement, firstJointPlacement, prevJointPlacement = SE3::Identity();
856 
857  RangeJoint rangeCompo;
858  JointModelComposite jointM;
859  std::string jointName;
860 
861  if (currentBody.jointChildren.size() > 1)
862  {
863  composite = true;
864 
865  MjcfJoint firstOne = currentBody.jointChildren.at(0);
866  jointName = "Composite_" + firstOne.jointName;
867  }
868 
869  fillReferenceConfig(currentBody);
870 
871  bool isFirst = true;
872  SE3 bodyInJoint;
873 
874  if (!composite)
875  {
876  addSoloJoint(currentBody.jointChildren.at(0), currentBody, bodyInJoint);
877  }
878  else
879  {
880  for (const auto & joint : currentBody.jointChildren)
881  {
882  if (joint.jointType == "free")
883  throw std::invalid_argument("Joint Composite trying to be created with a freeFlyer");
884 
885  SE3 jointInParent = bodyPose * joint.jointPlacement;
886  bodyInJoint = joint.jointPlacement.inverse();
887  if (isFirst)
888  {
889  firstJointPlacement = jointInParent;
890  jointPlacement = SE3::Identity();
891  isFirst = false;
892  }
893  else
894  jointPlacement = prevJointPlacement.inverse() * jointInParent;
895  if (joint.jointType == "slide")
896  {
897  jointM.addJoint(
898  createJoint<JointModelPX, JointModelPY, JointModelPZ, JointModelPrismaticUnaligned>(
899  joint.axis),
900  jointPlacement);
901 
902  rangeCompo = rangeCompo.concatenate<1, 1>(joint.range);
903  }
904  else if (joint.jointType == "ball")
905  {
906  jointM.addJoint(JointModelSpherical(), jointPlacement);
907  rangeCompo = rangeCompo.concatenate<4, 3>(joint.range.setDimension<4, 3>());
908  }
909  else if (joint.jointType == "hinge")
910  {
911  jointM.addJoint(
912  createJoint<JointModelRX, JointModelRY, JointModelRZ, JointModelRevoluteUnaligned>(
913  joint.axis),
914  jointPlacement);
915  rangeCompo = rangeCompo.concatenate<1, 1>(joint.range);
916  }
917  else
918  throw std::invalid_argument("Unknown joint type trying to be parsed.");
919 
920  prevJointPlacement = jointInParent;
921  }
923 
924  joint_id = urdfVisitor.model.addJoint(
925  frame.parentJoint, jointM, frame.placement * firstJointPlacement, jointName,
926  rangeCompo.maxEffort, rangeCompo.maxVel, rangeCompo.minConfig, rangeCompo.maxConfig,
927  rangeCompo.friction, rangeCompo.damping);
928  FrameIndex jointFrameId = urdfVisitor.model.addJointFrame(joint_id, (int)parentFrameId);
929  urdfVisitor.appendBodyToJoint(jointFrameId, inert, bodyInJoint, nameOfBody);
930 
931  urdfVisitor.model.armature[static_cast<Eigen::Index>(joint_id) - 1] = rangeCompo.armature;
932  }
933 
934  FrameIndex previousFrameId = urdfVisitor.model.frames.size();
935  for (const auto & site : currentBody.siteChildren)
936  {
937  SE3 placement = bodyInJoint * site.sitePlacement;
938  previousFrameId = urdfVisitor.model.addFrame(
939  Frame(site.siteName, frame.parentJoint, previousFrameId, placement, OP_FRAME));
940  }
941  }
942 
943  void MjcfGraph::fillReferenceConfig(const MjcfBody & currentBody)
944  {
945  for (const auto & joint : currentBody.jointChildren)
946  {
947  if (joint.jointType == "free")
948  {
949  referenceConfig.conservativeResize(referenceConfig.size() + 7);
950  referenceConfig.tail(7) << Eigen::Matrix<double, 7, 1>::Zero();
951  }
952  else if (joint.jointType == "ball")
953  {
954  referenceConfig.conservativeResize(referenceConfig.size() + 4);
955  referenceConfig.tail(4) << Eigen::Vector4d::Zero();
956  }
957  else if (joint.jointType == "slide" || joint.jointType == "hinge")
958  {
959  referenceConfig.conservativeResize(referenceConfig.size() + 1);
960  referenceConfig.tail(1) << joint.posRef;
961  }
962  }
963  }
964 
965  void MjcfGraph::addKeyFrame(const Eigen::VectorXd & keyframe, const std::string & keyName)
966  {
967  // Check config vectors and add them if size is right
968  const int model_nq = urdfVisitor.model.nq;
969  if (keyframe.size() == model_nq)
970  {
971  Eigen::VectorXd qpos(model_nq);
972  for (std::size_t i = 1; i < urdfVisitor.model.joints.size(); i++)
973  {
974  const auto & joint = urdfVisitor.model.joints[i];
975  int idx_q = joint.idx_q();
976  int nq = joint.nq();
977 
978  Eigen::VectorXd qpos_j = keyframe.segment(idx_q, nq);
979  Eigen::VectorXd q_ref = referenceConfig.segment(idx_q, nq);
980  if (joint.shortname() == "JointModelFreeFlyer")
981  {
982  Eigen::Vector4d new_quat(qpos_j(4), qpos_j(5), qpos_j(6), qpos_j(3));
983  qpos_j.tail(4) = new_quat;
984  }
985  else if (joint.shortname() == "JointModelSpherical")
986  {
987  Eigen::Vector4d new_quat(qpos_j(1), qpos_j(2), qpos_j(3), qpos_j(0));
988  qpos_j = new_quat;
989  }
990  else if (joint.shortname() == "JointModelComposite")
991  {
992  for (const auto & joint_ : boost::get<JointModelComposite>(joint.toVariant()).joints)
993  {
994  int idx_q_ = joint_.idx_q() - idx_q;
995  int nq_ = joint_.nq();
996  if (joint_.shortname() == "JointModelSpherical")
997  {
998  Eigen::Vector4d new_quat(
999  qpos_j(idx_q_ + 1), qpos_j(idx_q_ + 2), qpos_j(idx_q_ + 3), qpos_j(idx_q_));
1000  qpos_j.segment(idx_q_, nq_) = new_quat;
1001  }
1002  else
1003  qpos_j.segment(idx_q_, nq_) -= q_ref.segment(idx_q_, nq_);
1004  }
1005  }
1006  else
1007  qpos_j -= q_ref;
1008 
1009  qpos.segment(idx_q, nq) = qpos_j;
1010  }
1011 
1012  urdfVisitor.model.referenceConfigurations.insert(std::make_pair(keyName, qpos));
1013  }
1014  else
1015  throw std::invalid_argument("Keyframe size does not match model size");
1016  }
1017 
1019  {
1020  urdfVisitor.setName(modelName);
1021 
1022  // get name and inertia of first root link
1023  std::string rootLinkName = bodiesList.at(0);
1024  MjcfBody rootBody = mapOfBodies.find(rootLinkName)->second;
1025  urdfVisitor.addRootJoint(rootBody.bodyInertia, rootLinkName);
1026  fillReferenceConfig(rootBody);
1027  for (const auto & entry : bodiesList)
1028  {
1029  if (entry != rootLinkName)
1030  fillModel(entry);
1031  }
1032 
1033  for (const auto & entry : mapOfConfigs)
1034  {
1035  addKeyFrame(entry.second, entry.first);
1036  }
1037  }
1038  } // namespace details
1039  } // namespace mjcf
1040 } // namespace pinocchio
meshcat-viewer.mesh
mesh
Definition: meshcat-viewer.py:53
ax
ax
pinocchio::InertiaTpl< context::Scalar, context::Options >
pinocchio::mjcf::details::MjcfCompiler::angle_converter
double angle_converter
Definition: mjcf-graph.hpp:52
pinocchio::FrameIndex
Index FrameIndex
Definition: multibody/fwd.hpp:28
pinocchio::mjcf::details::MjcfJoint::goThroughElement
void goThroughElement(const ptree &el, bool use_limits, const MjcfCompiler &currentCompiler)
Go through a joint node (default class or not) and parse info into the structure.
Definition: mjcf-graph.cpp:164
pinocchio::mjcf::details::MjcfCompiler::mapEulerAngles
Eigen::Matrix3d mapEulerAngles
Definition: mjcf-graph.hpp:54
pinocchio::mjcf::details::MjcfClass
Structure to stock all default classes information.
Definition: mjcf-graph.hpp:76
pinocchio::mjcf::details::RangeJoint::setDimension
RangeJoint setDimension() const
Set dimension to the limits to match the joint nq and nv.
Definition: mjcf-graph.cpp:116
pinocchio::mjcf::details::MjcfGraph::mapOfTextures
TextureMap_t mapOfTextures
Definition: mjcf-graph.hpp:352
pinocchio::mjcf::details::MjcfCompiler
Informations that are stocked in the XML tag compile.
Definition: mjcf-graph.hpp:38
pinocchio::mjcf::details::MjcfGraph::ptree
boost::property_tree::ptree ptree
Definition: mjcf-graph.hpp:332
pinocchio::SE3Tpl::inverse
SE3Tpl inverse() const
aXb = bXa.inverse()
Definition: spatial/se3-tpl.hpp:149
pinocchio::mjcf::details::MjcfCompiler::boundInertia
double boundInertia
Definition: mjcf-graph.hpp:59
pinocchio::mjcf::details::MjcfTexture::textType
std::string textType
Definition: mjcf-graph.hpp:217
pinocchio::idx_q
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
pinocchio::mjcf::details::MjcfJoint::fill
void fill(const ptree &el, const MjcfBody &currentBody, const MjcfGraph &currentGraph)
Definition: mjcf-graph.cpp:229
pinocchio::mjcf::details::MjcfBody::bodyInertia
Inertia bodyInertia
Definition: mjcf-graph.hpp:104
pinocchio::mjcf::details::MjcfGraph::referenceConfig
Eigen::VectorXd referenceConfig
Definition: mjcf-graph.hpp:357
pinocchio::mjcf::details::MjcfMesh
All informations related to a mesh are stored here.
Definition: mjcf-graph.hpp:205
lambdas.parent
parent
Definition: lambdas.py:20
pinocchio::mjcf::details::MjcfCompiler::convertAngle
double convertAngle(const double &angle_) const
Convert the angle in radian if model was declared to use degree.
Definition: mjcf-graph.cpp:98
quat
quat
pinocchio::mjcf::details::MjcfGraph::mapOfClasses
ClassMap_t mapOfClasses
Definition: mjcf-graph.hpp:344
pinocchio::mjcf::details::RangeJoint::maxConfig
Eigen::VectorXd maxConfig
Definition: mjcf-graph.hpp:122
pinocchio::mjcf::details::RangeJoint
All joint limits.
Definition: mjcf-graph.hpp:115
pinocchio::mjcf::details::UrdfVisitor
pinocchio::urdf::details::UrdfVisitor< double, 0, ::pinocchio::JointCollectionDefaultTpl > UrdfVisitor
Definition: mjcf-graph.cpp:16
pinocchio::mjcf::details::RangeJoint::maxVel
Eigen::VectorXd maxVel
Definition: mjcf-graph.hpp:120
pinocchio::Inertia
InertiaTpl< context::Scalar, context::Options > Inertia
Definition: spatial/fwd.hpp:65
pinocchio::SE3Tpl< context::Scalar, context::Options >
pinocchio::mjcf::details::MjcfGraph::parseRootTree
void parseRootTree()
Fill the pinocchio model with all the infos from the graph.
Definition: mjcf-graph.cpp:1018
pinocchio::nq
int nq(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointNqVisitor to get the dimension of the joint configuration space.
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:20
pinocchio::name
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.
mjcf-graph.hpp
simulation-closed-kinematic-chains.rotation
rotation
Definition: simulation-closed-kinematic-chains.py:24
pinocchio::mjcf::details::MjcfTexture::gridsize
Eigen::Vector2d gridsize
Definition: mjcf-graph.hpp:221
pinocchio::mjcf::details::MjcfGeom
Definition: mjcf-graph.hpp:246
pinocchio::JointModelSpherical
JointModelSphericalTpl< context::Scalar > JointModelSpherical
Definition: multibody/joint/fwd.hpp:73
pinocchio::mjcf::details::MjcfCompiler::inertiafromgeom
boost::logic::tribool inertiafromgeom
Definition: mjcf-graph.hpp:62
pinocchio::mjcf::details::MjcfCompiler::convertEuler
Eigen::Matrix3d convertEuler(const Eigen::Vector3d &angles) const
Convert the euler angles according to the convention declared in the compile tag.
Definition: mjcf-graph.cpp:103
pinocchio::mjcf::details::MjcfJoint
All joint information parsed from the mjcf model.
Definition: mjcf-graph.hpp:173
pinocchio::mjcf::details::RangeJoint::minConfig
Eigen::VectorXd minConfig
Definition: mjcf-graph.hpp:124
R
R
pinocchio::mjcf::details::RangeJoint::concatenate
RangeJoint concatenate(const RangeJoint &range) const
Concatenate 2 rangeJoint.
Definition: mjcf-graph.cpp:136
pinocchio::mjcf::details::MjcfMaterial
All informations related to material are stored here.
Definition: mjcf-graph.hpp:225
pinocchio::mjcf::details::MjcfGraph::parseJointAndBody
void parseJointAndBody(const ptree &el, const boost::optional< std::string > &childClass, const std::string &parentName="")
Go through the main body of the mjcf file "worldbody" to get all the info ready to create the model.
Definition: mjcf-graph.cpp:392
pinocchio::mjcf::details::MjcfClass::className
std::string className
Definition: mjcf-graph.hpp:82
pinocchio::mjcf::details::MjcfGraph::modelName
std::string modelName
Definition: mjcf-graph.hpp:366
pinocchio::mjcf::details::RangeJoint::friction
Eigen::VectorXd friction
Definition: mjcf-graph.hpp:132
pinocchio::mjcf::details::MjcfCompiler::boundMass
double boundMass
Definition: mjcf-graph.hpp:57
pinocchio::mjcf::details::MjcfJoint::axis
Eigen::Vector3d axis
Definition: mjcf-graph.hpp:184
pinocchio::mjcf::details::MjcfJoint::jointType
std::string jointType
Definition: mjcf-graph.hpp:189
pinocchio::JointModelCompositeTpl::addJoint
JointModelDerived & addJoint(const JointModelBase< JointModel > &jmodel, const SE3 &placement=SE3::Identity())
Add a joint to the vector of joints.
Definition: joint-composite.hpp:279
pinocchio::mjcf::details::MjcfGraph::convertInertiaFromMjcf
Inertia convertInertiaFromMjcf(const ptree &el) const
Convert Inertia of an mjcf element into Inertia model of pinocchio.
Definition: mjcf-graph.cpp:344
pinocchio::mjcf::details::copyPtree
static void copyPtree(const ptree &src, ptree &dst)
Copy the value of ptree src into dst.
Definition: mjcf-graph.cpp:24
pinocchio::FrameTpl
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition: multibody/frame.hpp:55
pinocchio::Index
PINOCCHIO_COMPILER_DIAGNOSTIC_POP typedef std::size_t Index
Definition: multibody/fwd.hpp:22
pinocchio::mjcf::details::MjcfGraph::parseGraphFromXML
void parseGraphFromXML(const std::string &xmlStr)
parse the mjcf file into a graph
Definition: mjcf-graph.cpp:764
pinocchio::mjcf::details::MjcfGraph::mapOfConfigs
ConfigMap_t mapOfConfigs
Definition: mjcf-graph.hpp:354
pinocchio::InertiaTpl< context::Scalar, context::Options >::Zero
static InertiaTpl Zero()
Definition: spatial/inertia.hpp:332
pinocchio::mjcf::details::MjcfClass::classElement
ptree classElement
Definition: mjcf-graph.hpp:84
pinocchio::mjcf::details::MjcfBody::geomChildren
std::vector< MjcfGeom > geomChildren
Definition: mjcf-graph.hpp:109
pinocchio::mjcf::details::MjcfGraph::parseTexture
void parseTexture(const ptree &el)
Parse all the info from a texture node.
Definition: mjcf-graph.cpp:498
pinocchio::mjcf::details::RangeJoint::springReference
Eigen::VectorXd springReference
Definition: mjcf-graph.hpp:129
details
pinocchio::mjcf::details::MjcfJoint::ptree
boost::property_tree::ptree ptree
Definition: mjcf-graph.hpp:176
pinocchio::placement
const MotionDense< Motion2 > const SE3Tpl< SE3Scalar, SE3Options > & placement
Definition: spatial/classic-acceleration.hpp:122
pinocchio::mjcf::details::RangeJoint::damping
Eigen::VectorXd damping
Definition: mjcf-graph.hpp:134
pinocchio::mjcf::details::MjcfTexture::filePath
std::string filePath
Definition: mjcf-graph.hpp:219
filename
filename
pinocchio::mjcf::details::MjcfGraph::parseCompiler
void parseCompiler(const ptree &el)
Parse all the info from the compile node into compilerInfo.
Definition: mjcf-graph.cpp:611
pinocchio::JointModelTpl< context::Scalar >
mat
mat
pinocchio::SE3Tpl::rotation
ConstAngularRef rotation() const
Definition: se3-base.hpp:48
pinocchio::mjcf::details::MjcfGraph::fillModel
void fillModel(const std::string &nameOfBody)
Use all the infos that were parsed from the xml file to add a body and joint to the model.
Definition: mjcf-graph.cpp:832
value
float value
pinocchio::mjcf::details::ELEMENTS
static const std::array< std::string, 3 > ELEMENTS
Definition: mjcf-graph.cpp:19
pinocchio::mjcf::details::MjcfGraph::bodiesList
VectorOfStrings bodiesList
Definition: mjcf-graph.hpp:363
pinocchio::mjcf::details::RangeJoint::springStiffness
Eigen::VectorXd springStiffness
Definition: mjcf-graph.hpp:127
pinocchio::mjcf::details::MjcfBody::siteChildren
std::vector< MjcfSite > siteChildren
Definition: mjcf-graph.hpp:111
pinocchio::mjcf::details::MjcfGraph::addKeyFrame
void addKeyFrame(const Eigen::VectorXd &keyframe, const std::string &keyName)
Add a keyframe to the model (ie reference configuration)
Definition: mjcf-graph.cpp:965
pos
pos
pinocchio::mjcf::details::MjcfGraph::parseMesh
void parseMesh(const ptree &el)
Parse all the info from a mesh node.
Definition: mjcf-graph.cpp:547
pinocchio::mjcf::details::MjcfGraph::mapOfMeshes
MeshMap_t mapOfMeshes
Definition: mjcf-graph.hpp:350
pinocchio::mjcf::details::MjcfJoint::jointPlacement
SE3 jointPlacement
Definition: mjcf-graph.hpp:181
pinocchio::mjcf::details::MjcfGraph::mapOfBodies
BodyMap_t mapOfBodies
Definition: mjcf-graph.hpp:346
pinocchio::context::Vector3
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Definition: context/generic.hpp:53
pinocchio::mjcf::details::MjcfGraph::parseMaterial
void parseMaterial(const ptree &el)
Parse all the info from a material node.
Definition: mjcf-graph.cpp:522
axis
axis
pinocchio::mjcf::details::RangeJoint::frictionLoss
double frictionLoss
Definition: mjcf-graph.hpp:139
pinocchio::mjcf::details::ptree
boost::property_tree::ptree ptree
Definition: mjcf-graph.cpp:13
contact-cholesky.frame
frame
Definition: contact-cholesky.py:27
pinocchio::mjcf::details::MjcfGraph::parseKeyFrame
void parseKeyFrame(const ptree &el)
Parse all the info from the meta tag keyframe.
Definition: mjcf-graph.cpp:703
meshcat-viewer-solo.q_ref
q_ref
Definition: meshcat-viewer-solo.py:13
pinocchio::Frame
FrameTpl< context::Scalar, context::Options > Frame
Definition: multibody/fwd.hpp:31
anymal-simulation.mass
mass
Definition: anymal-simulation.py:78
pinocchio::mjcf::details::MjcfGeom::fill
void fill(const ptree &el, const MjcfBody &currentBody, const MjcfGraph &currentGraph)
Fill Geometry element with info from ptree nodes.
Definition: mjcf-graph-geom.cpp:403
value_type
Scalar value_type
Definition: eigen_plugin.hpp:2
pinocchio::mjcf::details::MjcfJoint::jointName
std::string jointName
Definition: mjcf-graph.hpp:179
pinocchio::mjcf::details::MjcfBody::bodyClassName
std::string bodyClassName
Definition: mjcf-graph.hpp:96
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1118
pinocchio::mjcf::details::MjcfGraph::mapOfMaterials
MaterialMap_t mapOfMaterials
Definition: mjcf-graph.hpp:348
pinocchio::mjcf::details::MjcfCompiler::meshdir
std::string meshdir
Definition: mjcf-graph.hpp:47
pinocchio::mjcf::details::MjcfCompiler::texturedir
std::string texturedir
Definition: mjcf-graph.hpp:49
pinocchio::JointModelCompositeTpl
Definition: multibody/joint/fwd.hpp:141
pinocchio::mjcf::details::MjcfGraph::fillReferenceConfig
void fillReferenceConfig(const MjcfBody &currentBody)
Fill reference configuration for a body and all it's associated dof.
Definition: mjcf-graph.cpp:943
pinocchio::OP_FRAME
@ OP_FRAME
operational frame: user-defined frames that are defined at runtime
Definition: multibody/frame.hpp:33
pinocchio::mjcf::details::MjcfGraph::urdfVisitor
UrdfVisitor & urdfVisitor
Definition: mjcf-graph.hpp:373
pinocchio::mjcf::details::MjcfGraph::parseGraph
void parseGraph()
parse the mjcf file into a graph
Definition: mjcf-graph.cpp:724
pinocchio::mjcf::details::MjcfGraph::compilerInfo
MjcfCompiler compilerInfo
Definition: mjcf-graph.hpp:342
pinocchio::mjcf::details::MjcfGraph::pt
ptree pt
Definition: mjcf-graph.hpp:360
pinocchio::mjcf::details::MjcfCompiler::autolimits
bool autolimits
Definition: mjcf-graph.hpp:42
pinocchio::mjcf::details::MjcfCompiler::strippath
bool strippath
Definition: mjcf-graph.hpp:45
pinocchio::mjcf::details::MjcfGraph::parseAsset
void parseAsset(const ptree &el)
Parse all the info from the meta tag asset (mesh, material, texture)
Definition: mjcf-graph.cpp:569
pinocchio::mjcf::details::MjcfGraph::convertPosition
SE3 convertPosition(const ptree &el) const
Convert pose of an mjcf element into SE3.
Definition: mjcf-graph.cpp:273
pinocchio::SE3Tpl< context::Scalar, context::Options >::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
pinocchio::mjcf::details::MjcfGraph::addSoloJoint
void addSoloJoint(const MjcfJoint &jointInfo, const MjcfBody &currentBody, SE3 &bodyInJoint)
Add a joint to the model. only needed when a body has a solo joint child.
Definition: mjcf-graph.cpp:783
pinocchio::mjcf::details::updatePath
static boost::filesystem::path updatePath(bool strippath, const std::string &dir, const std::string &modelPath, const boost::filesystem::path &filePath)
Definition: mjcf-graph.cpp:70
pinocchio::mjcf::details::MjcfBody::bodyName
std::string bodyName
Definition: mjcf-graph.hpp:92
pinocchio::mjcf::details::updateClassElement
static void updateClassElement(ptree &current, const ptree &parent)
Update class Element in order to have all info of parent classes.
Definition: mjcf-graph.cpp:33
pinocchio::mjcf::details::MjcfJoint::posRef
double posRef
Definition: mjcf-graph.hpp:191
pinocchio::mjcf::details::MjcfBody::bodyParent
std::string bodyParent
Definition: mjcf-graph.hpp:94
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::mjcf::details::MjcfGraph
The graph which contains all information taken from the mjcf file.
Definition: mjcf-graph.hpp:329
pinocchio::mjcf::details::MjcfBody::jointChildren
std::vector< MjcfJoint > jointChildren
Definition: mjcf-graph.hpp:107
pinocchio::mjcf::details::MjcfBody
All Bodies informations extracted from mjcf model.
Definition: mjcf-graph.hpp:88
pinocchio::mjcf::details::internal::getConfiguredStringStream
std::istringstream getConfiguredStringStream(const std::string &str)
Definition: mjcf-graph.hpp:483
pinocchio::mjcf::details::MjcfSite
Definition: mjcf-graph.hpp:316
pinocchio::mjcf::details::MjcfGraph::parseDefault
void parseDefault(ptree &el, const ptree &parent)
Go through the default part of the file and get all the class name. Fill the mapOfDefault for later u...
Definition: mjcf-graph.cpp:587
pinocchio::mjcf::details::MjcfBody::bodyPlacement
SE3 bodyPlacement
Definition: mjcf-graph.hpp:102
pinocchio::python::context::SE3
SE3Tpl< Scalar, Options > SE3
Definition: bindings/python/context/generic.hpp:53
pinocchio::SE3
SE3Tpl< context::Scalar, context::Options > SE3
Definition: spatial/fwd.hpp:60
pinocchio::mjcf::details::RangeJoint::armature
double armature
Definition: mjcf-graph.hpp:137
append-urdf-model-with-another-model.joint_id
joint_id
Definition: append-urdf-model-with-another-model.py:34
casadi-quadrotor-ocp.path
path
Definition: casadi-quadrotor-ocp.py:10
pinocchio::mjcf::details::MjcfGraph::createJoint
JointModel createJoint(const Eigen::Vector3d &axis)
Create a joint to add to the joint composite if needed.
Definition: mjcf-graph.cpp:771
pinocchio::mjcf::details::MjcfBody::childClass
std::string childClass
Definition: mjcf-graph.hpp:99
CppAD::max
AD< Scalar > max(const AD< Scalar > &x, const AD< Scalar > &y)
Definition: autodiff/cppad.hpp:180
pinocchio::mjcf::details::getName
static std::string getName(const ptree &el, const boost::filesystem::path &filePath)
Definition: mjcf-graph.cpp:52
d
FCL_REAL d
pinocchio::mjcf::details::internal::getUnknownSizeVectorFromStream
Eigen::VectorXd getUnknownSizeVectorFromStream(const std::string &str)
Definition: mjcf-graph.hpp:501
n
Vec3f n
robot-wrapper-viewer.com
com
Definition: robot-wrapper-viewer.py:45
pinocchio::mjcf::details::RangeJoint::maxEffort
Eigen::VectorXd maxEffort
Definition: mjcf-graph.hpp:118
pinocchio::mjcf::details::MjcfTexture
All informations related to a texture are stored here.
Definition: mjcf-graph.hpp:214
pinocchio::mjcf::details::MjcfGraph::modelPath
std::string modelPath
Definition: mjcf-graph.hpp:367
pinocchio::mjcf::details::MjcfSite::fill
void fill(const ptree &el, const MjcfBody &currentBody, const MjcfGraph &currentGraph)
Definition: mjcf-graph-geom.cpp:467
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::mjcf::details::MjcfGeom::VISUAL
@ VISUAL
Definition: mjcf-graph.hpp:254
pinocchio::mjcf::details::MjcfJoint::range
RangeJoint range
Definition: mjcf-graph.hpp:186


pinocchio
Author(s):
autogenerated on Tue Jun 25 2024 02:42:40