Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 10, 2025
1 parent 3ea4df3 commit faae757
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
37 changes: 24 additions & 13 deletions src/parsers/mjcf/mjcf-graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ namespace pinocchio
else
{
if (filePath.extension().empty())
PINOCCHIO_THROW_PRETTY(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
PINOCCHIO_THROW_PRETTY(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");
}
}

Expand Down Expand Up @@ -172,7 +174,8 @@ namespace pinocchio
{

if (!use_limits && el.get_optional<std::string>("<xmlattr>.range"))
PINOCCHIO_THROW_PRETTY(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<std::string>("<xmlattr>.type");
Expand Down Expand Up @@ -227,7 +230,8 @@ namespace pinocchio
else if (jointType == "hinge")
posRef = currentCompiler.convertAngle(*value);
else
PINOCCHIO_THROW_PRETTY(std::invalid_argument,
PINOCCHIO_THROW_PRETTY(
std::invalid_argument,
"Reference position can only be used with hinge or slide joints.");
}
}
Expand Down Expand Up @@ -358,7 +362,8 @@ namespace pinocchio
double mass = std::max(el.get<double>("<xmlattr>.mass"), compilerInfo.boundMass);
;
if (mass < 0)
PINOCCHIO_THROW_PRETTY(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<std::string>("<xmlattr>.pos");
Expand Down Expand Up @@ -410,7 +415,8 @@ namespace pinocchio
auto chcl_s = childClass;
// if inertiafromgeom is false and inertia does not exist - throw
if (!compilerInfo.inertiafromgeom && !el.get_child_optional("inertial"))
PINOCCHIO_THROW_PRETTY(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)
Expand Down Expand Up @@ -666,7 +672,8 @@ namespace pinocchio
mapOfClasses.insert(std::make_pair(*nameClass, classDefault));
}
else
PINOCCHIO_THROW_PRETTY(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);
Expand Down Expand Up @@ -736,8 +743,8 @@ namespace pinocchio
std::string eulerseq = *eulerS;
if (eulerseq.find_first_not_of("xyzXYZ") != std::string::npos || eulerseq.size() != 3)
{
PINOCCHIO_THROW_PRETTY(std::invalid_argument,
"Model tried to use euler angles but euler sequence is wrong");
PINOCCHIO_THROW_PRETTY(
std::invalid_argument, "Model tried to use euler angles but euler sequence is wrong");
}
else
{
Expand Down Expand Up @@ -848,7 +855,8 @@ namespace pinocchio
if (pt.get_child_optional("mujoco"))
el = pt.get_child("mujoco");
else
PINOCCHIO_THROW_PRETTY(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)
{
Expand All @@ -859,7 +867,8 @@ namespace pinocchio
if (n_s)
modelName = *n_s;
else
PINOCCHIO_THROW_PRETTY(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")
Expand Down Expand Up @@ -1019,7 +1028,8 @@ namespace pinocchio
for (const auto & joint : currentBody.jointChildren)
{
if (joint.jointType == "free")
PINOCCHIO_THROW_PRETTY(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();
Expand Down Expand Up @@ -1054,7 +1064,8 @@ namespace pinocchio
rangeCompo = rangeCompo.concatenate<1, 1>(joint.range);
}
else
PINOCCHIO_THROW_PRETTY(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;
}
Expand Down
4 changes: 3 additions & 1 deletion unittest/mjcf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,9 @@ BOOST_AUTO_TEST_CASE(adding_site)
pinocchio::SE3 real_placement(rotation_matrix, Vector3(0.03, 0, -0.05));

BOOST_CHECK(model_m.frames[model_m.getFrameId("testSite")].placement.isApprox(real_placement));
BOOST_CHECK(model_m.frames[model_m.getFrameId("testSite")].parentJoint == model_m.frames[model_m.getFrameId("body3")].parentJoint);
BOOST_CHECK(
model_m.frames[model_m.getFrameId("testSite")].parentJoint
== model_m.frames[model_m.getFrameId("body3")].parentJoint);
}

/// @brief test that a fixed model is well parsed
Expand Down

0 comments on commit faae757

Please sign in to comment.