src/parsers/sdf/model.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2022 INRIA
3 //
4 
10 
11 #include <sdf/sdf.hh>
12 #include <ignition/math.hh>
13 #include <sstream>
14 #include <boost/foreach.hpp>
15 #include <limits>
16 #include <iostream>
17 
18 namespace pinocchio
19 {
20  namespace sdf
21  {
22  namespace details
23  {
24 
25  const std::string findRootLink(const SdfGraph & graph)
26  {
27  std::string trial_link = graph.mapOfLinks.begin()->first;
28  bool search_for_parent = true;
29  while (search_for_parent)
30  {
31  const std::vector<std::string> & parents_of_links =
32  graph.parentOfLinks.find(trial_link)->second;
33  if (parents_of_links.size() == 0)
34  {
35  search_for_parent = false;
36  return trial_link;
37  }
38  else
39  {
40  ::sdf::ElementPtr joint_element = graph.mapOfJoints.find(parents_of_links[0])->second;
41  trial_link = joint_element->GetElement("parent")->template Get<std::string>();
42  }
43  }
44  return std::string("");
45  }
46 
48  const SdfGraph & graph,
49  const urdf::details::UrdfVisitorBase & visitor,
50  const Model & model,
52  {
54  SdfGraph::ContactDetails)::const_iterator cm = std::cbegin(graph.contact_details);
55  cm != std::cend(graph.contact_details); ++cm)
56  {
57  // Get Link Name, and Link Pose, and set the values here:
58  const JointIndex joint_id = visitor.getParentId(cm->name);
59  const SE3 & cMj = graph.childPoseMap.find(cm->name)->second;
60 
62  cm->type, model, cm->joint1_id, cm->joint1_placement, joint_id, cMj.inverse(),
63  cm->reference_frame);
64 
65  contact_models.push_back(rcm);
66  }
67  }
68 
69  void parseRootTree(SdfGraph & graph, const std::string & rootLinkName)
70  {
71  // First joint connecting universe
72  const ::sdf::ElementPtr rootLinkElement = graph.mapOfLinks.find(rootLinkName)->second;
73  const ::sdf::ElementPtr inertialElem = rootLinkElement->GetElement("inertial");
74 
75  graph.urdfVisitor.addRootJoint(convertInertiaFromSdf(inertialElem), rootLinkName);
76  const std::vector<std::string> & childrenOfLink =
77  graph.childrenOfLinks.find(rootLinkName)->second;
78  for (std::vector<std::string>::const_iterator childOfChild = std::begin(childrenOfLink);
79  childOfChild != std::end(childrenOfLink); ++childOfChild)
80  {
81  graph.recursiveFillModel(graph.mapOfJoints.find(*childOfChild)->second);
82  }
83  }
84  } // namespace details
85  } // namespace sdf
86 } // namespace pinocchio
pinocchio::SE3Tpl::inverse
SE3Tpl inverse() const
aXb = bXa.inverse()
Definition: spatial/se3-tpl.hpp:149
pinocchio::sdf::details::parseRootTree
void parseRootTree(SdfGraph &graph, const std::string &rootLinkName)
Definition: src/parsers/sdf/model.cpp:69
pinocchio::SE3Tpl< context::Scalar, context::Options >
model.hpp
pinocchio::sdf::details::findRootLink
const std::string findRootLink(const SdfGraph &graph)
Definition: src/parsers/sdf/model.cpp:25
pinocchio::sdf::details::parseContactInformation
void parseContactInformation(const SdfGraph &graph, const urdf::details::UrdfVisitorBase &visitor, const Model &model, PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(RigidConstraintModel) &contact_models)
Definition: src/parsers/sdf/model.cpp:47
matrix.hpp
details
sdf.hpp
pinocchio::RigidConstraintModelTpl
Definition: algorithm/constraints/fwd.hpp:14
urdf.hpp
PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR
#define PINOCCHIO_STD_VECTOR_WITH_EIGEN_ALLOCATOR(T)
Definition: container/aligned-vector.hpp:13
quadrotor-ocp.cm
cm
Definition: quadrotor-ocp.py:22
graph
Definition: graph.py:1
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
contact-cholesky.contact_models
list contact_models
Definition: contact-cholesky.py:22
contact-info.hpp
append-urdf-model-with-another-model.joint_id
joint_id
Definition: append-urdf-model-with-another-model.py:34
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::model
JointCollectionTpl & model
Definition: joint-configuration.hpp:1082
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:11