@@ -59,13 +59,15 @@ namespace pinocchio
5959 else
6060 {
6161 if (filePath.extension ().empty ())
62- throw std::invalid_argument (" Cannot find extension for one of the mesh/texture" );
62+ PINOCCHIO_THROW_PRETTY (
63+ std::invalid_argument, " Cannot find extension for one of the mesh/texture" );
6364
6465 auto st = filePath.stem ();
6566 if (!st.empty ())
6667 return st.string ();
6768 else
68- throw std::invalid_argument (" Cannot find a name for one of the mesh.texture" );
69+ PINOCCHIO_THROW_PRETTY (
70+ std::invalid_argument, " Cannot find a name for one of the mesh.texture" );
6971 }
7072 }
7173
@@ -172,7 +174,8 @@ namespace pinocchio
172174 {
173175
174176 if (!use_limits && el.get_optional <std::string>(" <xmlattr>.range" ))
175- throw std::invalid_argument (" Range limit is specified but it was not specify to use it." );
177+ PINOCCHIO_THROW_PRETTY (
178+ std::invalid_argument, " Range limit is specified but it was not specify to use it." );
176179
177180 // Type
178181 auto type_s = el.get_optional <std::string>(" <xmlattr>.type" );
@@ -227,7 +230,8 @@ namespace pinocchio
227230 else if (jointType == " hinge" )
228231 posRef = currentCompiler.convertAngle (*value);
229232 else
230- throw std::invalid_argument (
233+ PINOCCHIO_THROW_PRETTY (
234+ std::invalid_argument,
231235 " Reference position can only be used with hinge or slide joints." );
232236 }
233237 }
@@ -358,7 +362,8 @@ namespace pinocchio
358362 double mass = std::max (el.get <double >(" <xmlattr>.mass" ), compilerInfo.boundMass );
359363 ;
360364 if (mass < 0 )
361- throw std::invalid_argument (" Mass of body is not supposed to be negative" );
365+ PINOCCHIO_THROW_PRETTY (
366+ std::invalid_argument, " Mass of body is not supposed to be negative" );
362367
363368 Inertia::Vector3 com;
364369 auto com_s = el.get_optional <std::string>(" <xmlattr>.pos" );
@@ -410,7 +415,8 @@ namespace pinocchio
410415 auto chcl_s = childClass;
411416 // if inertiafromgeom is false and inertia does not exist - throw
412417 if (!compilerInfo.inertiafromgeom && !el.get_child_optional (" inertial" ))
413- throw std::invalid_argument (" Cannot get inertia from geom and no inertia was found" );
418+ PINOCCHIO_THROW_PRETTY (
419+ std::invalid_argument, " Cannot get inertia from geom and no inertia was found" );
414420
415421 bool usegeominertia = false ;
416422 if (compilerInfo.inertiafromgeom )
@@ -524,7 +530,7 @@ namespace pinocchio
524530 {
525531 std::cout << " Warning - Only texture with files are supported" << std::endl;
526532 if (name.empty ())
527- throw std::invalid_argument ( " Textures need a name." );
533+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Textures need a name." );
528534 }
529535 else
530536 {
@@ -553,7 +559,7 @@ namespace pinocchio
553559 if (n)
554560 name = *n;
555561 else
556- throw std::invalid_argument ( " Material was given without a name" );
562+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Material was given without a name" );
557563
558564 // default < Class < Attributes
559565 if (mapOfClasses.find (" mujoco_default" ) != mapOfClasses.end ())
@@ -644,7 +650,7 @@ namespace pinocchio
644650 parseTexture (v.second );
645651
646652 if (v.first == " hfield" )
647- throw std::invalid_argument ( " hfields are not supported yet" );
653+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " hfields are not supported yet" );
648654 }
649655 }
650656
@@ -666,7 +672,8 @@ namespace pinocchio
666672 mapOfClasses.insert (std::make_pair (*nameClass, classDefault));
667673 }
668674 else
669- throw std::invalid_argument (" Class does not have a name. Cannot parse model." );
675+ PINOCCHIO_THROW_PRETTY (
676+ std::invalid_argument, " Class does not have a name. Cannot parse model." );
670677 }
671678 else if (v.first == " default" )
672679 parseDefault (v.second , el, v.first );
@@ -735,8 +742,10 @@ namespace pinocchio
735742 {
736743 std::string eulerseq = *eulerS;
737744 if (eulerseq.find_first_not_of (" xyzXYZ" ) != std::string::npos || eulerseq.size () != 3 )
738- throw std::invalid_argument (
739- " Model tried to use euler angles but euler sequence is wrong" );
745+ {
746+ PINOCCHIO_THROW_PRETTY (
747+ std::invalid_argument, " Model tried to use euler angles but euler sequence is wrong" );
748+ }
740749 else
741750 {
742751 // get index combination
@@ -764,7 +773,7 @@ namespace pinocchio
764773 compilerInfo.mapEulerAngles .col (ci) = Eigen::Vector3d::UnitZ ();
765774 break ;
766775 default :
767- throw std::invalid_argument ( " Euler Axis does not exist" );
776+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Euler Axis does not exist" );
768777 break ;
769778 }
770779 }
@@ -817,7 +826,7 @@ namespace pinocchio
817826 if (body1)
818827 eq.body1 = *body1;
819828 else
820- throw std::invalid_argument ( " Equality constraint needs a first body" );
829+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Equality constraint needs a first body" );
821830
822831 // get the name of second body
823832 auto body2 = v.second .get_optional <std::string>(" <xmlattr>.body2" );
@@ -846,7 +855,8 @@ namespace pinocchio
846855 if (pt.get_child_optional (" mujoco" ))
847856 el = pt.get_child (" mujoco" );
848857 else
849- throw std::invalid_argument (" This is not a standard mujoco model. Cannot parse it." );
858+ PINOCCHIO_THROW_PRETTY (
859+ std::invalid_argument, " This is not a standard mujoco model. Cannot parse it." );
850860
851861 for (const ptree::value_type & v : el)
852862 {
@@ -857,7 +867,8 @@ namespace pinocchio
857867 if (n_s)
858868 modelName = *n_s;
859869 else
860- throw std::invalid_argument (" Model is missing a name. Cannot parse it" );
870+ PINOCCHIO_THROW_PRETTY (
871+ std::invalid_argument, " Model is missing a name. Cannot parse it" );
861872 }
862873
863874 if (v.first == " compiler" )
@@ -945,7 +956,7 @@ namespace pinocchio
945956 jType = UrdfVisitor::REVOLUTE;
946957 }
947958 else
948- throw std::invalid_argument ( " Unknown joint type" );
959+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Unknown joint type" );
949960
950961 urdfVisitor.addJointAndBody (
951962 jType, joint.axis , parentFrameId, jointInParent, joint.jointName , inert, bodyInJoint,
@@ -1017,7 +1028,8 @@ namespace pinocchio
10171028 for (const auto & joint : currentBody.jointChildren )
10181029 {
10191030 if (joint.jointType == " free" )
1020- throw std::invalid_argument (" Joint Composite trying to be created with a freeFlyer" );
1031+ PINOCCHIO_THROW_PRETTY (
1032+ std::invalid_argument, " Joint Composite trying to be created with a freeFlyer" );
10211033
10221034 SE3 jointInParent = bodyPose * joint.jointPlacement ;
10231035 bodyInJoint = joint.jointPlacement .inverse ();
@@ -1052,7 +1064,8 @@ namespace pinocchio
10521064 rangeCompo = rangeCompo.concatenate <1 , 1 >(joint.range );
10531065 }
10541066 else
1055- throw std::invalid_argument (" Unknown joint type trying to be parsed." );
1067+ PINOCCHIO_THROW_PRETTY (
1068+ std::invalid_argument, " Unknown joint type trying to be parsed." );
10561069
10571070 prevJointPlacement = jointInParent;
10581071 }
@@ -1070,12 +1083,13 @@ namespace pinocchio
10701083 rangeCompo.armature ;
10711084 }
10721085
1073- FrameIndex previousFrameId = urdfVisitor.model .frames .size ();
1086+ FrameIndex bodyId = urdfVisitor.model .getFrameId (nameOfBody, BODY);
1087+ frame = urdfVisitor.model .frames [bodyId];
10741088 for (const auto & site : currentBody.siteChildren )
10751089 {
10761090 SE3 placement = bodyInJoint * site.sitePlacement ;
1077- previousFrameId = urdfVisitor.model .addFrame (
1078- Frame (site.siteName , frame.parentJoint , previousFrameId , placement, OP_FRAME));
1091+ urdfVisitor.model .addFrame (
1092+ Frame (site.siteName , frame.parentJoint , bodyId , placement, OP_FRAME));
10791093 }
10801094 }
10811095
@@ -1151,7 +1165,7 @@ namespace pinocchio
11511165 urdfVisitor.model .referenceConfigurations .insert (std::make_pair (keyName, qpos));
11521166 }
11531167 else
1154- throw std::invalid_argument ( " Keyframe size does not match model size" );
1168+ PINOCCHIO_THROW_PRETTY ( std::invalid_argument, " Keyframe size does not match model size" );
11551169 }
11561170
11571171 void MjcfGraph::parseContactInformation (
@@ -1188,7 +1202,6 @@ namespace pinocchio
11881202 void MjcfGraph::parseRootTree ()
11891203 {
11901204 urdfVisitor.setName (modelName);
1191-
11921205 // get name and inertia of first root link
11931206 std::string rootLinkName = bodiesList.at (0 );
11941207 MjcfBody rootBody = mapOfBodies.find (rootLinkName)->second ;
0 commit comments