Skip to content

Commit

Permalink
Merge branch 'sdf15' into arjo/fix/clone_parent_only
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters authored Nov 14, 2024
2 parents 57e19c1 + e40c32f commit 6d4f5d9
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0004 NEW)
endif(COMMAND CMAKE_POLICY)

project (sdformat15 VERSION 15.0.0)
project (sdformat15 VERSION 15.1.0)

# The protocol version has nothing to do with the package version.
# It represents the current version of SDFormat implemented by the software
Expand Down
29 changes: 29 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
## libsdformat 15.X

### libsdformat 15.1.0 (2024-11-13)

1. Bazel CI
* [Pull request #1500](https://github.com/gazebosim/sdformat/pull/1500)

1. Add bzlmod support to sdf15
* [Pull request #1493](https://github.com/gazebosim/sdformat/pull/1493)

1. Support removing the actor, light, or model from the root
* [Pull request #1492](https://github.com/gazebosim/sdformat/pull/1492)

1. Only look for psutil if testing is enabled
* [Pull request #1495](https://github.com/gazebosim/sdformat/pull/1495)

1. Improve installation instructions
* [Pull request #1496](https://github.com/gazebosim/sdformat/pull/1496)

1. Permit building python bindings separately from libsdformat library
* [Pull request #1491](https://github.com/gazebosim/sdformat/pull/1491)

1. Change sdf\_config.h to sdf/config.hh everywhere
* [Pull request #1494](https://github.com/gazebosim/sdformat/pull/1494)

1. Improve installation instructions
* [Pull request #1490](https://github.com/gazebosim/sdformat/pull/1490)

1. Fix symbol checking test when compiled with debug symbols
* [Pull request #1474](https://github.com/gazebosim/sdformat/pull/1474)

### libsdformat 15.0.0 (2024-09-25)

1. **Baseline:** this includes all changes from 14.5.0 and earlier.
Expand Down
5 changes: 5 additions & 0 deletions include/sdf/Root.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ namespace sdf
public: sdf::ElementPtr ToElement(
const OutputConfig &_config = OutputConfig::GlobalConfig()) const;

/// \brief Remove the actor, light, or model if one of them exists.
/// The SDF Root object can only hold one, or none, from the set
/// [Actor, Light, Model].
public: void ClearActorLightModel();

/// \brief Private data pointer
GZ_UTILS_IMPL_PTR(dataPtr)
};
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<name>sdformat15</name>
<version>15.0.0</version>
<version>15.1.0</version>
<description>SDFormat is an XML file format that describes environments, objects, and robots
in a manner suitable for robotic applications</description>

Expand Down
4 changes: 4 additions & 0 deletions python/src/sdf/pyRoot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ void defineRoot(pybind11::object module)
.def("set_light", &sdf::Root::SetLight,
"Set the light object. This will override any existing model, "
"actor, and light object.")
.def("clear_actor_light_model", &sdf::Root::ClearActorLightModel,
"Remove the actor, light, or model if one of them exists."
"The SDF Root object can only hold one, or none, from the set"
"[Actor, Light, Model].")
.def("add_world", [](Root &self, const World &_world)
{
ThrowIfErrors(self.AddWorld(_world));
Expand Down
28 changes: 28 additions & 0 deletions python/test/pyRoot_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,33 @@ def test_resolve_auto_inertials_with_save_calculation_configuration(self):
self.assertEqual(len(inertialErr), 0)
self.assertTrue(link.auto_inertia_saved())

def test_clear_actor_light_model(self):
root = Root()

# \TODO(anyone) Wrap the Actor class.
# self.assertEqual(None, root.actor())
# actor1 = Actor()
# actor1.set_name("actor1")
# root.set_actor(actor1)
# self.assertNotEqual(None, root.actor())
# root.clear_actor_light_model()
# self.assertEqual(None, root.actor())

self.assertEqual(None, root.light())
light1 = Light()
light1.set_name("light1")
root.set_light(light1)
self.assertNotEqual(None, root.light())
root.clear_actor_light_model()
self.assertEqual(None, root.light())

self.assertEqual(None, root.model())
model1 = Model()
model1.set_name("model1")
root.set_model(model1)
self.assertNotEqual(None, root.model())
root.clear_actor_light_model()
self.assertEqual(None, root.model())

if __name__ == '__main__':
unittest.main()
6 changes: 6 additions & 0 deletions src/Root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,9 @@ sdf::ElementPtr Root::ToElement(const OutputConfig &_config) const

return elem;
}

/////////////////////////////////////////////////
void Root::ClearActorLightModel()
{
this->dataPtr->modelLightOrActor = std::monostate{};
}
42 changes: 42 additions & 0 deletions src/Root_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,3 +670,45 @@ TEST(DOMRoot, WorldByName)
ASSERT_TRUE(root.WorldNameExists("world2"));
EXPECT_EQ("world2", root.WorldByName("world2")->Name());
}

/////////////////////////////////////////////////
TEST(DOMRoot, ClearActorLightModel)
{
sdf::Root root;
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());

sdf::Actor actor1;
actor1.SetName("actor1");
root.SetActor(actor1);
EXPECT_NE(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());
root.ClearActorLightModel();
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());

sdf::Light light1;
light1.SetName("light1");
root.SetLight(light1);
EXPECT_EQ(nullptr, root.Actor());
EXPECT_NE(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());
root.ClearActorLightModel();
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());

sdf::Model model1;
model1.SetName("model1");
root.SetModel(model1);
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_NE(nullptr, root.Model());
root.ClearActorLightModel();
EXPECT_EQ(nullptr, root.Actor());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Model());
}

0 comments on commit 6d4f5d9

Please sign in to comment.