Skip to content

Commit 6d4f5d9

Browse files
authored
Merge branch 'sdf15' into arjo/fix/clone_parent_only
2 parents 57e19c1 + e40c32f commit 6d4f5d9

File tree

8 files changed

+116
-2
lines changed

8 files changed

+116
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(COMMAND CMAKE_POLICY)
55
CMAKE_POLICY(SET CMP0004 NEW)
66
endif(COMMAND CMAKE_POLICY)
77

8-
project (sdformat15 VERSION 15.0.0)
8+
project (sdformat15 VERSION 15.1.0)
99

1010
# The protocol version has nothing to do with the package version.
1111
# It represents the current version of SDFormat implemented by the software

Changelog.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
## libsdformat 15.X
22

3+
### libsdformat 15.1.0 (2024-11-13)
4+
5+
1. Bazel CI
6+
* [Pull request #1500](https://github.com/gazebosim/sdformat/pull/1500)
7+
8+
1. Add bzlmod support to sdf15
9+
* [Pull request #1493](https://github.com/gazebosim/sdformat/pull/1493)
10+
11+
1. Support removing the actor, light, or model from the root
12+
* [Pull request #1492](https://github.com/gazebosim/sdformat/pull/1492)
13+
14+
1. Only look for psutil if testing is enabled
15+
* [Pull request #1495](https://github.com/gazebosim/sdformat/pull/1495)
16+
17+
1. Improve installation instructions
18+
* [Pull request #1496](https://github.com/gazebosim/sdformat/pull/1496)
19+
20+
1. Permit building python bindings separately from libsdformat library
21+
* [Pull request #1491](https://github.com/gazebosim/sdformat/pull/1491)
22+
23+
1. Change sdf\_config.h to sdf/config.hh everywhere
24+
* [Pull request #1494](https://github.com/gazebosim/sdformat/pull/1494)
25+
26+
1. Improve installation instructions
27+
* [Pull request #1490](https://github.com/gazebosim/sdformat/pull/1490)
28+
29+
1. Fix symbol checking test when compiled with debug symbols
30+
* [Pull request #1474](https://github.com/gazebosim/sdformat/pull/1474)
31+
332
### libsdformat 15.0.0 (2024-09-25)
433

534
1. **Baseline:** this includes all changes from 14.5.0 and earlier.

include/sdf/Root.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ namespace sdf
246246
public: sdf::ElementPtr ToElement(
247247
const OutputConfig &_config = OutputConfig::GlobalConfig()) const;
248248

249+
/// \brief Remove the actor, light, or model if one of them exists.
250+
/// The SDF Root object can only hold one, or none, from the set
251+
/// [Actor, Light, Model].
252+
public: void ClearActorLightModel();
253+
249254
/// \brief Private data pointer
250255
GZ_UTILS_IMPL_PTR(dataPtr)
251256
};

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="2">
33
<name>sdformat15</name>
4-
<version>15.0.0</version>
4+
<version>15.1.0</version>
55
<description>SDFormat is an XML file format that describes environments, objects, and robots
66
in a manner suitable for robotic applications</description>
77

python/src/sdf/pyRoot.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ void defineRoot(pybind11::object module)
9696
.def("set_light", &sdf::Root::SetLight,
9797
"Set the light object. This will override any existing model, "
9898
"actor, and light object.")
99+
.def("clear_actor_light_model", &sdf::Root::ClearActorLightModel,
100+
"Remove the actor, light, or model if one of them exists."
101+
"The SDF Root object can only hold one, or none, from the set"
102+
"[Actor, Light, Model].")
99103
.def("add_world", [](Root &self, const World &_world)
100104
{
101105
ThrowIfErrors(self.AddWorld(_world));

python/test/pyRoot_TEST.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,33 @@ def test_resolve_auto_inertials_with_save_calculation_configuration(self):
358358
self.assertEqual(len(inertialErr), 0)
359359
self.assertTrue(link.auto_inertia_saved())
360360

361+
def test_clear_actor_light_model(self):
362+
root = Root()
363+
364+
# \TODO(anyone) Wrap the Actor class.
365+
# self.assertEqual(None, root.actor())
366+
# actor1 = Actor()
367+
# actor1.set_name("actor1")
368+
# root.set_actor(actor1)
369+
# self.assertNotEqual(None, root.actor())
370+
# root.clear_actor_light_model()
371+
# self.assertEqual(None, root.actor())
372+
373+
self.assertEqual(None, root.light())
374+
light1 = Light()
375+
light1.set_name("light1")
376+
root.set_light(light1)
377+
self.assertNotEqual(None, root.light())
378+
root.clear_actor_light_model()
379+
self.assertEqual(None, root.light())
380+
381+
self.assertEqual(None, root.model())
382+
model1 = Model()
383+
model1.set_name("model1")
384+
root.set_model(model1)
385+
self.assertNotEqual(None, root.model())
386+
root.clear_actor_light_model()
387+
self.assertEqual(None, root.model())
388+
361389
if __name__ == '__main__':
362390
unittest.main()

src/Root.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,9 @@ sdf::ElementPtr Root::ToElement(const OutputConfig &_config) const
644644

645645
return elem;
646646
}
647+
648+
/////////////////////////////////////////////////
649+
void Root::ClearActorLightModel()
650+
{
651+
this->dataPtr->modelLightOrActor = std::monostate{};
652+
}

src/Root_TEST.cc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,3 +670,45 @@ TEST(DOMRoot, WorldByName)
670670
ASSERT_TRUE(root.WorldNameExists("world2"));
671671
EXPECT_EQ("world2", root.WorldByName("world2")->Name());
672672
}
673+
674+
/////////////////////////////////////////////////
675+
TEST(DOMRoot, ClearActorLightModel)
676+
{
677+
sdf::Root root;
678+
EXPECT_EQ(nullptr, root.Actor());
679+
EXPECT_EQ(nullptr, root.Light());
680+
EXPECT_EQ(nullptr, root.Model());
681+
682+
sdf::Actor actor1;
683+
actor1.SetName("actor1");
684+
root.SetActor(actor1);
685+
EXPECT_NE(nullptr, root.Actor());
686+
EXPECT_EQ(nullptr, root.Light());
687+
EXPECT_EQ(nullptr, root.Model());
688+
root.ClearActorLightModel();
689+
EXPECT_EQ(nullptr, root.Actor());
690+
EXPECT_EQ(nullptr, root.Light());
691+
EXPECT_EQ(nullptr, root.Model());
692+
693+
sdf::Light light1;
694+
light1.SetName("light1");
695+
root.SetLight(light1);
696+
EXPECT_EQ(nullptr, root.Actor());
697+
EXPECT_NE(nullptr, root.Light());
698+
EXPECT_EQ(nullptr, root.Model());
699+
root.ClearActorLightModel();
700+
EXPECT_EQ(nullptr, root.Actor());
701+
EXPECT_EQ(nullptr, root.Light());
702+
EXPECT_EQ(nullptr, root.Model());
703+
704+
sdf::Model model1;
705+
model1.SetName("model1");
706+
root.SetModel(model1);
707+
EXPECT_EQ(nullptr, root.Actor());
708+
EXPECT_EQ(nullptr, root.Light());
709+
EXPECT_NE(nullptr, root.Model());
710+
root.ClearActorLightModel();
711+
EXPECT_EQ(nullptr, root.Actor());
712+
EXPECT_EQ(nullptr, root.Light());
713+
EXPECT_EQ(nullptr, root.Model());
714+
}

0 commit comments

Comments
 (0)