Skip to content

Commit

Permalink
Handle sdf::Geometry::EMPTY in conversions (#2430)
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Koenig <[email protected]>
  • Loading branch information
nkoenig authored Jun 5, 2024
1 parent 1b577f1 commit 49ab5c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ msgs::Geometry gz::sim::convert(const sdf::Geometry &_in)
}
}
}
else if (_in.Type() == sdf::GeometryType::EMPTY)
{
out.set_type(msgs::Geometry::EMPTY);
}
else
{
gzerr << "Geometry type [" << static_cast<int>(_in.Type())
Expand Down
10 changes: 10 additions & 0 deletions src/Conversions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1206,3 +1206,13 @@ TEST(Conversions, MsgsPluginToSdf)
EXPECT_EQ(innerXml, sdfPlugins[1].Contents()[0]->ToString(""));
EXPECT_EQ(innerXml2, sdfPlugins[1].Contents()[1]->ToString(""));
}

/////////////////////////////////////////////////
TEST(Conversions, GeometryEmpty)
{
sdf::Geometry geometry;
geometry.SetType(sdf::GeometryType::EMPTY);

auto geometryMsg = convert<msgs::Geometry>(geometry);
EXPECT_EQ(msgs::Geometry::EMPTY, geometryMsg.type());
}

0 comments on commit 49ab5c6

Please sign in to comment.