5 #ifndef __pinocchio_parsers_mjcf_graph_hpp__
6 #define __pinocchio_parsers_mjcf_graph_hpp__
12 #include <boost/property_tree/xml_parser.hpp>
13 #include <boost/property_tree/ptree.hpp>
14 #include <boost/foreach.hpp>
15 #include <boost/math/constants/constants.hpp>
16 #include <boost/filesystem.hpp>
17 #include <boost/logic/tribool.hpp>
18 #include <boost/lexical_cast.hpp>
23 #include <unordered_map>
43 bool autolimits =
true;
46 bool strippath =
false;
53 double angle_converter = boost::math::constants::pi<double>() / 180.0;
60 double boundInertia = 0;
63 boost::logic::tribool inertiafromgeom = boost::logic::indeterminate;
68 double convertAngle(
const double & angle_)
const;
73 Eigen::Matrix3d convertEuler(
const Eigen::Vector3d & angles)
const;
140 double frictionLoss = 0.;
145 const double infty = std::numeric_limits<double>::infinity();
146 maxVel = Eigen::VectorXd::Constant(1, infty);
147 maxEffort = Eigen::VectorXd::Constant(1, infty);
148 minConfig = Eigen::VectorXd::Constant(1, -infty);
149 maxConfig = Eigen::VectorXd::Constant(1, infty);
150 springStiffness = Eigen::VectorXd::Constant(1,
v);
151 springReference = Eigen::VectorXd::Constant(1,
v);
152 friction = Eigen::VectorXd::Constant(1, 0.);
153 damping = Eigen::VectorXd::Constant(1, 0.);
154 armature = Eigen::VectorXd::Constant(1, 0.);
161 template<
int Nq,
int Nv>
169 template<
int Nq,
int Nv>
180 std::string jointName =
"free";
185 Eigen::Vector3d
axis = Eigen::Vector3d::UnitZ();
190 std::string jointType =
"hinge";
203 goThroughElement(
const ptree & el,
bool use_limits,
const MjcfCompiler & currentCompiler);
209 Eigen::Vector3d
scale = Eigen::Vector3d::Constant(1);
222 Eigen::Vector2d
gridsize = Eigen::Vector2d::Constant(1);
230 Eigen::Vector4d rgba = Eigen::Vector4d::Constant(1);
232 float reflectance = 0;
234 float shininess = 0.5;
236 float specular = 0.5;
244 void goThroughElement(
const ptree & el);
263 std::string geomType =
"sphere";
282 Eigen::Vector4d rgba = Eigen::Vector4d::Constant(1);
290 double density = 1000;
292 bool shellinertia =
false;
308 void computeInertia();
314 void goThroughElement(
const ptree & el,
const MjcfGraph & currentGraph);
326 void goThroughElement(
const ptree & el,
const MjcfGraph & currentGraph);
366 Eigen::Vector3d anchor = Eigen::Vector3d::Zero();
384 typedef std::unordered_map<std::string, MjcfBody>
BodyMap_t;
385 typedef std::unordered_map<std::string, MjcfClass>
ClassMap_t;
387 typedef std::unordered_map<std::string, MjcfMesh>
MeshMap_t;
389 typedef std::unordered_map<std::string, Eigen::VectorXd>
ConfigMap_t;
423 typedef pinocchio::urdf::details::
424 UrdfVisitor<double, 0, ::pinocchio::JointCollectionDefaultTpl>
431 : modelPath(modelPath)
432 , urdfVisitor(urdfVisitor)
439 SE3 convertPosition(
const ptree & el)
const;
449 void parseDefault(
ptree & el,
const ptree &
parent,
const std::string & parentTag);
455 void parseJointAndBody(
457 const boost::optional<std::string> & childClass,
458 const std::string & parentName =
"");
462 void parseCompiler(
const ptree & el);
466 void parseTexture(
const ptree & el);
470 void parseMaterial(
const ptree & el);
474 void parseMesh(
const ptree & el);
478 void parseAsset(
const ptree & el);
482 void parseKeyFrame(
const ptree & el);
486 void parseEquality(
const ptree & el);
493 void parseGraphFromXML(
const std::string & xmlStr);
502 template<
typename TypeX,
typename TypeY,
typename TypeZ,
typename TypeUnaligned>
503 JointModel createJoint(
const Eigen::Vector3d & axis);
515 void fillModel(
const std::string & nameOfBody);
522 void fillReferenceConfig(
const MjcfBody & currentBody);
527 void addKeyFrame(
const Eigen::VectorXd & keyframe,
const std::string & keyName);
549 std::istringstream posStream(
str);
550 posStream.exceptions(std::ios::failbit);
558 Eigen::Matrix<double, N, 1> vector;
559 for (
int i = 0;
i <
N;
i++)
568 std::vector<double> vector;
570 while (!stream.eof())
573 vector.push_back(elem);
576 Eigen::VectorXd returnVector(vector.size());
577 for (std::size_t
i = 0;
i < vector.size();
i++)
587 #endif // __pinocchio_parsers_mjcf_graph_hpp__