From 5e13b49f68e3681ea6ded9f6872424ca54de6d24 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Thu, 6 Jan 2022 16:56:49 -0700
Subject: [PATCH 01/27] make SDF to USD a separate component of sdformat
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
CMakeLists.txt | 11 +-
examples/usdConverter/README.md | 30 ++++
examples/usdConverter/shapes.sdf | 244 +++++++++++++++++++++++++++++
usd/include/CMakeLists.txt | 1 +
usd/include/sdf/CMakeLists.txt | 1 +
usd/include/sdf/usd/CMakeLists.txt | 1 +
usd/include/sdf/usd/World.hh | 42 +++++
usd/src/CMakeLists.txt | 22 +++
usd/src/World.cc | 43 +++++
usd/src/cmd/CMakeLists.txt | 20 +++
usd/src/cmd/sdf2usd.cc | 123 +++++++++++++++
11 files changed, 537 insertions(+), 1 deletion(-)
create mode 100644 examples/usdConverter/README.md
create mode 100644 examples/usdConverter/shapes.sdf
create mode 100644 usd/include/CMakeLists.txt
create mode 100644 usd/include/sdf/CMakeLists.txt
create mode 100644 usd/include/sdf/usd/CMakeLists.txt
create mode 100644 usd/include/sdf/usd/World.hh
create mode 100644 usd/src/CMakeLists.txt
create mode 100644 usd/src/World.cc
create mode 100644 usd/src/cmd/CMakeLists.txt
create mode 100644 usd/src/cmd/sdf2usd.cc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ff7e0038..0f150351c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,8 +109,17 @@ if (BUILD_SDF)
ign_find_package(ignition-utils1 VERSION REQUIRED)
set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR})
+ ########################################
+ # Find ignition common
+ ign_find_package(ignition-common4 COMPONENTS graphics REQUIRED_BY usd)
+ set(IGN_COMMON_VER ${ignition-common4_VERSION_MAJOR})
+
+ ########################################
+ # Find PXR
+ ign_find_package(pxr REQUIRED_BY usd PKGCONFIG pxr)
- ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS)
+ ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
+ COMPONENTS usd)
ign_create_packages()
add_subdirectory(sdf)
diff --git a/examples/usdConverter/README.md b/examples/usdConverter/README.md
new file mode 100644
index 000000000..323fea82c
--- /dev/null
+++ b/examples/usdConverter/README.md
@@ -0,0 +1,30 @@
+# Converting between SDF and USD
+
+This example shows how a world in a SDF file can be converted to [USD](https://graphics.pixar.com/usd/release/index.html).
+
+## Requirements
+
+You will need all of the dependencies for sdformat, along with the following additional dependencies:
+* USD: [installation instructions](https://github.com/PixarAnimationStudios/USD/blob/release/README.md#getting-and-building-the-code)
+* [ignition-common4](https://github.com/ignitionrobotics/ign-common)
+
+## Setup
+
+Build sdformat, and then run the following commands to build the example (run these commands from this example directory):
+```bash
+mkdir build
+cd build
+cmake ..
+make
+```
+
+You should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
+The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usda` (run this command from the `build` directory):
+```bash
+./sdf2usd ../shapes.sdf shapes.usda
+```
+
+You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
+```
+usdview shapes.usda
+```
diff --git a/examples/usdConverter/shapes.sdf b/examples/usdConverter/shapes.sdf
new file mode 100644
index 000000000..6935ae5d3
--- /dev/null
+++ b/examples/usdConverter/shapes.sdf
@@ -0,0 +1,244 @@
+
+
+
+
+
+ 1.0 1.0 1.0
+ 0.8 0.8 0.8
+
+
+
+ true
+ 0 0 10 0 0 0
+ 0.8 0.8 0.8 1
+ 0.2 0.2 0.2 1
+
+ 1000
+ 0.9
+ 0.01
+ 0.001
+
+ -0.5 0.1 -0.9
+
+
+
+ true
+
+
+
+
+ 0 0 1
+ 100 100
+
+
+
+
+
+
+ 0 0 1
+ 100 100
+
+
+
+ 0.8 0.8 0.8 1
+ 0.8 0.8 0.8 1
+ 0.8 0.8 0.8 1
+
+
+
+
+
+
+ 0 0 0.5 0 0 0
+
+
+
+ 0.16666
+ 0
+ 0
+ 0.16666
+ 0
+ 0.16666
+
+ 1.0
+
+
+
+
+ 1 1 1
+
+
+
+
+
+
+
+ 1 1 1
+
+
+
+ 1 0 0 1
+ 1 0 0 1
+ 1 0 0 1
+
+
+
+
+
+
+ 0 -1.5 0.5 0 0 0
+
+
+
+ 0.1458
+ 0
+ 0
+ 0.1458
+ 0
+ 0.125
+
+ 1.0
+
+
+
+
+ 0.5
+ 1.0
+
+
+
+
+
+
+
+ 0.5
+ 1.0
+
+
+
+ 0 1 0 1
+ 0 1 0 1
+ 0 1 0 1
+
+
+
+
+
+
+ 0 1.5 0.5 0 0 0
+
+
+
+ 0.1
+ 0
+ 0
+ 0.1
+ 0
+ 0.1
+
+ 1.0
+
+
+
+
+ 0.5
+
+
+
+
+
+
+
+ 0.5
+
+
+
+ 0 0 1 1
+ 0 0 1 1
+ 0 0 1 1
+
+
+
+
+
+
+ 0 -3.0 0.5 0 0 0
+
+
+
+ 0.074154
+ 0
+ 0
+ 0.074154
+ 0
+ 0.018769
+
+ 1.0
+
+
+
+
+ 0.2
+ 0.6
+
+
+
+
+
+
+ 0.2
+ 0.6
+
+
+
+ 1 1 0 1
+ 1 1 0 1
+ 1 1 0 1
+
+
+
+
+
+
+ 0 3.0 0.5 0 0 0
+
+
+
+ 0.068
+ 0
+ 0
+ 0.058
+ 0
+ 0.026
+
+ 1.0
+
+
+
+
+ 0.2 0.3 0.5
+
+
+
+
+
+
+ 0.2 0.3 0.5
+
+
+
+ 1 0 1 1
+ 1 0 1 1
+ 1 0 1 1
+
+
+
+
+
+
diff --git a/usd/include/CMakeLists.txt b/usd/include/CMakeLists.txt
new file mode 100644
index 000000000..f2909dd9d
--- /dev/null
+++ b/usd/include/CMakeLists.txt
@@ -0,0 +1 @@
+ign_install_all_headers(COMPONENT usd)
diff --git a/usd/include/sdf/CMakeLists.txt b/usd/include/sdf/CMakeLists.txt
new file mode 100644
index 000000000..f2909dd9d
--- /dev/null
+++ b/usd/include/sdf/CMakeLists.txt
@@ -0,0 +1 @@
+ign_install_all_headers(COMPONENT usd)
diff --git a/usd/include/sdf/usd/CMakeLists.txt b/usd/include/sdf/usd/CMakeLists.txt
new file mode 100644
index 000000000..f2909dd9d
--- /dev/null
+++ b/usd/include/sdf/usd/CMakeLists.txt
@@ -0,0 +1 @@
+ign_install_all_headers(COMPONENT usd)
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/World.hh
new file mode 100644
index 000000000..7bc763551
--- /dev/null
+++ b/usd/include/sdf/usd/World.hh
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2022 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#ifndef SDF_USD_WORLD_HH_
+#define SDF_USD_WORLD_HH_
+
+#include
+
+#include
+
+#include "sdf/World.hh"
+#include "sdf/sdf_config.h"
+
+namespace usd
+{
+ /// \brief Parse an SDF world into a USD stage.
+ /// \param[in] _world The SDF world to parse.
+ /// \param[in] _stage The stage that should contain the USD representation
+ /// of _world.
+ /// \param[in] _path The USD path of the parsed world in _stage, which must be
+ /// a valid USD path.
+ /// \return True if _world was succesfully parsed into _stage with a path of
+ /// _path. False otherwise.
+ bool SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
+ pxr::UsdStageRefPtr &_stage, const std::string &_path);
+}
+
+#endif
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
new file mode 100644
index 000000000..b447ccd8a
--- /dev/null
+++ b/usd/src/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Collect source files into the "sources" variable and unit test files into the
+# "gtest_sources" variable.
+ign_get_libsources_and_unittests(sources gtest_sources)
+
+ign_add_component(usd SOURCES ${sources} GET_TARGET_NAME usd_target)
+
+target_include_directories(${usd_target}
+ PUBLIC
+ ${PXR_INCLUDE_DIRS}
+)
+
+target_link_libraries(${usd_target}
+ PUBLIC
+ ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
+ ignition-common${IGN_COMMON_VER}::graphics
+ ${PXR_LIBRARIES}
+)
+
+# Build the unit tests
+ign_build_tests(TYPE UNIT SOURCES ${gtest_sources} LIB_DEPS ${usd_target})
+
+add_subdirectory(cmd)
diff --git a/usd/src/World.cc b/usd/src/World.cc
new file mode 100644
index 000000000..2f56bf442
--- /dev/null
+++ b/usd/src/World.cc
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include "sdf/usd/World.hh"
+
+#include
+#include
+
+#include
+#include
+#include
+
+namespace usd
+{
+ bool ParseSdfWorld(const sdf::World &_world, pxr::UsdStageRefPtr &_stage,
+ const std::string &_path)
+ {
+ _stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::UsdGeomTokens->z);
+ _stage->SetEndTimeCode(100);
+ _stage->SetMetadata(pxr::TfToken("metersPerUnit"), 1.0);
+ _stage->SetStartTimeCode(0);
+ _stage->SetTimeCodesPerSecond(24);
+
+ // TODO(ahcorde) Add parser
+ std::cerr << "Parser is not yet implemented" << '\n';
+
+ return true;
+ }
+}
diff --git a/usd/src/cmd/CMakeLists.txt b/usd/src/cmd/CMakeLists.txt
new file mode 100644
index 000000000..3fa27abc5
--- /dev/null
+++ b/usd/src/cmd/CMakeLists.txt
@@ -0,0 +1,20 @@
+if(TARGET ${usd_target})
+ add_executable(sdf2usd
+ sdf2usd.cc
+ )
+
+ target_link_libraries(sdf2usd
+ PUBLIC
+ ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER}
+ ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
+ ignition-common${IGN_COMMON_VER}::graphics
+ ${usd_target}
+ )
+
+ install(
+ TARGETS
+ sdf2usd
+ DESTINATION
+ ${BIN_INSTALL_DIR}
+ )
+endif()
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
new file mode 100644
index 000000000..ab2be27ed
--- /dev/null
+++ b/usd/src/cmd/sdf2usd.cc
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2022 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include
+
+#include
+#include
+
+#include "sdf/sdf.hh"
+#include "sdf/usd/World.hh"
+
+//////////////////////////////////////////////////
+/// \brief Enumeration of available commands
+enum class Command
+{
+ kNone,
+};
+
+//////////////////////////////////////////////////
+/// \brief Structure to hold all available topic options
+struct Options
+{
+ /// \brief Command to execute
+ Command command{Command::kNone};
+
+ /// \brief input filename
+ std::string inputFilename{"input.sdf"};
+
+ /// \brief output filename
+ std::string outputFilename{"output.sdf"};
+};
+
+void runCommand(const Options &_opt)
+{
+ sdf::Root root;
+ auto errors = root.Load(_opt.inputFilename);
+ if (!errors.empty())
+ {
+ std::cerr << "Errors encountered:\n";
+ for (const auto &e : errors)
+ std::cout << e << "\n";
+ exit(-2);
+ }
+
+ // only support SDF files with exactly 1 world for now
+ if (root.WorldCount() != 1u)
+ {
+ std::cerr << _opt.inputFilename << " does not have exactly 1 world\n";
+ exit(-3);
+ }
+
+ auto world = root.WorldByIndex(0u);
+ if (!world)
+ {
+ std::cerr << "Error retrieving the world from "
+ << _opt.inputFilename << "\n";
+ exit(-4);
+ }
+
+ auto stage = pxr::UsdStage::CreateInMemory();
+
+ const auto worldPath = std::string("/" + world->Name());
+ if (!usd::ParseSdfWorld(*world, stage, worldPath))
+ {
+ std::cerr << "Error parsing world [" << world->Name() << "]\n";
+ exit(-5);
+ }
+
+ if (!stage->GetRootLayer()->Export(_opt.outputFilename))
+ {
+ std::cerr << "Issue saving USD to " << _opt.outputFilename << "\n";
+ exit(-6);
+ }
+}
+
+void addFlags(CLI::App &_app)
+{
+ auto opt = std::make_shared();
+
+ _app.add_option("-i,--input",
+ opt->inputFilename,
+ "Input filename");
+
+ _app.add_option("-o,--output",
+ opt->outputFilename,
+ "Output filename");
+
+ _app.callback([&_app, opt](){
+ runCommand(*opt);
+ });
+}
+
+//////////////////////////////////////////////////
+int main(int argc, char** argv)
+{
+ CLI::App app{"Sdf format converter"};
+
+ app.set_help_all_flag("--help-all", "Show all help");
+
+ app.add_flag_callback("--version", [](){
+ std::cout << strdup(SDF_VERSION_FULL) << std::endl;
+ throw CLI::Success();
+ });
+
+ addFlags(app);
+ CLI11_PARSE(app, argc, argv);
+
+ return 0;
+}
From fa4568b4c553a2575ab9228e9795ce93bc18bb57 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Fri, 7 Jan 2022 12:55:31 +0100
Subject: [PATCH 02/27] Added ignition-common4 as a dependency
Signed-off-by: ahcorde
---
.github/ci/packages.apt | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt
index 2ea67b09f..4107d6953 100644
--- a/.github/ci/packages.apt
+++ b/.github/ci/packages.apt
@@ -1,3 +1,4 @@
+libignition-common4-dev
libignition-cmake2-dev
libignition-math6-dev
libignition-tools-dev
From 18f3ac1f062668043c9517be539237c4bd3dff67 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Mon, 10 Jan 2022 15:11:52 -0700
Subject: [PATCH 03/27] create world prim and add physics information
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
usd/src/World.cc | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/usd/src/World.cc b/usd/src/World.cc
index 2f56bf442..6dd03ee71 100644
--- a/usd/src/World.cc
+++ b/usd/src/World.cc
@@ -21,8 +21,13 @@
#include
#include
+#include
+#include
#include
#include
+#include
+
+#include "sdf/World.hh"
namespace usd
{
@@ -35,8 +40,20 @@ namespace usd
_stage->SetStartTimeCode(0);
_stage->SetTimeCodesPerSecond(24);
+ const pxr::SdfPath worldPrimPath(_path);
+ auto usdWorldPrim = _stage->DefinePrim(worldPrimPath);
+
+ auto usdPhysics = pxr::UsdPhysicsScene::Define(_stage,
+ pxr::SdfPath(_path + "/physics"));
+ const auto &sdfWorldGravity = _world.Gravity();
+ const auto normalizedGravity = sdfWorldGravity.Normalized();
+ usdPhysics.CreateGravityDirectionAttr().Set(pxr::GfVec3f(
+ normalizedGravity.X(), normalizedGravity.Y(), normalizedGravity.Z()));
+ usdPhysics.CreateGravityMagnitudeAttr().Set(
+ static_cast(sdfWorldGravity.Length()));
+
// TODO(ahcorde) Add parser
- std::cerr << "Parser is not yet implemented" << '\n';
+ std::cerr << "Parser for a sdf world is not yet implemented\n";
return true;
}
From 3bbd6eaf17029e8cd3029fd12ce7477703c16919 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Mon, 10 Jan 2022 17:34:43 -0700
Subject: [PATCH 04/27] add unit test for world conversion
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
test/test_utils.hh | 21 +++++++++
usd/src/CMakeLists.txt | 7 ++-
usd/src/World.cc | 4 +-
usd/src/World_Sdf2Usd_TEST.cc | 87 +++++++++++++++++++++++++++++++++++
4 files changed, 117 insertions(+), 2 deletions(-)
create mode 100644 usd/src/World_Sdf2Usd_TEST.cc
diff --git a/test/test_utils.hh b/test/test_utils.hh
index 150f70b60..e52599dad 100644
--- a/test/test_utils.hh
+++ b/test/test_utils.hh
@@ -18,7 +18,9 @@
#define SDF_TEST_UTILS_HH_
#include
+#include
#include "sdf/Console.hh"
+#include "sdf/Root.hh"
namespace sdf
{
@@ -104,6 +106,25 @@ class RedirectConsoleStream
private: sdf::Console::ConsoleStream oldStream;
};
+/// \brief Load an SDF file into a sdf::Root object
+/// \param[in] _fileName The name of the file to load
+/// \param[in] _root The sdf::Root object to load the file into
+/// \return True if a file named _fileName was successfully loaded into
+/// _root. False otherwise
+bool LoadSdfFile(const std::string &_fileName, sdf::Root &_root)
+{
+ auto errors = _root.Load(_fileName);
+ if (!errors.empty())
+ {
+ std::cerr << "Errors encountered:\n";
+ for (const auto &e : errors)
+ std::cerr << e << "\n";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace testing
} // namespace sdf
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
index b447ccd8a..4b8de3a34 100644
--- a/usd/src/CMakeLists.txt
+++ b/usd/src/CMakeLists.txt
@@ -17,6 +17,11 @@ target_link_libraries(${usd_target}
)
# Build the unit tests
-ign_build_tests(TYPE UNIT SOURCES ${gtest_sources} LIB_DEPS ${usd_target})
+ign_build_tests(
+ TYPE UNIT
+ SOURCES ${gtest_sources}
+ LIB_DEPS ${usd_target}
+ INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
+)
add_subdirectory(cmd)
diff --git a/usd/src/World.cc b/usd/src/World.cc
index 6dd03ee71..e8ae2b2bf 100644
--- a/usd/src/World.cc
+++ b/usd/src/World.cc
@@ -53,7 +53,9 @@ namespace usd
static_cast(sdfWorldGravity.Length()));
// TODO(ahcorde) Add parser
- std::cerr << "Parser for a sdf world is not yet implemented\n";
+ std::cerr << "Parser for a sdf world only parses physics information at "
+ << "the moment. Models and lights that are children of the world "
+ << "are currently being ignored.\n";
return true;
}
diff --git a/usd/src/World_Sdf2Usd_TEST.cc b/usd/src/World_Sdf2Usd_TEST.cc
new file mode 100644
index 000000000..2c52c26ad
--- /dev/null
+++ b/usd/src/World_Sdf2Usd_TEST.cc
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2022 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "sdf/usd/World.hh"
+#include "sdf/Root.hh"
+#include "test_config.h"
+#include "test_utils.hh"
+
+/////////////////////////////////////////////////
+// Fixture that creates a USD stage for each test case.
+class UsdStageFixture : public::testing::Test
+{
+ public: UsdStageFixture() = default;
+
+ protected: void SetUp() override
+ {
+ this->stage = pxr::UsdStage::CreateInMemory();
+ ASSERT_TRUE(this->stage);
+ }
+
+ public: pxr::UsdStageRefPtr stage;
+};
+
+/////////////////////////////////////////////////
+TEST_F(UsdStageFixture, World)
+{
+ const auto path = sdf::testing::TestFile("sdf", "empty.sdf");
+ sdf::Root root;
+
+ ASSERT_TRUE(sdf::testing::LoadSdfFile(path, root));
+ ASSERT_EQ(1u, root.WorldCount());
+ auto world = root.WorldByIndex(0u);
+
+ const auto worldPath = std::string("/" + world->Name());
+ EXPECT_TRUE(usd::ParseSdfWorld(*world, this->stage, worldPath));
+
+ // check top-level stage information
+ EXPECT_DOUBLE_EQ(100.0, this->stage->GetEndTimeCode());
+ EXPECT_DOUBLE_EQ(0.0, this->stage->GetStartTimeCode());
+ EXPECT_DOUBLE_EQ(24.0, this->stage->GetTimeCodesPerSecond());
+ pxr::TfToken upAxisVal;
+ EXPECT_TRUE(this->stage->GetMetadata(pxr::UsdGeomTokens->upAxis, &upAxisVal));
+ EXPECT_EQ(pxr::UsdGeomTokens->z, upAxisVal);
+ double metersPerUnitVal;
+ EXPECT_TRUE(this->stage->GetMetadata(pxr::TfToken("metersPerUnit"),
+ &metersPerUnitVal));
+ EXPECT_DOUBLE_EQ(1.0, metersPerUnitVal);
+
+ // Check that world prim exists, and that things like physics information
+ // were parsed correctly
+ auto worldPrim = this->stage->GetPrimAtPath(pxr::SdfPath(worldPath));
+ ASSERT_TRUE(worldPrim);
+ auto physicsScene = pxr::UsdPhysicsScene::Get(this->stage,
+ pxr::SdfPath(worldPath + "/physics"));
+ ASSERT_TRUE(physicsScene);
+ pxr::GfVec3f gravityDirectionVal;
+ EXPECT_TRUE(physicsScene.GetGravityDirectionAttr().Get(&gravityDirectionVal));
+ EXPECT_EQ(gravityDirectionVal, pxr::GfVec3f(0, 0, -1));
+ float gravityMagnitudeVal;
+ EXPECT_TRUE(physicsScene.GetGravityMagnitudeAttr().Get(&gravityMagnitudeVal));
+ EXPECT_FLOAT_EQ(gravityMagnitudeVal, 9.8f);
+}
From 16e0789bd4c4d56525d06fe273fc865a4c0bc61a Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Tue, 11 Jan 2022 15:33:26 +0100
Subject: [PATCH 05/27] Added ci to compile with USD
Signed-off-by: ahcorde
---
.github/ci/before_cmake.sh | 58 ++++++++++++++++++++++++++++++++++++++
.github/ci/packages.apt | 1 +
.github/workflows/ci.yml | 10 +++++++
3 files changed, 69 insertions(+)
create mode 100644 .github/ci/before_cmake.sh
diff --git a/.github/ci/before_cmake.sh b/.github/ci/before_cmake.sh
new file mode 100644
index 000000000..a0e23f85c
--- /dev/null
+++ b/.github/ci/before_cmake.sh
@@ -0,0 +1,58 @@
+#!/bin/sh -l
+
+set -x
+
+BUILD_DIR=`pwd`
+
+cd /tmp
+
+# check that we can compile USD from sources
+mkdir cmake_test
+cd cmake_test
+
+echo "cmake_minimum_required(VERSION 3.12)" > CMakeLists.txt
+
+return_code=0
+cmake . || return_code=$(($return_code + $?))
+if [ $return_code -eq 0 ]
+then
+ # compile USD from sources
+ cd /tmp
+ mkdir usd_binaries
+ cd usd_binaries
+
+ apt-get install libboost-all-dev libtbb-dev p7zip-full -y
+
+ wget https://github.com/PixarAnimationStudios/USD/archive/refs/tags/v21.11.zip
+ unzip v21.11.zip
+ sed -i '2059 i \ \ \ \ requiredDependencies.remove(BOOST)' USD-21.11/build_scripts/build_usd.py
+ cd USD-21.11
+ mkdir build
+ cd build
+
+ cmake -DCMAKE_INSTALL_PREFIX="/tmp/USD" -DCMAKE_PREFIX_PATH="/tmp/USD" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DPXR_PREFER_SAFETY_OVER_SPEED=ON \
+ -DPXR_ENABLE_PYTHON_SUPPORT=OFF \
+ -DBUILD_SHARED_LIBS=ON \
+ -DTBB_USE_DEBUG_BUILD=OFF \
+ -DPXR_BUILD_DOCUMENTATION=OFF \
+ -DPXR_BUILD_TESTS=OFF \
+ -DPXR_BUILD_EXAMPLES=OFF \
+ -DPXR_BUILD_TUTORIALS=OFF \
+ -DPXR_BUILD_USD_TOOLS=OFF \
+ -DPXR_BUILD_IMAGING=OFF \
+ -DPXR_BUILD_USD_IMAGING=OFF \
+ -DPXR_BUILD_USDVIEW=OFF \
+ -DPXR_BUILD_ALEMBIC_PLUGIN=OFF \
+ -DPXR_BUILD_DRACO_PLUGIN=OFF \
+ -DPXR_ENABLE_MATERIALX_SUPPORT=OFF \
+ -DBoost_NO_BOOST_CMAKE=On \
+ -DBoost_INCLUDE_DIR=/usr/include \
+ -DBoost_NO_BOOST_CMAKE=FALSE \
+ ..
+
+ make -j$(nproc) install
+fi
+
+cd $BUILD_DIR
diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt
index 4107d6953..e39a4b6eb 100644
--- a/.github/ci/packages.apt
+++ b/.github/ci/packages.apt
@@ -3,6 +3,7 @@ libignition-cmake2-dev
libignition-math6-dev
libignition-tools-dev
libignition-utils1-dev
+libignition-utils1-cli-dev
libtinyxml2-dev
liburdfdom-dev
libxml2-utils
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2914eb5d5..613c0531d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,6 +7,11 @@ jobs:
runs-on: ubuntu-latest
name: Ubuntu Bionic CI
steps:
+ - name: Set env
+ run: |
+ export PATH=$PATH:/tmp/usd_binaries/bin
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/usd_binaries/lib
+ export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/tmp/usd_binaries
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
@@ -18,6 +23,11 @@ jobs:
runs-on: ubuntu-latest
name: Ubuntu Focal CI
steps:
+ - name: Set env
+ run: |
+ echo "PATH=$PATH:/tmp/USD/bin" >> $GITHUB_ENV
+ echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/USD/lib" >> $GITHUB_ENV
+ echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/tmp/USD" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
From ae3ee43b017e13bcc09cb671b00cfb3358c28bab Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 17 Jan 2022 13:26:38 +0100
Subject: [PATCH 06/27] Added feedback
Signed-off-by: ahcorde
---
usd/include/CMakeLists.txt | 2 +-
usd/include/sdf/usd/World.hh | 6 ++++--
usd/src/CMakeLists.txt | 1 -
usd/src/World.cc | 8 ++++++--
usd/src/World_Sdf2Usd_TEST.cc | 6 +++++-
usd/src/cmd/sdf2usd.cc | 8 ++++++--
6 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/usd/include/CMakeLists.txt b/usd/include/CMakeLists.txt
index f2909dd9d..9c28e4b11 100644
--- a/usd/include/CMakeLists.txt
+++ b/usd/include/CMakeLists.txt
@@ -1 +1 @@
-ign_install_all_headers(COMPONENT usd)
+add_subdirectory(sdf/usd)
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/World.hh
index 7bc763551..605831ad2 100644
--- a/usd/include/sdf/usd/World.hh
+++ b/usd/include/sdf/usd/World.hh
@@ -20,10 +20,12 @@
#include
+#pragma push_macro ("__DEPRECATED")
+#undef __DEPRECATED
#include
+#pragma pop_macro ("__DEPRECATED")
#include "sdf/World.hh"
-#include "sdf/sdf_config.h"
namespace usd
{
@@ -35,7 +37,7 @@ namespace usd
/// a valid USD path.
/// \return True if _world was succesfully parsed into _stage with a path of
/// _path. False otherwise.
- bool SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
+ sdf::Errors SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
pxr::UsdStageRefPtr &_stage, const std::string &_path);
}
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
index 4b8de3a34..e1d24493d 100644
--- a/usd/src/CMakeLists.txt
+++ b/usd/src/CMakeLists.txt
@@ -12,7 +12,6 @@ target_include_directories(${usd_target}
target_link_libraries(${usd_target}
PUBLIC
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
- ignition-common${IGN_COMMON_VER}::graphics
${PXR_LIBRARIES}
)
diff --git a/usd/src/World.cc b/usd/src/World.cc
index e8ae2b2bf..226fb97c9 100644
--- a/usd/src/World.cc
+++ b/usd/src/World.cc
@@ -23,7 +23,10 @@
#include
#include
#include
+#pragma push_macro ("__DEPRECATED")
+#undef __DEPRECATED
#include
+#pragma pop_macro ("__DEPRECATED")
#include
#include
@@ -31,9 +34,10 @@
namespace usd
{
- bool ParseSdfWorld(const sdf::World &_world, pxr::UsdStageRefPtr &_stage,
+ sdf::Errors ParseSdfWorld(const sdf::World &_world, pxr::UsdStageRefPtr &_stage,
const std::string &_path)
{
+ sdf::Errors errors;
_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::UsdGeomTokens->z);
_stage->SetEndTimeCode(100);
_stage->SetMetadata(pxr::TfToken("metersPerUnit"), 1.0);
@@ -57,6 +61,6 @@ namespace usd
<< "the moment. Models and lights that are children of the world "
<< "are currently being ignored.\n";
- return true;
+ return errors;
}
}
diff --git a/usd/src/World_Sdf2Usd_TEST.cc b/usd/src/World_Sdf2Usd_TEST.cc
index 2c52c26ad..a781d3c8c 100644
--- a/usd/src/World_Sdf2Usd_TEST.cc
+++ b/usd/src/World_Sdf2Usd_TEST.cc
@@ -18,6 +18,8 @@
#include
#include
+#pragma push_macro ("__DEPRECATED")
+#undef __DEPRECATED
#include
#include
#include
@@ -25,6 +27,7 @@
#include
#include
#include
+#pragma pop_macro ("__DEPRECATED")
#include "sdf/usd/World.hh"
#include "sdf/Root.hh"
@@ -57,7 +60,8 @@ TEST_F(UsdStageFixture, World)
auto world = root.WorldByIndex(0u);
const auto worldPath = std::string("/" + world->Name());
- EXPECT_TRUE(usd::ParseSdfWorld(*world, this->stage, worldPath));
+ auto usdErrors = usd::ParseSdfWorld(*world, stage, worldPath);
+ EXPECT_TRUE(usdErrors.empty());
// check top-level stage information
EXPECT_DOUBLE_EQ(100.0, this->stage->GetEndTimeCode());
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
index ab2be27ed..b0999d44e 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/cmd/sdf2usd.cc
@@ -18,7 +18,10 @@
#include
#include
+#pragma push_macro ("__DEPRECATED")
+#undef __DEPRECATED
#include
+#pragma pop_macro ("__DEPRECATED")
#include "sdf/sdf.hh"
#include "sdf/usd/World.hh"
@@ -74,7 +77,8 @@ void runCommand(const Options &_opt)
auto stage = pxr::UsdStage::CreateInMemory();
const auto worldPath = std::string("/" + world->Name());
- if (!usd::ParseSdfWorld(*world, stage, worldPath))
+ auto usdErrors = usd::ParseSdfWorld(*world, stage, worldPath);
+ if (usdErrors.empty())
{
std::cerr << "Error parsing world [" << world->Name() << "]\n";
exit(-5);
@@ -112,7 +116,7 @@ int main(int argc, char** argv)
app.set_help_all_flag("--help-all", "Show all help");
app.add_flag_callback("--version", [](){
- std::cout << strdup(SDF_VERSION_FULL) << std::endl;
+ std::cout << SDF_VERSION_FULL << std::endl;
throw CLI::Success();
});
From 36d42fcfbd49350b371239f2f4a737ec262d6b6c Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 17 Jan 2022 13:32:14 +0100
Subject: [PATCH 07/27] improved doc
Signed-off-by: ahcorde
---
usd/include/sdf/usd/World.hh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/World.hh
index 605831ad2..e2cc94272 100644
--- a/usd/include/sdf/usd/World.hh
+++ b/usd/include/sdf/usd/World.hh
@@ -25,6 +25,8 @@
#include
#pragma pop_macro ("__DEPRECATED")
+#include "sdf/sdf_config.h"
+#include "sdf/system_util.hh"
#include "sdf/World.hh"
namespace usd
@@ -32,11 +34,11 @@ namespace usd
/// \brief Parse an SDF world into a USD stage.
/// \param[in] _world The SDF world to parse.
/// \param[in] _stage The stage that should contain the USD representation
- /// of _world.
+ /// of _world. It must be initialized first
/// \param[in] _path The USD path of the parsed world in _stage, which must be
/// a valid USD path.
- /// \return True if _world was succesfully parsed into _stage with a path of
- /// _path. False otherwise.
+ /// \return Errors, which is a vector of Error objects. Each Error includes
+ /// an error code and message. An empty vector indicates no error.
sdf::Errors SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
pxr::UsdStageRefPtr &_stage, const std::string &_path);
}
From 45457236160a17e7f632d337ce0e9de4f91e2147 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Tue, 18 Jan 2022 12:26:29 -0700
Subject: [PATCH 08/27] update CMake code
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
CMakeLists.txt | 2 +-
usd/include/sdf/CMakeLists.txt | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
delete mode 100644 usd/include/sdf/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f150351c..27604fe92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -116,7 +116,7 @@ if (BUILD_SDF)
########################################
# Find PXR
- ign_find_package(pxr REQUIRED_BY usd PKGCONFIG pxr)
+ ign_find_package(pxr QUIET REQUIRED_BY usd PKGCONFIG pxr)
ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
COMPONENTS usd)
diff --git a/usd/include/sdf/CMakeLists.txt b/usd/include/sdf/CMakeLists.txt
deleted file mode 100644
index f2909dd9d..000000000
--- a/usd/include/sdf/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-ign_install_all_headers(COMPONENT usd)
From 91629c07da112face018cf167d567dd2f6a86020 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 11:09:31 +0100
Subject: [PATCH 09/27] included namespaces
Signed-off-by: ahcorde
---
usd/include/sdf/usd/World.hh | 29 ++++++++++++++++++-----------
usd/src/World.cc | 7 +++++++
usd/src/World_Sdf2Usd_TEST.cc | 2 +-
usd/src/cmd/sdf2usd.cc | 2 +-
4 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/World.hh
index e2cc94272..6ea54ab6a 100644
--- a/usd/include/sdf/usd/World.hh
+++ b/usd/include/sdf/usd/World.hh
@@ -29,18 +29,25 @@
#include "sdf/system_util.hh"
#include "sdf/World.hh"
-namespace usd
+namespace sdf
{
- /// \brief Parse an SDF world into a USD stage.
- /// \param[in] _world The SDF world to parse.
- /// \param[in] _stage The stage that should contain the USD representation
- /// of _world. It must be initialized first
- /// \param[in] _path The USD path of the parsed world in _stage, which must be
- /// a valid USD path.
- /// \return Errors, which is a vector of Error objects. Each Error includes
- /// an error code and message. An empty vector indicates no error.
- sdf::Errors SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
- pxr::UsdStageRefPtr &_stage, const std::string &_path);
+ // Inline bracke to help doxygen filtering.
+ inline namespace SDF_VERSION_NAMESPACE {
+ //
+ namespace usd
+ {
+ /// \brief Parse an SDF world into a USD stage.
+ /// \param[in] _world The SDF world to parse.
+ /// \param[in] _stage The stage that should contain the USD representation
+ /// of _world. It must be initialized first
+ /// \param[in] _path The USD path of the parsed world in _stage, which must be
+ /// a valid USD path.
+ /// \return Errors, which is a vector of Error objects. Each Error includes
+ /// an error code and message. An empty vector indicates no error.
+ sdf::Errors SDFORMAT_VISIBLE ParseSdfWorld(const sdf::World &_world,
+ pxr::UsdStageRefPtr &_stage, const std::string &_path);
+ }
+ }
}
#endif
diff --git a/usd/src/World.cc b/usd/src/World.cc
index 226fb97c9..32859f9a9 100644
--- a/usd/src/World.cc
+++ b/usd/src/World.cc
@@ -32,6 +32,11 @@
#include "sdf/World.hh"
+namespace sdf
+{
+// Inline bracke to help doxygen filtering.
+inline namespace SDF_VERSION_NAMESPACE {
+//
namespace usd
{
sdf::Errors ParseSdfWorld(const sdf::World &_world, pxr::UsdStageRefPtr &_stage,
@@ -64,3 +69,5 @@ namespace usd
return errors;
}
}
+}
+}
diff --git a/usd/src/World_Sdf2Usd_TEST.cc b/usd/src/World_Sdf2Usd_TEST.cc
index a781d3c8c..0883cd8af 100644
--- a/usd/src/World_Sdf2Usd_TEST.cc
+++ b/usd/src/World_Sdf2Usd_TEST.cc
@@ -60,7 +60,7 @@ TEST_F(UsdStageFixture, World)
auto world = root.WorldByIndex(0u);
const auto worldPath = std::string("/" + world->Name());
- auto usdErrors = usd::ParseSdfWorld(*world, stage, worldPath);
+ auto usdErrors = sdf::usd::ParseSdfWorld(*world, stage, worldPath);
EXPECT_TRUE(usdErrors.empty());
// check top-level stage information
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
index b0999d44e..2411b3d8b 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/cmd/sdf2usd.cc
@@ -77,7 +77,7 @@ void runCommand(const Options &_opt)
auto stage = pxr::UsdStage::CreateInMemory();
const auto worldPath = std::string("/" + world->Name());
- auto usdErrors = usd::ParseSdfWorld(*world, stage, worldPath);
+ auto usdErrors = sdf::usd::ParseSdfWorld(*world, stage, worldPath);
if (usdErrors.empty())
{
std::cerr << "Error parsing world [" << world->Name() << "]\n";
From 63479536baaa2354bee69f4281795db88d2c058e Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 12:23:32 +0100
Subject: [PATCH 10/27] Added basic test to sdf2usd cmd
Signed-off-by: ahcorde
---
usd/src/CMakeLists.txt | 2 +-
usd/src/sdf2usd_TEST.cc | 86 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
create mode 100644 usd/src/sdf2usd_TEST.cc
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
index e1d24493d..554092755 100644
--- a/usd/src/CMakeLists.txt
+++ b/usd/src/CMakeLists.txt
@@ -19,7 +19,7 @@ target_link_libraries(${usd_target}
ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
- LIB_DEPS ${usd_target}
+ LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
)
diff --git a/usd/src/sdf2usd_TEST.cc b/usd/src/sdf2usd_TEST.cc
new file mode 100644
index 000000000..b5e4c79f3
--- /dev/null
+++ b/usd/src/sdf2usd_TEST.cc
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2022 Open Source Robotics Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+#include
+
+#include
+
+#include
+#include
+
+#include "test_config.h"
+#include "test_utils.hh"
+
+#ifdef _WIN32
+ #define popen _popen
+ #define pclose _pclose
+#endif
+
+static std::string sdf2usdCommand()
+{
+ return std::string(IGN_PATH) + "/sdf2usd";
+}
+
+/////////////////////////////////////////////////
+std::string custom_exec_str(std::string _cmd)
+{
+ _cmd += " 2>&1";
+ FILE *pipe = popen(_cmd.c_str(), "r");
+
+ if (!pipe)
+ return "ERROR";
+
+ char buffer[128];
+ std::string result = "";
+
+ while (!feof(pipe))
+ {
+ if (fgets(buffer, 128, pipe) != NULL)
+ result += buffer;
+ }
+
+ pclose(pipe);
+ return result;
+}
+
+/////////////////////////////////////////////////
+TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
+{
+ std::string pathBase = PROJECT_SOURCE_PATH;
+ pathBase = ignition::common::joinPaths(pathBase, "test", "sdf");
+
+ auto tmpDir = ignition::common::tempDirectoryPath();
+ auto tmp = ignition::common::createTempDirectory("usd", tmpDir);
+ std::cerr << "tmp " << tmp << '\n';
+ // Check a good SDF file
+ {
+ std::string path = ignition::common::joinPaths(pathBase,
+ "/shapes_world.sdf");
+
+ std::string output =
+ custom_exec_str(sdf2usdCommand() + " -i " + path + " -o " +
+ ignition::common::joinPaths(tmp, "shapes.usd"));
+ // TODO(ahcorde): Check the output when the parser is implemented
+ }
+}
+
+/////////////////////////////////////////////////
+/// Main
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
From bb6ee5afa110981845b3c4839355fddd6a9cbbf5 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 12:43:22 +0100
Subject: [PATCH 11/27] changes in sdf2usd
Signed-off-by: ahcorde
---
examples/usdConverter/README.md | 8 ++++----
usd/src/cmd/sdf2usd.cc | 6 +++---
usd/src/sdf2usd_TEST.cc | 4 +---
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/examples/usdConverter/README.md b/examples/usdConverter/README.md
index 323fea82c..f72cb69cc 100644
--- a/examples/usdConverter/README.md
+++ b/examples/usdConverter/README.md
@@ -19,12 +19,12 @@ make
```
You should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
-The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usda` (run this command from the `build` directory):
+The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usd` (run this command from the `build` directory):
```bash
-./sdf2usd ../shapes.sdf shapes.usda
+./sdf2usd ../shapes.sdf shapes.usd
```
You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
-```
-usdview shapes.usda
+```bash
+usdview shapes.usd
```
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
index 2411b3d8b..9b5854298 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/cmd/sdf2usd.cc
@@ -44,7 +44,7 @@ struct Options
std::string inputFilename{"input.sdf"};
/// \brief output filename
- std::string outputFilename{"output.sdf"};
+ std::string outputFilename{"output.usd"};
};
void runCommand(const Options &_opt)
@@ -95,11 +95,11 @@ void addFlags(CLI::App &_app)
{
auto opt = std::make_shared();
- _app.add_option("-i,--input",
+ _app.add_option("input",
opt->inputFilename,
"Input filename");
- _app.add_option("-o,--output",
+ _app.add_option("output",
opt->outputFilename,
"Output filename");
diff --git a/usd/src/sdf2usd_TEST.cc b/usd/src/sdf2usd_TEST.cc
index b5e4c79f3..b929b1f86 100644
--- a/usd/src/sdf2usd_TEST.cc
+++ b/usd/src/sdf2usd_TEST.cc
@@ -64,14 +64,12 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
auto tmpDir = ignition::common::tempDirectoryPath();
auto tmp = ignition::common::createTempDirectory("usd", tmpDir);
- std::cerr << "tmp " << tmp << '\n';
// Check a good SDF file
{
std::string path = ignition::common::joinPaths(pathBase,
"/shapes_world.sdf");
-
std::string output =
- custom_exec_str(sdf2usdCommand() + " -i " + path + " -o " +
+ custom_exec_str(sdf2usdCommand() + " " + path + " " +
ignition::common::joinPaths(tmp, "shapes.usd"));
// TODO(ahcorde): Check the output when the parser is implemented
}
From d1d7af6324dc52392cc561ef9addf8bbdb835a95 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 12:52:47 +0100
Subject: [PATCH 12/27] Fixed usd tutorial
Signed-off-by: ahcorde
---
examples/usdConverter/README.md | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/examples/usdConverter/README.md b/examples/usdConverter/README.md
index f72cb69cc..3690b4c5f 100644
--- a/examples/usdConverter/README.md
+++ b/examples/usdConverter/README.md
@@ -10,18 +10,11 @@ You will need all of the dependencies for sdformat, along with the following add
## Setup
-Build sdformat, and then run the following commands to build the example (run these commands from this example directory):
-```bash
-mkdir build
-cd build
-cmake ..
-make
-```
+Build sdformat, you should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
+The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usd`:
-You should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
-The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usd` (run this command from the `build` directory):
```bash
-./sdf2usd ../shapes.sdf shapes.usd
+sdf2usd ../shapes.sdf shapes.usd
```
You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
From bab9e374a703af03e6b7c726481b5f13a3ab9912 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 14:22:07 +0100
Subject: [PATCH 13/27] Removed unneeded CMakeLists.txt
Signed-off-by: ahcorde
---
usd/include/CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 usd/include/CMakeLists.txt
diff --git a/usd/include/CMakeLists.txt b/usd/include/CMakeLists.txt
deleted file mode 100644
index 9c28e4b11..000000000
--- a/usd/include/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(sdf/usd)
From cbdfa49eb4bb0c2eb0a94c99449987febe96dd81 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 20:41:23 +0100
Subject: [PATCH 14/27] Moved CMakeLists.txt
Signed-off-by: ahcorde
---
usd/include/sdf/{usd => }/CMakeLists.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename usd/include/sdf/{usd => }/CMakeLists.txt (100%)
diff --git a/usd/include/sdf/usd/CMakeLists.txt b/usd/include/sdf/CMakeLists.txt
similarity index 100%
rename from usd/include/sdf/usd/CMakeLists.txt
rename to usd/include/sdf/CMakeLists.txt
From 99fb1702b9bf0a3ed9ecb378d7006497add40b04 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Wed, 19 Jan 2022 13:53:24 -0700
Subject: [PATCH 15/27] update example docs and other nits before merge
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
examples/usdConverter/README.md | 48 +++++-
examples/usdConverter/shapes.sdf | 244 -------------------------------
test/test_utils.hh | 1 +
usd/include/sdf/usd/World.hh | 2 +-
usd/src/cmd/CMakeLists.txt | 2 -
usd/src/cmd/sdf2usd.cc | 13 +-
6 files changed, 54 insertions(+), 256 deletions(-)
delete mode 100644 examples/usdConverter/shapes.sdf
diff --git a/examples/usdConverter/README.md b/examples/usdConverter/README.md
index 3690b4c5f..924944959 100644
--- a/examples/usdConverter/README.md
+++ b/examples/usdConverter/README.md
@@ -7,17 +7,57 @@ This example shows how a world in a SDF file can be converted to [USD](https://g
You will need all of the dependencies for sdformat, along with the following additional dependencies:
* USD: [installation instructions](https://github.com/PixarAnimationStudios/USD/blob/release/README.md#getting-and-building-the-code)
* [ignition-common4](https://github.com/ignitionrobotics/ign-common)
+* [ignition-utils1 (including the CLI component)](https://github.com/ignitionrobotics/ign-utils)
## Setup
-Build sdformat, you should now have an executable named `sdf2usd`, which can be used to convert a SDF world file to a USD file.
-The following command converts the example `shapes.sdf` file to its USD representation, stored in a file called `shapes.usd`:
+Build sdformat. The steps below follow a traditional cmake build, but sdformat
+can also be built with [colcon](https://colcon.readthedocs.io/en/released/index.html):
+```bash
+git clone https://github.com/ignitionrobotics/sdformat.git
+cd sdformat
+mkdir build
+cd build
+cmake ..
+make
+```
+
+You should now have an executable named `sdf2usd` in the `sdformat/build/bin` directory.
+This executable can be used to convert a SDF world file to a USD file.
+To see how the executable works, run the following command from the `sdformat/build/bin` directory:
+```bash
+./sdf2usd -h
+```
+
+To convert [shapes_world.sdf](https://github.com/ignitionrobotics/sdformat/blob/sdf12/test/sdf/shapes_world.sdf) to its USD representation as a file called `shapes.usd`, run the following commands:
```bash
-sdf2usd ../shapes.sdf shapes.usd
+wget https://raw.githubusercontent.com/ignitionrobotics/sdformat/sdf12/test/sdf/shapes_world.sdf
+./sdf2usd shapes_world.sdf shapes.usd
```
-You can now view the contents of the generated USD file with `usdview` (this should have been installed when setting up the USD dependency):
+You can now view the contents of the generated USD file with `usdcat` (this should have been installed when setting up the USD dependency):
+```bash
+usdcat shapes.usd
+```
+
+To see the visual representation of the USD world, run `usdview` (this should have also been installed when setting up the USD dependency):
```bash
usdview shapes.usd
```
+
+### Note about building with colcon
+You may need to add the USD library path to your `LD_LIBRARY_PATH` environment variable after sourcing the colcon workspace.
+If the USD library path is not a part of `LD_LIBRARY_PATH`, you will probably see the following error when running the `sdf2usd` executable:
+```bash
+sdf2usd: error while loading shared libraries: libusd_usd.so: cannot open shared object file: No such file or directory
+```
+The typical USD library path is `/lib`.
+So, if you installed USD at `/usr/local/USD`, the following command on Linux properly updates the `LD_LIBRARY_PATH` environment variable:
+```bash
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/USD/lib
+```
+
+Another thing to note if building with colcon is that after sourcing the workspace with sdformat,
+the `sdf2usd` executable can be run without having to go to the `sdformat/build/bin` directory.
+So, instead of going to that directory and running `./sdf2usd ...`, you should be able to run `sdf2usd ...` from anywhere.
diff --git a/examples/usdConverter/shapes.sdf b/examples/usdConverter/shapes.sdf
deleted file mode 100644
index 6935ae5d3..000000000
--- a/examples/usdConverter/shapes.sdf
+++ /dev/null
@@ -1,244 +0,0 @@
-
-
-
-
-
- 1.0 1.0 1.0
- 0.8 0.8 0.8
-
-
-
- true
- 0 0 10 0 0 0
- 0.8 0.8 0.8 1
- 0.2 0.2 0.2 1
-
- 1000
- 0.9
- 0.01
- 0.001
-
- -0.5 0.1 -0.9
-
-
-
- true
-
-
-
-
- 0 0 1
- 100 100
-
-
-
-
-
-
- 0 0 1
- 100 100
-
-
-
- 0.8 0.8 0.8 1
- 0.8 0.8 0.8 1
- 0.8 0.8 0.8 1
-
-
-
-
-
-
- 0 0 0.5 0 0 0
-
-
-
- 0.16666
- 0
- 0
- 0.16666
- 0
- 0.16666
-
- 1.0
-
-
-
-
- 1 1 1
-
-
-
-
-
-
-
- 1 1 1
-
-
-
- 1 0 0 1
- 1 0 0 1
- 1 0 0 1
-
-
-
-
-
-
- 0 -1.5 0.5 0 0 0
-
-
-
- 0.1458
- 0
- 0
- 0.1458
- 0
- 0.125
-
- 1.0
-
-
-
-
- 0.5
- 1.0
-
-
-
-
-
-
-
- 0.5
- 1.0
-
-
-
- 0 1 0 1
- 0 1 0 1
- 0 1 0 1
-
-
-
-
-
-
- 0 1.5 0.5 0 0 0
-
-
-
- 0.1
- 0
- 0
- 0.1
- 0
- 0.1
-
- 1.0
-
-
-
-
- 0.5
-
-
-
-
-
-
-
- 0.5
-
-
-
- 0 0 1 1
- 0 0 1 1
- 0 0 1 1
-
-
-
-
-
-
- 0 -3.0 0.5 0 0 0
-
-
-
- 0.074154
- 0
- 0
- 0.074154
- 0
- 0.018769
-
- 1.0
-
-
-
-
- 0.2
- 0.6
-
-
-
-
-
-
- 0.2
- 0.6
-
-
-
- 1 1 0 1
- 1 1 0 1
- 1 1 0 1
-
-
-
-
-
-
- 0 3.0 0.5 0 0 0
-
-
-
- 0.068
- 0
- 0
- 0.058
- 0
- 0.026
-
- 1.0
-
-
-
-
- 0.2 0.3 0.5
-
-
-
-
-
-
- 0.2 0.3 0.5
-
-
-
- 1 0 1 1
- 1 0 1 1
- 1 0 1 1
-
-
-
-
-
-
diff --git a/test/test_utils.hh b/test/test_utils.hh
index e52599dad..df8e9c43f 100644
--- a/test/test_utils.hh
+++ b/test/test_utils.hh
@@ -19,6 +19,7 @@
#include
#include
+
#include "sdf/Console.hh"
#include "sdf/Root.hh"
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/World.hh
index 6ea54ab6a..1988af244 100644
--- a/usd/include/sdf/usd/World.hh
+++ b/usd/include/sdf/usd/World.hh
@@ -25,7 +25,7 @@
#include
#pragma pop_macro ("__DEPRECATED")
-#include "sdf/sdf_config.h"
+#include "sdf/config.hh"
#include "sdf/system_util.hh"
#include "sdf/World.hh"
diff --git a/usd/src/cmd/CMakeLists.txt b/usd/src/cmd/CMakeLists.txt
index 3fa27abc5..46b6ca8a3 100644
--- a/usd/src/cmd/CMakeLists.txt
+++ b/usd/src/cmd/CMakeLists.txt
@@ -6,8 +6,6 @@ if(TARGET ${usd_target})
target_link_libraries(sdf2usd
PUBLIC
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER}
- ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
- ignition-common${IGN_COMMON_VER}::graphics
${usd_target}
)
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
index 9b5854298..84248ddc6 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/cmd/sdf2usd.cc
@@ -78,9 +78,12 @@ void runCommand(const Options &_opt)
const auto worldPath = std::string("/" + world->Name());
auto usdErrors = sdf::usd::ParseSdfWorld(*world, stage, worldPath);
- if (usdErrors.empty())
+ if (!usdErrors.empty())
{
- std::cerr << "Error parsing world [" << world->Name() << "]\n";
+ std::cerr << "The following errors occurred when parsing world ["
+ << world->Name() << "]\n:";
+ for (const auto &e : errors)
+ std::cout << e << "\n";
exit(-5);
}
@@ -97,11 +100,11 @@ void addFlags(CLI::App &_app)
_app.add_option("input",
opt->inputFilename,
- "Input filename");
+ "Input filename. Defaults to input.sdf unless otherwise specified.");
_app.add_option("output",
opt->outputFilename,
- "Output filename");
+ "Output filename. Defaults to output.usd unless otherwise specified.");
_app.callback([&_app, opt](){
runCommand(*opt);
@@ -111,7 +114,7 @@ void addFlags(CLI::App &_app)
//////////////////////////////////////////////////
int main(int argc, char** argv)
{
- CLI::App app{"Sdf format converter"};
+ CLI::App app{"SDF to USD converter"};
app.set_help_all_flag("--help-all", "Show all help");
From 92eca6331ff67586e00e86be81e2e9d9ce125258 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 22:32:11 +0100
Subject: [PATCH 16/27] clean CI
Signed-off-by: ahcorde
---
.github/ci/before_cmake.sh | 2 +-
.github/workflows/ci.yml | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/.github/ci/before_cmake.sh b/.github/ci/before_cmake.sh
index a0e23f85c..7ad653397 100644
--- a/.github/ci/before_cmake.sh
+++ b/.github/ci/before_cmake.sh
@@ -6,7 +6,7 @@ BUILD_DIR=`pwd`
cd /tmp
-# check that we can compile USD from sources
+# check that we can compile USD from sources (only Focal)
mkdir cmake_test
cd cmake_test
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 613c0531d..277bab16a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,11 +7,6 @@ jobs:
runs-on: ubuntu-latest
name: Ubuntu Bionic CI
steps:
- - name: Set env
- run: |
- export PATH=$PATH:/tmp/usd_binaries/bin
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/usd_binaries/lib
- export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH:/tmp/usd_binaries
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
From 0618353bf930778bb1e21ff34b5cf4f8babe93a2 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 22:39:10 +0100
Subject: [PATCH 17/27] Fixed CMake warning
Signed-off-by: ahcorde
---
CMakeLists.txt | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27604fe92..6328a7fa8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -118,8 +118,11 @@ if (BUILD_SDF)
# Find PXR
ign_find_package(pxr QUIET REQUIRED_BY usd PKGCONFIG pxr)
- ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
- COMPONENTS usd)
+ if (pxr_FOUND)
+ ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
+ COMPONENTS usd)
+ endif()
+
ign_create_packages()
add_subdirectory(sdf)
From bcc282b9346e14f7f60138fec2b1d8caeb652999 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 22:49:13 +0100
Subject: [PATCH 18/27] Fixed cmake
Signed-off-by: ahcorde
---
CMakeLists.txt | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6328a7fa8..ae7a2d2bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,10 +119,12 @@ if (BUILD_SDF)
ign_find_package(pxr QUIET REQUIRED_BY usd PKGCONFIG pxr)
if (pxr_FOUND)
- ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
- COMPONENTS usd)
+ list(APPEND COMPONENTS_TO_BUILD usd)
endif()
+ ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
+ COMPONENTS ${COMPONENTS_TO_BUILD})
+
ign_create_packages()
add_subdirectory(sdf)
From 0fd25685264109aa7c05024aa5bf9b8d82ee15a8 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Wed, 19 Jan 2022 23:12:04 +0100
Subject: [PATCH 19/27] reverted changes in CMakeLists.txt
Signed-off-by: ahcorde
---
CMakeLists.txt | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae7a2d2bd..1b69c0e65 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -118,12 +118,8 @@ if (BUILD_SDF)
# Find PXR
ign_find_package(pxr QUIET REQUIRED_BY usd PKGCONFIG pxr)
- if (pxr_FOUND)
- list(APPEND COMPONENTS_TO_BUILD usd)
- endif()
-
ign_configure_build(HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS
- COMPONENTS ${COMPONENTS_TO_BUILD})
+ COMPONENTS usd)
ign_create_packages()
From 0195564045cfc260663d462f4418590b29de6f45 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Fri, 21 Jan 2022 23:20:43 +0100
Subject: [PATCH 20/27] Improved test
Signed-off-by: ahcorde
---
usd/src/sdf2usd_TEST.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/usd/src/sdf2usd_TEST.cc b/usd/src/sdf2usd_TEST.cc
index b929b1f86..d2b5d3e7b 100644
--- a/usd/src/sdf2usd_TEST.cc
+++ b/usd/src/sdf2usd_TEST.cc
@@ -18,6 +18,7 @@
#include
+#include
#include
#include
@@ -71,6 +72,9 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
std::string output =
custom_exec_str(sdf2usdCommand() + " " + path + " " +
ignition::common::joinPaths(tmp, "shapes.usd"));
+ // make sure that a shapes.usd file was generated
+ EXPECT_TRUE(ignition::common::isFile(
+ ignition::common::joinPaths(tmp, "shapes.usd")));
// TODO(ahcorde): Check the output when the parser is implemented
}
}
From d91557e1095e9fd9e3cc919506a4af61e65977a5 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Fri, 21 Jan 2022 21:14:51 -0700
Subject: [PATCH 21/27] fix search path of sdf2usd executable in
UNIT_sdf2usd_TEST
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
usd/src/sdf2usd_TEST.cc | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/usd/src/sdf2usd_TEST.cc b/usd/src/sdf2usd_TEST.cc
index d2b5d3e7b..d532172dc 100644
--- a/usd/src/sdf2usd_TEST.cc
+++ b/usd/src/sdf2usd_TEST.cc
@@ -32,7 +32,8 @@
static std::string sdf2usdCommand()
{
- return std::string(IGN_PATH) + "/sdf2usd";
+ return ignition::common::joinPaths(std::string(PROJECT_BINARY_DIR), "bin",
+ "sdf2usd");
}
/////////////////////////////////////////////////
@@ -68,14 +69,22 @@ TEST(check_cmd, IGN_UTILS_TEST_DISABLED_ON_WIN32(SDF))
// Check a good SDF file
{
std::string path = ignition::common::joinPaths(pathBase,
- "/shapes_world.sdf");
+ "shapes_world.sdf");
+ const auto outputUsdFilePath =
+ ignition::common::joinPaths(tmp, "shapes.usd");
+ EXPECT_FALSE(ignition::common::isFile(outputUsdFilePath));
std::string output =
- custom_exec_str(sdf2usdCommand() + " " + path + " " +
- ignition::common::joinPaths(tmp, "shapes.usd"));
+ custom_exec_str(sdf2usdCommand() + " " + path + " " + outputUsdFilePath);
+ // TODO(adlarkin) make sure 'output' (i.e., the result of running the
+ // sdf2usd executable) is an empty string once the usd2sdf parser is fully
+ // implemented (right now, running the parser outputs an error indicating
+ // that functionality isn't complete)
+
// make sure that a shapes.usd file was generated
- EXPECT_TRUE(ignition::common::isFile(
- ignition::common::joinPaths(tmp, "shapes.usd")));
- // TODO(ahcorde): Check the output when the parser is implemented
+ EXPECT_TRUE(ignition::common::isFile(outputUsdFilePath));
+
+ // TODO(ahcorde): Check the contents of outputUsdFilePath when the parser
+ // is implemented
}
}
From f3922f0d5cc61ad74cf10457c887352ceb5d92ca Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Fri, 21 Jan 2022 21:15:32 -0700
Subject: [PATCH 22/27] alphabetize packages.apt
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
.github/ci/packages.apt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt
index e39a4b6eb..09308b7f2 100644
--- a/.github/ci/packages.apt
+++ b/.github/ci/packages.apt
@@ -1,5 +1,5 @@
-libignition-common4-dev
libignition-cmake2-dev
+libignition-common4-dev
libignition-math6-dev
libignition-tools-dev
libignition-utils1-dev
From 4c454a3cf2ade40e6220c76f5a54e92b4174ef05 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 24 Jan 2022 09:01:09 +0100
Subject: [PATCH 23/27] cleanup before_cmake.sh
Signed-off-by: ahcorde
---
.github/ci/before_cmake.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/ci/before_cmake.sh b/.github/ci/before_cmake.sh
index 7ad653397..123af216d 100644
--- a/.github/ci/before_cmake.sh
+++ b/.github/ci/before_cmake.sh
@@ -25,7 +25,6 @@ then
wget https://github.com/PixarAnimationStudios/USD/archive/refs/tags/v21.11.zip
unzip v21.11.zip
- sed -i '2059 i \ \ \ \ requiredDependencies.remove(BOOST)' USD-21.11/build_scripts/build_usd.py
cd USD-21.11
mkdir build
cd build
@@ -47,7 +46,6 @@ then
-DPXR_BUILD_ALEMBIC_PLUGIN=OFF \
-DPXR_BUILD_DRACO_PLUGIN=OFF \
-DPXR_ENABLE_MATERIALX_SUPPORT=OFF \
- -DBoost_NO_BOOST_CMAKE=On \
-DBoost_INCLUDE_DIR=/usr/include \
-DBoost_NO_BOOST_CMAKE=FALSE \
..
From 95c07e9e012f2c3a643670322faaa5acf5f3f783 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 24 Jan 2022 09:41:57 +0100
Subject: [PATCH 24/27] changed file structure
Signed-off-by: ahcorde
---
usd/include/sdf/usd/{ => sdf_parser}/World.hh | 0
usd/src/CMakeLists.txt | 27 +------------------
usd/src/sdf_parser/CMakeLists.txt | 26 ++++++++++++++++++
usd/src/{ => sdf_parser}/World.cc | 2 +-
.../{ => sdf_parser}/World_Sdf2Usd_TEST.cc | 2 +-
usd/src/{ => sdf_parser}/cmd/CMakeLists.txt | 0
usd/src/{ => sdf_parser}/cmd/sdf2usd.cc | 2 +-
usd/src/{ => sdf_parser}/sdf2usd_TEST.cc | 0
8 files changed, 30 insertions(+), 29 deletions(-)
rename usd/include/sdf/usd/{ => sdf_parser}/World.hh (100%)
create mode 100644 usd/src/sdf_parser/CMakeLists.txt
rename usd/src/{ => sdf_parser}/World.cc (98%)
rename usd/src/{ => sdf_parser}/World_Sdf2Usd_TEST.cc (98%)
rename usd/src/{ => sdf_parser}/cmd/CMakeLists.txt (100%)
rename usd/src/{ => sdf_parser}/cmd/sdf2usd.cc (98%)
rename usd/src/{ => sdf_parser}/sdf2usd_TEST.cc (100%)
diff --git a/usd/include/sdf/usd/World.hh b/usd/include/sdf/usd/sdf_parser/World.hh
similarity index 100%
rename from usd/include/sdf/usd/World.hh
rename to usd/include/sdf/usd/sdf_parser/World.hh
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
index 554092755..0842d9965 100644
--- a/usd/src/CMakeLists.txt
+++ b/usd/src/CMakeLists.txt
@@ -1,26 +1 @@
-# Collect source files into the "sources" variable and unit test files into the
-# "gtest_sources" variable.
-ign_get_libsources_and_unittests(sources gtest_sources)
-
-ign_add_component(usd SOURCES ${sources} GET_TARGET_NAME usd_target)
-
-target_include_directories(${usd_target}
- PUBLIC
- ${PXR_INCLUDE_DIRS}
-)
-
-target_link_libraries(${usd_target}
- PUBLIC
- ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
- ${PXR_LIBRARIES}
-)
-
-# Build the unit tests
-ign_build_tests(
- TYPE UNIT
- SOURCES ${gtest_sources}
- LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
- INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
-)
-
-add_subdirectory(cmd)
+add_subdirectory(sdf_parser)
diff --git a/usd/src/sdf_parser/CMakeLists.txt b/usd/src/sdf_parser/CMakeLists.txt
new file mode 100644
index 000000000..554092755
--- /dev/null
+++ b/usd/src/sdf_parser/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Collect source files into the "sources" variable and unit test files into the
+# "gtest_sources" variable.
+ign_get_libsources_and_unittests(sources gtest_sources)
+
+ign_add_component(usd SOURCES ${sources} GET_TARGET_NAME usd_target)
+
+target_include_directories(${usd_target}
+ PUBLIC
+ ${PXR_INCLUDE_DIRS}
+)
+
+target_link_libraries(${usd_target}
+ PUBLIC
+ ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
+ ${PXR_LIBRARIES}
+)
+
+# Build the unit tests
+ign_build_tests(
+ TYPE UNIT
+ SOURCES ${gtest_sources}
+ LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
+ INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
+)
+
+add_subdirectory(cmd)
diff --git a/usd/src/World.cc b/usd/src/sdf_parser/World.cc
similarity index 98%
rename from usd/src/World.cc
rename to usd/src/sdf_parser/World.cc
index 32859f9a9..37352d24a 100644
--- a/usd/src/World.cc
+++ b/usd/src/sdf_parser/World.cc
@@ -15,7 +15,7 @@
*
*/
-#include "sdf/usd/World.hh"
+#include "sdf/usd/sdf_parser/World.hh"
#include
#include
diff --git a/usd/src/World_Sdf2Usd_TEST.cc b/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
similarity index 98%
rename from usd/src/World_Sdf2Usd_TEST.cc
rename to usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
index 0883cd8af..884667608 100644
--- a/usd/src/World_Sdf2Usd_TEST.cc
+++ b/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
@@ -29,7 +29,7 @@
#include
#pragma pop_macro ("__DEPRECATED")
-#include "sdf/usd/World.hh"
+#include "sdf/usd/sdf_parser/World.hh"
#include "sdf/Root.hh"
#include "test_config.h"
#include "test_utils.hh"
diff --git a/usd/src/cmd/CMakeLists.txt b/usd/src/sdf_parser/cmd/CMakeLists.txt
similarity index 100%
rename from usd/src/cmd/CMakeLists.txt
rename to usd/src/sdf_parser/cmd/CMakeLists.txt
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/sdf_parser/cmd/sdf2usd.cc
similarity index 98%
rename from usd/src/cmd/sdf2usd.cc
rename to usd/src/sdf_parser/cmd/sdf2usd.cc
index 84248ddc6..a99c49b63 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/sdf_parser/cmd/sdf2usd.cc
@@ -24,7 +24,7 @@
#pragma pop_macro ("__DEPRECATED")
#include "sdf/sdf.hh"
-#include "sdf/usd/World.hh"
+#include "sdf/usd/sdf_parser/World.hh"
//////////////////////////////////////////////////
/// \brief Enumeration of available commands
diff --git a/usd/src/sdf2usd_TEST.cc b/usd/src/sdf_parser/sdf2usd_TEST.cc
similarity index 100%
rename from usd/src/sdf2usd_TEST.cc
rename to usd/src/sdf_parser/sdf2usd_TEST.cc
From c4c189f2c0bc037442d5cf277ca1289ec3d8b39e Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 24 Jan 2022 09:51:16 +0100
Subject: [PATCH 25/27] File structure
Signed-off-by: ahcorde
---
usd/src/CMakeLists.txt | 32 ++++++++++++++++++++-
usd/src/{sdf_parser => }/cmd/CMakeLists.txt | 0
usd/src/{sdf_parser => }/cmd/sdf2usd.cc | 0
usd/src/sdf_parser/CMakeLists.txt | 26 -----------------
4 files changed, 31 insertions(+), 27 deletions(-)
rename usd/src/{sdf_parser => }/cmd/CMakeLists.txt (100%)
rename usd/src/{sdf_parser => }/cmd/sdf2usd.cc (100%)
delete mode 100644 usd/src/sdf_parser/CMakeLists.txt
diff --git a/usd/src/CMakeLists.txt b/usd/src/CMakeLists.txt
index 0842d9965..cf9ccb0ff 100644
--- a/usd/src/CMakeLists.txt
+++ b/usd/src/CMakeLists.txt
@@ -1 +1,31 @@
-add_subdirectory(sdf_parser)
+set(sources
+ sdf_parser/World.cc
+)
+
+ign_add_component(usd SOURCES ${sources} GET_TARGET_NAME usd_target)
+
+target_include_directories(${usd_target}
+ PUBLIC
+ ${PXR_INCLUDE_DIRS}
+)
+
+target_link_libraries(${usd_target}
+ PUBLIC
+ ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
+ ${PXR_LIBRARIES}
+)
+
+set(gtest_sources
+ sdf_parser/sdf2usd_TEST.cc
+ sdf_parser/World_Sdf2Usd_TEST.cc
+)
+
+# Build the unit tests
+ign_build_tests(
+ TYPE UNIT
+ SOURCES ${gtest_sources}
+ LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
+ INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
+)
+
+add_subdirectory(cmd)
diff --git a/usd/src/sdf_parser/cmd/CMakeLists.txt b/usd/src/cmd/CMakeLists.txt
similarity index 100%
rename from usd/src/sdf_parser/cmd/CMakeLists.txt
rename to usd/src/cmd/CMakeLists.txt
diff --git a/usd/src/sdf_parser/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
similarity index 100%
rename from usd/src/sdf_parser/cmd/sdf2usd.cc
rename to usd/src/cmd/sdf2usd.cc
diff --git a/usd/src/sdf_parser/CMakeLists.txt b/usd/src/sdf_parser/CMakeLists.txt
deleted file mode 100644
index 554092755..000000000
--- a/usd/src/sdf_parser/CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-# Collect source files into the "sources" variable and unit test files into the
-# "gtest_sources" variable.
-ign_get_libsources_and_unittests(sources gtest_sources)
-
-ign_add_component(usd SOURCES ${sources} GET_TARGET_NAME usd_target)
-
-target_include_directories(${usd_target}
- PUBLIC
- ${PXR_INCLUDE_DIRS}
-)
-
-target_link_libraries(${usd_target}
- PUBLIC
- ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
- ${PXR_LIBRARIES}
-)
-
-# Build the unit tests
-ign_build_tests(
- TYPE UNIT
- SOURCES ${gtest_sources}
- LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
- INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
-)
-
-add_subdirectory(cmd)
From 085194986889525bb15ea65cd79d2366407ccb55 Mon Sep 17 00:00:00 2001
From: ahcorde
Date: Mon, 24 Jan 2022 10:32:55 +0100
Subject: [PATCH 26/27] Added TODO
Signed-off-by: ahcorde
---
usd/include/sdf/usd/sdf_parser/World.hh | 4 ++++
usd/src/cmd/sdf2usd.cc | 4 ++++
usd/src/sdf_parser/World.cc | 10 +++++++---
usd/src/sdf_parser/World_Sdf2Usd_TEST.cc | 5 +++++
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/usd/include/sdf/usd/sdf_parser/World.hh b/usd/include/sdf/usd/sdf_parser/World.hh
index 1988af244..3fc892d91 100644
--- a/usd/include/sdf/usd/sdf_parser/World.hh
+++ b/usd/include/sdf/usd/sdf_parser/World.hh
@@ -20,6 +20,10 @@
#include
+// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
+// are reported using #pragma message so normal diagnostic flags cannot remove
+// them. This workaround requires this block to be used whenever usd is
+// included.
#pragma push_macro ("__DEPRECATED")
#undef __DEPRECATED
#include
diff --git a/usd/src/cmd/sdf2usd.cc b/usd/src/cmd/sdf2usd.cc
index a99c49b63..c6f03353a 100644
--- a/usd/src/cmd/sdf2usd.cc
+++ b/usd/src/cmd/sdf2usd.cc
@@ -17,6 +17,10 @@
#include
+// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
+// are reported using #pragma message so normal diagnostic flags cannot remove
+// them. This workaround requires this block to be used whenever usd is
+// included.
#include
#pragma push_macro ("__DEPRECATED")
#undef __DEPRECATED
diff --git a/usd/src/sdf_parser/World.cc b/usd/src/sdf_parser/World.cc
index 37352d24a..390e3cefd 100644
--- a/usd/src/sdf_parser/World.cc
+++ b/usd/src/sdf_parser/World.cc
@@ -20,15 +20,19 @@
#include
#include
+// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
+// are reported using #pragma message so normal diagnostic flags cannot remove
+// them. This workaround requires this block to be used whenever usd is
+// included.
+#pragma push_macro ("__DEPRECATED")
+#undef __DEPRECATED
#include
#include
#include
-#pragma push_macro ("__DEPRECATED")
-#undef __DEPRECATED
#include
-#pragma pop_macro ("__DEPRECATED")
#include
#include
+#pragma pop_macro ("__DEPRECATED")
#include "sdf/World.hh"
diff --git a/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc b/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
index 884667608..189276456 100644
--- a/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
+++ b/usd/src/sdf_parser/World_Sdf2Usd_TEST.cc
@@ -18,6 +18,11 @@
#include
#include
+
+// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
+// are reported using #pragma message so normal diagnostic flags cannot remove
+// them. This workaround requires this block to be used whenever usd is
+// included.
#pragma push_macro ("__DEPRECATED")
#undef __DEPRECATED
#include
From 01aeb5747114f4449db417dca19a3d2300e516a7 Mon Sep 17 00:00:00 2001
From: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
Date: Mon, 24 Jan 2022 11:44:28 -0700
Subject: [PATCH 27/27] fix include guard
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
---
usd/include/sdf/usd/sdf_parser/World.hh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/usd/include/sdf/usd/sdf_parser/World.hh b/usd/include/sdf/usd/sdf_parser/World.hh
index 3fc892d91..f5c7d8ccd 100644
--- a/usd/include/sdf/usd/sdf_parser/World.hh
+++ b/usd/include/sdf/usd/sdf_parser/World.hh
@@ -15,8 +15,8 @@
*
*/
-#ifndef SDF_USD_WORLD_HH_
-#define SDF_USD_WORLD_HH_
+#ifndef SDF_USD_SDF_PARSER_WORLD_HH_
+#define SDF_USD_SDF_PARSER_WORLD_HH_
#include