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;
55 Eigen::Matrix3d mapEulerAngles = Eigen::Matrix3d::Identity();
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);
224 Eigen::Vector2d
gridsize = Eigen::Vector2d::Constant(1);
232 Eigen::Vector4d rgba = Eigen::Vector4d::Constant(1);
234 float reflectance = 0;
236 float shininess = 0.5;
238 float specular = 0.5;
246 void goThroughElement(
const ptree & el);
265 std::string geomType =
"sphere";
284 Eigen::Vector4d rgba = Eigen::Vector4d::Constant(1);
292 double density = 1000;
294 bool shellinertia =
false;
310 void computeInertia();
316 void goThroughElement(
const ptree & el,
const MjcfGraph & currentGraph);
328 void goThroughElement(
const ptree & el,
const MjcfGraph & currentGraph);
368 Eigen::Vector3d anchor = Eigen::Vector3d::Zero();
386 typedef std::unordered_map<std::string, MjcfBody>
BodyMap_t;
387 typedef std::unordered_map<std::string, MjcfClass>
ClassMap_t;
389 typedef std::unordered_map<std::string, MjcfMesh>
MeshMap_t;
391 typedef std::unordered_map<std::string, Eigen::VectorXd>
ConfigMap_t;
425 typedef pinocchio::urdf::details::
426 UrdfVisitor<double, 0, ::pinocchio::JointCollectionDefaultTpl>
433 : modelPath(modelPath)
434 , urdfVisitor(urdfVisitor)
441 SE3 convertPosition(
const ptree & el)
const;
451 void parseDefault(
ptree & el,
const ptree &
parent,
const std::string & parentTag);
457 void parseJointAndBody(
459 const boost::optional<std::string> & childClass,
460 const std::string & parentName =
"");
464 void parseCompiler(
const ptree & el);
468 void parseTexture(
const ptree & el);
472 void parseMaterial(
const ptree & el);
476 void parseMesh(
const ptree & el);
480 void parseAsset(
const ptree & el);
484 void parseKeyFrame(
const ptree & el);
488 void parseEquality(
const ptree & el);
495 void parseGraphFromXML(
const std::string & xmlStr);
504 template<
typename TypeX,
typename TypeY,
typename TypeZ,
typename TypeUnaligned>
505 JointModel createJoint(
const Eigen::Vector3d & axis);
517 void fillModel(
const std::string & nameOfBody);
524 void fillReferenceConfig(
const MjcfBody & currentBody);
529 void addKeyFrame(
const Eigen::VectorXd & keyframe,
const std::string & keyName);
551 std::istringstream posStream(
str);
552 posStream.exceptions(std::ios::badbit);
560 Eigen::Matrix<double, N, 1> vector;
561 for (
int i = 0;
i <
N;
i++)
570 std::vector<double> vector;
572 while (stream >> elem)
574 vector.push_back(elem);
577 Eigen::VectorXd returnVector(vector.size());
578 for (std::size_t
i = 0;
i < vector.size();
i++)
588 #endif // __pinocchio_parsers_mjcf_graph_hpp__