Skip to content

Commit

Permalink
Merge branch 'ahcorde/root/worldname' of https://github.com/osrf/sdfo…
Browse files Browse the repository at this point in the history
…rmat into ahcorde/root/worldname
  • Loading branch information
ahcorde committed Jul 8, 2022
2 parents a6c9ef3 + 94086c0 commit 4cbab2d
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 22 deletions.
4 changes: 4 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ but with improved human-readability..
+ ***Deprecation:*** bool checkJointParentChildLinkNames(const sdf::Root \*)
+ ***Replacement:*** bool checkJointParentChildNames(const sdf::Root \*)

- **sdf/SDFImpl.hh**:
+ ***Deprecation:*** void Root(sdf::ElementPtr)
+ ***Replacement:*** void SetRoot(sdf::ElementPtr)

## libsdformat 11.x to 12.0

An error is now emitted instead of a warning for a file containing more than
Expand Down
7 changes: 6 additions & 1 deletion include/sdf/SDFImpl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ namespace sdf

/// \brief Set the root pointer
/// \param[in] _root Root element
public: void Root(const ElementPtr _root);
public: void SetRoot(const ElementPtr _root);

/// \brief Set the root pointer
/// \param[in] _root Root element
/// \deprecated Use SetRoot
public: GZ_DEPRECATED(13) void Root(const ElementPtr _root);

/// \brief Get the path to the SDF document on disk.
/// \return The full path to the SDF document.
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.3/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element.</description>

<attribute name="version" type="string" default="1.3" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.4/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element.</description>

<attribute name="version" type="string" default="1.4" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.5/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element.</description>

<attribute name="version" type="string" default="1.5" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.6/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element that can include 0-N models, actors, lights, and/or worlds. A user of multiple worlds could run parallel instances of simulation, or offer selection of a world at runtime.</description>

<attribute name="version" type="string" default="1.6" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.7/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element that can include 0-N models, actors, lights, and/or worlds. A user of multiple worlds could run parallel instances of simulation, or offer selection of a world at runtime.</description>

<attribute name="version" type="string" default="1.7" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.8/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element that can include one model, actor, light, or worlds. A user of multiple worlds could run parallel instances of simulation, or offer selection of a world at runtime.</description>

<attribute name="version" type="string" default="1.8" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
10 changes: 9 additions & 1 deletion sdf/1.9/root.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<description>SDFormat base element that can include one model, actor, light, or worlds. A user of multiple worlds could run parallel instances of simulation, or offer selection of a world at runtime.</description>

<attribute name="version" type="string" default="1.9" required="1">
<description>Version number of the SDFormat specification.</description>
<description>
Version number of the SDFormat specification, consisting of major
and minor versions delimited by a `.` character.
A major version bump is required if older versions cannot be
automatically converted to this version.
A minor version bump is required when there are breaking changes that
can be handled by the automatic conversion functionality encoded in the
`*.convert` files.
</description>
</attribute>

<include filename="world.sdf" required="*"/>
Expand Down
8 changes: 7 additions & 1 deletion src/SDF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,17 @@ ElementPtr SDF::Root() const
}

/////////////////////////////////////////////////
void SDF::Root(const ElementPtr _root)
void SDF::SetRoot(const ElementPtr _root)
{
this->dataPtr->root = _root;
}

/////////////////////////////////////////////////
void SDF::Root(const ElementPtr _root)
{
this->SetRoot(_root);
}

/////////////////////////////////////////////////
std::string SDF::FilePath() const
{
Expand Down
21 changes: 21 additions & 0 deletions src/SDF_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <any>
#include <gz/math.hh>
#include <gz/utils/Environment.hh>
#include <gz/utils/SuppressWarning.hh>

#include "sdf/sdf.hh"

Expand Down Expand Up @@ -273,6 +274,26 @@ TEST(SDF, ElementRemoveChild)
EXPECT_FALSE(elem);
}

////////////////////////////////////////////////////
TEST(SDF, SetRoot)
{
sdf::SDF s;

sdf::ElementPtr elem;
elem.reset(new sdf::Element());
elem->AddValue("bool", "true", "0", "description");
s.SetRoot(elem);
EXPECT_EQ(elem, s.Root());

// Test deprecated setter, remove in libsdformat14
s.SetRoot(nullptr);
EXPECT_EQ(nullptr, s.Root());
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
s.Root(elem);
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
EXPECT_EQ(elem, s.Root());
}

////////////////////////////////////////////////////
/// Ensure that getting empty values with empty keys returns correct values.
TEST(SDF, EmptyValues)
Expand Down
2 changes: 1 addition & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ bool readXml(tinyxml2::XMLElement *_xml, ElementPtr _sdf,
init(includeSDFTemplate, _config);
}
SDFPtr includeSDF(new SDF);
includeSDF->Root(includeSDFTemplate->Root()->Clone());
includeSDF->SetRoot(includeSDFTemplate->Root()->Clone());

