Skip to content

Reduce/Eliminate sdf::Model and sdf::World serialization warnings #2742

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

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion include/gz/sim/components/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace serializers
if (modelElem->HasElement("pose"))
{
sdf::ElementPtr poseElem = modelElem->GetElement("pose");
if (poseElem->HasAttribute("relative_to"))
if (poseElem->GetAttribute("relative_to")->GetSet())
{
// Skip serializing models with //pose/@relative_to attribute
// since deserialization will fail. This could be a nested model.
Expand Down
23 changes: 23 additions & 0 deletions include/gz/sim/components/World.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ namespace sim
{
// Inline bracket to help doxygen filtering.
inline namespace GZ_SIM_VERSION_NAMESPACE {

namespace serializers
{
/// \brief Specialize the DefaultSerializer on sdf::World so we can
/// skip serialization
/// TODO(azeey) Do we ever want to serialize this component?
template <>
class DefaultSerializer<sdf::World>
{
public:
static std::ostream &Serialize(std::ostream &_out, const sdf::World &)
{
return _out;
}

public:
static std::istream &Deserialize(std::istream &_in, sdf::World &)
{
return _in;
}
};
}

namespace components
{
/// \brief A component that identifies an entity as being a world.
Expand Down
Loading