Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Fixed
- Fix linkage of Boost.Serialization on Windows ([#2400](https://github.com/stack-of-tasks/pinocchio/pull/2400))
- Fix mjcf parser appending of inertias at root joint ([#2403](https://github.com/stack-of-tasks/pinocchio/pull/2403))

## [3.2.0] - 2024-08-27

Expand Down
38 changes: 25 additions & 13 deletions src/parsers/mjcf/mjcf-graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,29 @@ namespace pinocchio
namespace fs = boost::filesystem;
MjcfTexture text;
auto file = el.get_optional<std::string>("<xmlattr>.file");
if (!file)
throw std::invalid_argument("Only textures with files are supported");

fs::path filePath(*file);
std::string name = getName(el, filePath);
auto name_ = el.get_optional<std::string>("<xmlattr>.name");
auto type = el.get_optional<std::string>("<xmlattr>.type");

text.filePath =
updatePath(compilerInfo.strippath, compilerInfo.texturedir, modelPath, filePath).string();
std::string name;
if (name_)
name = *name_;
else if (*type == "skybox")
name = *type;
if (!file)
{
std::cout << "Warning - Only texture with files are supported" << std::endl;
if (name.empty())
throw std::invalid_argument("Textures need a name.");
}
else
{
fs::path filePath(*file);
name = getName(el, filePath);

text.filePath =
updatePath(compilerInfo.strippath, compilerInfo.texturedir, modelPath, filePath)
.string();
}
auto str_v = el.get_optional<std::string>("<xmlattr>.type");
if (str_v)
text.textType = *str_v;
Expand Down Expand Up @@ -785,15 +799,12 @@ namespace pinocchio
{

FrameIndex parentFrameId = 0;
Inertia inert = Inertia::Zero();
if (!currentBody.bodyParent.empty())
{
parentFrameId = urdfVisitor.getBodyId(currentBody.bodyParent);
inert = currentBody.bodyInertia;
}

// get body pose in body parent
const SE3 bodyPose = currentBody.bodyPlacement;

Inertia inert = currentBody.bodyInertia;
SE3 jointInParent = bodyPose * joint.jointPlacement;
bodyInJoint = joint.jointPlacement.inverse();
UrdfVisitor::JointType jType;
Expand Down Expand Up @@ -1036,7 +1047,8 @@ namespace pinocchio
// get name and inertia of first root link
std::string rootLinkName = bodiesList.at(0);
MjcfBody rootBody = mapOfBodies.find(rootLinkName)->second;
urdfVisitor.addRootJoint(rootBody.bodyInertia, rootLinkName);
if (rootBody.jointChildren.size() == 0)
urdfVisitor.addRootJoint(rootBody.bodyInertia, rootLinkName);

fillReferenceConfig(rootBody);
for (const auto & entry : bodiesList)
Expand Down