if (!readFile(filename, _config, includeSDF, _errors))
{
Expand Down
4 changes: 2 additions & 2 deletions test/integration/deprecated_specs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(DeprecatedElements, CanEmitErrors)
elem->SetRequired("-1");
elem->SetName("testElem");
// Change the root of sdf so we can test "testElem" in isolation
sdf->Root(elem);
sdf->SetRoot(elem);
auto config = sdf::ParserConfig::GlobalConfig();
config.SetWarningsPolicy(sdf::EnforcementPolicy::ERR);
sdf::Errors errors;
Expand Down Expand Up @@ -89,7 +89,7 @@ TEST(DeprecatedElements, CanEmitWarningWithErrorEnforcmentPolicy)
elem->SetRequired("-1");
elem->SetName("testElem");
// Change the root of sdf so we can test "testElem" in isolation
sdf->Root(elem);
sdf->SetRoot(elem);
{
auto config = sdf::ParserConfig::GlobalConfig();
config.SetWarningsPolicy(sdf::EnforcementPolicy::ERR);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/model/pr2.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<collision>base_footprint_geom_base_link</collision>
<topic>__default_topic__</topic>
</contact>
<plugin name='gazebo_contact' filename='libContactPlugin.so'/>
<plugin name='sim_contact' filename='libContactPlugin.so'/>
</sensor>
<sensor name='base_laser' type='ray'>
<always_on>1</always_on>
Expand Down
10 changes: 5 additions & 5 deletions usd/src/usd_parser/USDWorld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace usd

sdf::Plugin diffDrivePlugin;
diffDrivePlugin.SetName("gz::sim::systems::DiffDrive");
diffDrivePlugin.SetFilename("ignition-gazebo-diff-drive-system");
diffDrivePlugin.SetFilename("gz-sim-diff-drive-system");

std::string leftWheelName;
std::string rightWheelName;
Expand Down Expand Up @@ -408,24 +408,24 @@ namespace usd
// Add some plugins to run the Gazebo Sim simulation
sdf::Plugin physicsPlugin;
physicsPlugin.SetName("gz::sim::systems::Physics");
physicsPlugin.SetFilename("ignition-gazebo-physics-system");
physicsPlugin.SetFilename("gz-sim-physics-system");
_world.AddPlugin(physicsPlugin);

sdf::Plugin sensorsPlugin;
sensorsPlugin.SetName("gz::sim::systems::Sensors");
sensorsPlugin.SetFilename("ignition-gazebo-sensors-system");
sensorsPlugin.SetFilename("gz-sim-sensors-system");
_world.AddPlugin(sensorsPlugin);

sdf::Plugin userCommandsPlugin;
userCommandsPlugin.SetName("gz::sim::systems::UserCommands");
userCommandsPlugin.SetFilename("ignition-gazebo-user-commands-system");
userCommandsPlugin.SetFilename("gz-sim-user-commands-system");
_world.AddPlugin(userCommandsPlugin);

sdf::Plugin sceneBroadcasterPlugin;
sceneBroadcasterPlugin.SetName(
"gz::sim::systems::SceneBroadcaster");
sceneBroadcasterPlugin.SetFilename(
"ignition-gazebo-scene-broadcaster-system");
"gz-sim-scene-broadcaster-system");
_world.AddPlugin(sceneBroadcasterPlugin);
}

Expand Down
8 changes: 4 additions & 4 deletions usd/src/usd_parser/usd2sdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ TEST(check_cmd, GZ_UTILS_TEST_DISABLED_ON_WIN32(SDF))
auto plugins = world->Plugins();
EXPECT_EQ(4u, plugins.size());
EXPECT_EQ("gz::sim::systems::Physics", plugins[0].Name());
EXPECT_EQ("ignition-gazebo-physics-system", plugins[0].Filename());
EXPECT_EQ("gz-sim-physics-system", plugins[0].Filename());

EXPECT_EQ("gz::sim::systems::Sensors", plugins[1].Name());
EXPECT_EQ("ignition-gazebo-sensors-system", plugins[1].Filename());
EXPECT_EQ("gz-sim-sensors-system", plugins[1].Filename());

EXPECT_EQ("gz::sim::systems::UserCommands", plugins[2].Name());
EXPECT_EQ("ignition-gazebo-user-commands-system", plugins[2].Filename());
EXPECT_EQ("gz-sim-user-commands-system", plugins[2].Filename());

EXPECT_EQ("gz::sim::systems::SceneBroadcaster", plugins[3].Name());
EXPECT_EQ(
"ignition-gazebo-scene-broadcaster-system", plugins[3].Filename());
"gz-sim-scene-broadcaster-system", plugins[3].Filename());

// the world should have lights attached to it
std::set<std::string> savedLightNames;
Expand Down

0 comments on commit 4cbab2d

Please sign in to comment.