Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip serializing nested model with //pose/@relative_to attribute #1454

Merged
merged 6 commits into from
May 3, 2022
Merged
Changes from 2 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
27 changes: 24 additions & 3 deletions include/ignition/gazebo/components/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,34 @@ namespace serializers
sdf::ElementPtr modelElem = _model.Element();
if (!modelElem)
{
ignerr << "Unable to serialize sdf::Model" << std::endl;
ignwarn << "Unable to serialize sdf::Model" << std::endl;
return _out;
}

bool skip = false;
if (modelElem->HasElement("pose"))
{
sdf::ElementPtr poseElem = modelElem->GetElement("pose");
if (poseElem->HasAttribute("relative_to"))
{
// Skip serializing models with //pose/@relative_to attribute
// since deserialization will fail. This could be a nested model.
// see https://github.com/ignitionrobotics/ign-gazebo/issues/1071
static bool warned = false;
if (!warned)
{
ignwarn << "Skipping serialization / deserialization for models "
<< "with //pose/@relative_to attribute."
<< std::endl;
warned = true;
}
skip = true;
}
}

_out << "<?xml version=\"1.0\" ?>"
<< "<sdf version='" << SDF_PROTOCOL_VERSION << "'>"
<< modelElem->ToString("")
<< (skip ? std::string() : modelElem->ToString(""))
<< "</sdf>";
return _out;
}
Expand All @@ -70,7 +91,7 @@ namespace serializers
sdf::Errors errors = root.LoadSdfString(sdf);
if (!root.Model())
{
ignerr << "Unable to unserialize sdf::Model" << std::endl;
ignwarn << "Unable to deserialize sdf::Model" << std::endl;
return _in;
}

Expand Down