From 49ab5c6d0c69abdf0db45b99bcd350f4d90bf7cf Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Wed, 5 Jun 2024 07:55:42 -0700 Subject: [PATCH] Handle sdf::Geometry::EMPTY in conversions (#2430) Signed-off-by: Nate Koenig --- src/Conversions.cc | 4 ++++ src/Conversions_TEST.cc | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Conversions.cc b/src/Conversions.cc index 33548a6843..1ef5df8f82 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -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(_in.Type()) diff --git a/src/Conversions_TEST.cc b/src/Conversions_TEST.cc index 3d6e3e5861..2e7deecdd0 100644 --- a/src/Conversions_TEST.cc +++ b/src/Conversions_TEST.cc @@ -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(geometry); + EXPECT_EQ(msgs::Geometry::EMPTY, geometryMsg.type()); +}