Skip to content

Commit d1e1fe3

Browse files
author
Marco A. Gutierrez
authored
Merge branch 'sdf13' into sdf_error_parser
2 parents 973e91c + 7f63d02 commit d1e1fe3

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

.github/workflows/triage.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Add ticket to inbox
13-
uses: technote-space/create-project-card-action@v1
13+
uses: actions/[email protected]
1414
with:
15-
PROJECT: Core development
16-
COLUMN: Inbox
17-
GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }}
18-
CHECK_ORG_PROJECT: true
15+
project-url: https://github.com/orgs/gazebosim/projects/7
16+
github-token: ${{ secrets.TRIAGE_TOKEN }}
1917

python/test/pyWorld_TEST.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_set_physics(self):
202202

203203
def test_set_scene(self):
204204
world = World()
205-
self.assertEqual(None, world.scene())
205+
self.assertNotEqual(None, world.scene())
206206

207207
scene = Scene()
208208
scene.set_ambient(Color.BLUE)

src/World.cc

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class sdf::World::Implementation
4747
/// \return Errors, if any.
4848
public: Errors LoadSphericalCoordinates(sdf::ElementPtr _elem);
4949

50-
/// \brief Optional atmosphere model.
51-
public: std::optional<sdf::Atmosphere> atmosphere;
50+
/// \brief Required atmosphere model.
51+
public: sdf::Atmosphere atmosphere;
5252

5353
/// \brief Audio device name
5454
public: std::string audioDevice = "default";
@@ -60,8 +60,8 @@ class sdf::World::Implementation
6060
/// \brief Optional Gui parameters.
6161
public: std::optional<sdf::Gui> gui;
6262

63-
/// \brief Optional Scene parameters.
64-
public: std::optional<sdf::Scene> scene;
63+
/// \brief Required scene parameters.
64+
public: sdf::Scene scene;
6565

6666
/// \brief The frames specified in this world.
6767
public: std::vector<Frame> frames;
@@ -180,9 +180,8 @@ Errors World::Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
180180
// Read the atmosphere element
181181
if (_sdf->HasElement("atmosphere"))
182182
{
183-
this->dataPtr->atmosphere.emplace();
184183
Errors atmosphereLoadErrors =
185-
this->dataPtr->atmosphere->Load(_sdf->GetElement("atmosphere"));
184+
this->dataPtr->atmosphere.Load(_sdf->GetElement("atmosphere"));
186185
errors.insert(errors.end(), atmosphereLoadErrors.begin(),
187186
atmosphereLoadErrors.end());
188187
}
@@ -314,9 +313,8 @@ Errors World::Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
314313
// Load the Scene
315314
if (_sdf->HasElement("scene"))
316315
{
317-
this->dataPtr->scene.emplace();
318316
Errors sceneLoadErrors =
319-
this->dataPtr->scene->Load(_sdf->GetElement("scene"), _config);
317+
this->dataPtr->scene.Load(_sdf->GetElement("scene"), _config);
320318
errors.insert(errors.end(), sceneLoadErrors.begin(), sceneLoadErrors.end());
321319
}
322320

@@ -459,7 +457,7 @@ Model *World::ModelByName(const std::string &_name)
459457
/////////////////////////////////////////////////
460458
const sdf::Atmosphere *World::Atmosphere() const
461459
{
462-
return optionalToPointer(this->dataPtr->atmosphere);
460+
return &(this->dataPtr->atmosphere);
463461
}
464462

465463
/////////////////////////////////////////////////
@@ -497,7 +495,7 @@ void World::SetGui(const sdf::Gui &_gui)
497495
/////////////////////////////////////////////////
498496
const sdf::Scene *World::Scene() const
499497
{
500-
return optionalToPointer(this->dataPtr->scene);
498+
return &(this->dataPtr->scene);
501499
}
502500

503501
/////////////////////////////////////////////////
@@ -1033,16 +1031,14 @@ sdf::ElementPtr World::ToElement(const OutputConfig &_config) const
10331031
}
10341032

10351033
// Atmosphere
1036-
if (this->dataPtr->atmosphere)
1037-
elem->InsertElement(this->dataPtr->atmosphere->ToElement(), true);
1034+
elem->InsertElement(this->dataPtr->atmosphere.ToElement(), true);
10381035

10391036
// Gui
10401037
if (this->dataPtr->gui)
10411038
elem->InsertElement(this->dataPtr->gui->ToElement(), true);
10421039

10431040
// Scene
1044-
if (this->dataPtr->scene)
1045-
elem->InsertElement(this->dataPtr->scene->ToElement(), true);
1041+
elem->InsertElement(this->dataPtr->scene.ToElement(), true);
10461042

10471043
// Audio
10481044
if (this->dataPtr->audioDevice != "default")

src/World_TEST.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ TEST(DOMWorld, Construction)
3939
EXPECT_STREQ("default", world.AudioDevice().c_str());
4040
EXPECT_EQ(gz::math::Vector3d::Zero, world.WindLinearVelocity());
4141

42+
// The scene and atmosphere are requred, per the SDF spec. Make sure
43+
// that they have been created.
44+
EXPECT_TRUE(world.Scene());
45+
EXPECT_TRUE(world.Atmosphere());
46+
4247
EXPECT_EQ(0u, world.ModelCount());
4348
EXPECT_EQ(nullptr, world.ModelByIndex(0));
4449
EXPECT_EQ(nullptr, world.ModelByIndex(1));
@@ -358,7 +363,7 @@ TEST(DOMWorld, SetGui)
358363
TEST(DOMWorld, SetScene)
359364
{
360365
sdf::World world;
361-
EXPECT_EQ(nullptr, world.Scene());
366+
EXPECT_NE(nullptr, world.Scene());
362367

363368
sdf::Scene scene;
364369
scene.SetAmbient(gz::math::Color::Blue);

0 commit comments

Comments
 (0)