diff --git a/src/parsers/mjcf/mjcf-graph.cpp b/src/parsers/mjcf/mjcf-graph.cpp index 8a4f71a86..74e7c6ace 100644 --- a/src/parsers/mjcf/mjcf-graph.cpp +++ b/src/parsers/mjcf/mjcf-graph.cpp @@ -59,13 +59,13 @@ namespace pinocchio else { if (filePath.extension().empty()) - throw std::invalid_argument("Cannot find extension for one of the mesh/texture"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Cannot find extension for one of the mesh/texture"); auto st = filePath.stem(); if (!st.empty()) return st.string(); else - throw std::invalid_argument("Cannot find a name for one of the mesh.texture"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Cannot find a name for one of the mesh.texture"); } } @@ -172,7 +172,7 @@ namespace pinocchio { if (!use_limits && el.get_optional(".range")) - throw std::invalid_argument("Range limit is specified but it was not specify to use it."); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Range limit is specified but it was not specify to use it."); // Type auto type_s = el.get_optional(".type"); @@ -227,7 +227,7 @@ namespace pinocchio else if (jointType == "hinge") posRef = currentCompiler.convertAngle(*value); else - throw std::invalid_argument( + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Reference position can only be used with hinge or slide joints."); } } @@ -358,7 +358,7 @@ namespace pinocchio double mass = std::max(el.get(".mass"), compilerInfo.boundMass); ; if (mass < 0) - throw std::invalid_argument("Mass of body is not supposed to be negative"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Mass of body is not supposed to be negative"); Inertia::Vector3 com; auto com_s = el.get_optional(".pos"); @@ -410,7 +410,7 @@ namespace pinocchio auto chcl_s = childClass; // if inertiafromgeom is false and inertia does not exist - throw if (!compilerInfo.inertiafromgeom && !el.get_child_optional("inertial")) - throw std::invalid_argument("Cannot get inertia from geom and no inertia was found"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Cannot get inertia from geom and no inertia was found"); bool usegeominertia = false; if (compilerInfo.inertiafromgeom) @@ -524,7 +524,7 @@ namespace pinocchio { std::cout << "Warning - Only texture with files are supported" << std::endl; if (name.empty()) - throw std::invalid_argument("Textures need a name."); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Textures need a name."); } else { @@ -553,7 +553,7 @@ namespace pinocchio if (n) name = *n; else - throw std::invalid_argument("Material was given without a name"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Material was given without a name"); // default < Class < Attributes if (mapOfClasses.find("mujoco_default") != mapOfClasses.end()) @@ -644,7 +644,7 @@ namespace pinocchio parseTexture(v.second); if (v.first == "hfield") - throw std::invalid_argument("hfields are not supported yet"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "hfields are not supported yet"); } } @@ -666,7 +666,7 @@ namespace pinocchio mapOfClasses.insert(std::make_pair(*nameClass, classDefault)); } else - throw std::invalid_argument("Class does not have a name. Cannot parse model."); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Class does not have a name. Cannot parse model."); } else if (v.first == "default") parseDefault(v.second, el, v.first); @@ -735,8 +735,10 @@ namespace pinocchio { std::string eulerseq = *eulerS; if (eulerseq.find_first_not_of("xyzXYZ") != std::string::npos || eulerseq.size() != 3) - throw std::invalid_argument( + { + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Model tried to use euler angles but euler sequence is wrong"); + } else { // get index combination @@ -764,7 +766,7 @@ namespace pinocchio compilerInfo.mapEulerAngles.col(ci) = Eigen::Vector3d::UnitZ(); break; default: - throw std::invalid_argument("Euler Axis does not exist"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Euler Axis does not exist"); break; } } @@ -817,7 +819,7 @@ namespace pinocchio if (body1) eq.body1 = *body1; else - throw std::invalid_argument("Equality constraint needs a first body"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Equality constraint needs a first body"); // get the name of second body auto body2 = v.second.get_optional(".body2"); @@ -846,7 +848,7 @@ namespace pinocchio if (pt.get_child_optional("mujoco")) el = pt.get_child("mujoco"); else - throw std::invalid_argument("This is not a standard mujoco model. Cannot parse it."); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "This is not a standard mujoco model. Cannot parse it."); for (const ptree::value_type & v : el) { @@ -857,7 +859,7 @@ namespace pinocchio if (n_s) modelName = *n_s; else - throw std::invalid_argument("Model is missing a name. Cannot parse it"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Model is missing a name. Cannot parse it"); } if (v.first == "compiler") @@ -945,7 +947,7 @@ namespace pinocchio jType = UrdfVisitor::REVOLUTE; } else - throw std::invalid_argument("Unknown joint type"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Unknown joint type"); urdfVisitor.addJointAndBody( jType, joint.axis, parentFrameId, jointInParent, joint.jointName, inert, bodyInJoint, @@ -1017,7 +1019,7 @@ namespace pinocchio for (const auto & joint : currentBody.jointChildren) { if (joint.jointType == "free") - throw std::invalid_argument("Joint Composite trying to be created with a freeFlyer"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Joint Composite trying to be created with a freeFlyer"); SE3 jointInParent = bodyPose * joint.jointPlacement; bodyInJoint = joint.jointPlacement.inverse(); @@ -1052,7 +1054,7 @@ namespace pinocchio rangeCompo = rangeCompo.concatenate<1, 1>(joint.range); } else - throw std::invalid_argument("Unknown joint type trying to be parsed."); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Unknown joint type trying to be parsed."); prevJointPlacement = jointInParent; } @@ -1152,7 +1154,7 @@ namespace pinocchio urdfVisitor.model.referenceConfigurations.insert(std::make_pair(keyName, qpos)); } else - throw std::invalid_argument("Keyframe size does not match model size"); + PINOCCHIO_THROW_PRETTY(std::invalid_argument, "Keyframe size does not match model size"); } void MjcfGraph::parseContactInformation( @@ -1189,7 +1191,7 @@ namespace pinocchio void MjcfGraph::parseRootTree() { urdfVisitor.setName(modelName); - + // get name and inertia of first root link std::string rootLinkName = bodiesList.at(0); MjcfBody rootBody = mapOfBodies.find(rootLinkName)->second;