Skip to content

Commit

Permalink
Merge branch 'sdf13' into scpeters/merge_13_main
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters committed Aug 22, 2023
2 parents af88891 + 7f63d02 commit 11b9681
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add ticket to inbox
uses: technote-space/create-project-card-action@v1
uses: actions/[email protected]
with:
PROJECT: Core development
COLUMN: Inbox
GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }}
CHECK_ORG_PROJECT: true
project-url: https://github.com/orgs/gazebosim/projects/7
github-token: ${{ secrets.TRIAGE_TOKEN }}

2 changes: 1 addition & 1 deletion python/test/pyWorld_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_set_physics(self):

def test_set_scene(self):
world = World()
self.assertEqual(None, world.scene())
self.assertNotEqual(None, world.scene())

scene = Scene()
scene.set_ambient(Color.BLUE)
Expand Down
24 changes: 10 additions & 14 deletions src/World.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class sdf::World::Implementation
/// \return Errors, if any.
public: Errors LoadSphericalCoordinates(sdf::ElementPtr _elem);

/// \brief Optional atmosphere model.
public: std::optional<sdf::Atmosphere> atmosphere;
/// \brief Required atmosphere model.
public: sdf::Atmosphere atmosphere;

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

/// \brief Optional Scene parameters.
public: std::optional<sdf::Scene> scene;
/// \brief Required scene parameters.
public: sdf::Scene scene;

/// \brief The frames specified in this world.
public: std::vector<Frame> frames;
Expand Down Expand Up @@ -180,9 +180,8 @@ Errors World::Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
// Read the atmosphere element
if (_sdf->HasElement("atmosphere"))
{
this->dataPtr->atmosphere.emplace();
Errors atmosphereLoadErrors =
this->dataPtr->atmosphere->Load(_sdf->GetElement("atmosphere"));
this->dataPtr->atmosphere.Load(_sdf->GetElement("atmosphere"));
errors.insert(errors.end(), atmosphereLoadErrors.begin(),
atmosphereLoadErrors.end());
}
Expand Down Expand Up @@ -314,9 +313,8 @@ Errors World::Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
// Load the Scene
if (_sdf->HasElement("scene"))
{
this->dataPtr->scene.emplace();
Errors sceneLoadErrors =
this->dataPtr->scene->Load(_sdf->GetElement("scene"), _config);
this->dataPtr->scene.Load(_sdf->GetElement("scene"), _config);
errors.insert(errors.end(), sceneLoadErrors.begin(), sceneLoadErrors.end());
}

Expand Down Expand Up @@ -459,7 +457,7 @@ Model *World::ModelByName(const std::string &_name)
/////////////////////////////////////////////////
const sdf::Atmosphere *World::Atmosphere() const
{
return optionalToPointer(this->dataPtr->atmosphere);
return &(this->dataPtr->atmosphere);
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -497,7 +495,7 @@ void World::SetGui(const sdf::Gui &_gui)
/////////////////////////////////////////////////
const sdf::Scene *World::Scene() const
{
return optionalToPointer(this->dataPtr->scene);
return &(this->dataPtr->scene);
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -1033,16 +1031,14 @@ sdf::ElementPtr World::ToElement(const OutputConfig &_config) const
}

// Atmosphere
if (this->dataPtr->atmosphere)
elem->InsertElement(this->dataPtr->atmosphere->ToElement(), true);
elem->InsertElement(this->dataPtr->atmosphere.ToElement(), true);

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

// Scene
if (this->dataPtr->scene)
elem->InsertElement(this->dataPtr->scene->ToElement(), true);
elem->InsertElement(this->dataPtr->scene.ToElement(), true);

// Audio
if (this->dataPtr->audioDevice != "default")
Expand Down
7 changes: 6 additions & 1 deletion src/World_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ TEST(DOMWorld, Construction)
EXPECT_STREQ("default", world.AudioDevice().c_str());
EXPECT_EQ(gz::math::Vector3d::Zero, world.WindLinearVelocity());

// The scene and atmosphere are requred, per the SDF spec. Make sure
// that they have been created.
EXPECT_TRUE(world.Scene());
EXPECT_TRUE(world.Atmosphere());

EXPECT_EQ(0u, world.ModelCount());
EXPECT_EQ(nullptr, world.ModelByIndex(0));
EXPECT_EQ(nullptr, world.ModelByIndex(1));
Expand Down Expand Up @@ -358,7 +363,7 @@ TEST(DOMWorld, SetGui)
TEST(DOMWorld, SetScene)
{
sdf::World world;
EXPECT_EQ(nullptr, world.Scene());
EXPECT_NE(nullptr, world.Scene());

sdf::Scene scene;
scene.SetAmbient(gz::math::Color::Blue);
Expand Down

0 comments on commit 11b9681

Please sign in to comment.