Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usd -> sdf: Read transforms #871

Merged
merged 55 commits into from
Mar 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
48c499b
USD -> SDF: Added cmd line tool
ahcorde Mar 9, 2022
3a9b349
USD -> SDF: Parse Physics and generated SDF file
ahcorde Mar 9, 2022
576f9bd
usd -> sdf: Read transforms
ahcorde Mar 9, 2022
a869404
Fixed var name
ahcorde Mar 9, 2022
0d2f1ae
Added tests
ahcorde Mar 9, 2022
d939ca4
review feedback
adlarkin Mar 10, 2022
bffdc8f
more review feedback
adlarkin Mar 10, 2022
213fb64
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_p…
ahcorde Mar 10, 2022
460d693
feedback
ahcorde Mar 10, 2022
866ba4f
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_physics' into…
ahcorde Mar 10, 2022
a01e4f9
Fix when physics schema is not available
ahcorde Mar 10, 2022
318eff9
review feedback
adlarkin Mar 11, 2022
602a176
fix test
adlarkin Mar 11, 2022
2ba1b26
Added some feedback
ahcorde Mar 11, 2022
d8212ae
Added feedback
ahcorde Mar 14, 2022
50eabdb
Added feedback
ahcorde Mar 14, 2022
fea108f
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_physics' into…
ahcorde Mar 14, 2022
539d724
Added feedback
ahcorde Mar 14, 2022
faafcdd
Removed WorldInterface class
ahcorde Mar 14, 2022
8dbabfb
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_physics' into…
ahcorde Mar 14, 2022
5f754dc
fixed test
ahcorde Mar 14, 2022
42647f9
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_physics' into…
ahcorde Mar 14, 2022
e7c5480
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_t…
ahcorde Mar 15, 2022
778c017
Added feedback
ahcorde Mar 15, 2022
4b20b92
make linters happy
ahcorde Mar 16, 2022
ce0f51c
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_t…
ahcorde Mar 16, 2022
9b55364
make linters happy
ahcorde Mar 16, 2022
a1f1ebf
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 16, 2022
02e3b04
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 22, 2022
67aae32
Added feedback
ahcorde Mar 23, 2022
219b82e
Merge branch 'ahcorde/usd_to_sdf_transforms' of https://github.com/ig…
ahcorde Mar 23, 2022
d52b557
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 23, 2022
f86f662
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 23, 2022
bd9e026
make linters happy
ahcorde Mar 23, 2022
1281ba2
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 23, 2022
8a8486a
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
adlarkin Mar 24, 2022
f2f58a5
Added feedback
ahcorde Mar 24, 2022
d17b787
Merge branch 'ahcorde/usd_to_sdf_transforms' of https://github.com/ig…
ahcorde Mar 24, 2022
acf8663
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 24, 2022
3ce73a1
Add feedback
ahcorde Mar 24, 2022
f65d681
Merge branch 'ahcorde/usd_to_sdf_transforms' of https://github.com/ig…
ahcorde Mar 24, 2022
4cd064a
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
adlarkin Mar 27, 2022
34dad46
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_t…
ahcorde Mar 28, 2022
479330f
Convert FindStage to const
ahcorde Mar 28, 2022
0198bfa
Added rotateZYX test
ahcorde Mar 28, 2022
b270192
remove unneeded cmake code
adlarkin Mar 28, 2022
e2acde3
make sure only XYZ or ZYX rotation is enabled, but not both
adlarkin Mar 28, 2022
5e58b72
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 29, 2022
0d4d298
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 30, 2022
efbbc63
be more explicit about testing XYZ vs ZYX rotation
adlarkin Mar 30, 2022
da475d4
test nested position transforms
adlarkin Mar 30, 2022
68b26c9
make linters happy
ahcorde Mar 30, 2022
5f6f333
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 31, 2022
cf28342
USD -> SDF transform fixes (#924)
adlarkin Mar 31, 2022
3bb4427
added TODO
ahcorde Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added tests
Signed-off-by: ahcorde <ahcorde@gmail.com>
ahcorde committed Mar 9, 2022
commit 0d2f1aed6eaa3c759d7cc6459847e472ae32218e
3 changes: 2 additions & 1 deletion usd/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -11,11 +11,11 @@ set(sources
sdf_parser/Visual.cc
sdf_parser/World.cc
usd_parser/ParseUSD.cc
usd_parser/Physics.cc
usd_parser/USD.cc
usd_parser/USD2SDF.cc
usd_parser/USDData.cc
usd_parser/USDMaterial.cc
usd_parser/USDPhysics.cc
usd_parser/USDStage.cc
)

@@ -45,6 +45,7 @@ set(gtest_sources
sdf_parser/Visual_Sdf2Usd_TEST.cc
sdf_parser/World_Sdf2Usd_TEST.cc
usd_parser/USDData_TEST.cc
usd_parser/USDPhysics_TEST.cc
usd_parser/USDStage_TEST.cc
Conversions_TEST.cc
UsdError_TEST.cc
4 changes: 2 additions & 2 deletions usd/src/usd_parser/USD.cc
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@

#include "sdf/usd/usd_parser/USDData.hh"
#include "sdf/usd/usd_parser/USDStage.hh"
#include "Physics.hh"
#include "USDPhysics.hh"

#pragma push_macro ("__DEPRECATED")
#undef __DEPRECATED
@@ -60,7 +60,7 @@ namespace usd
std::pair<std::string, std::shared_ptr<USDStage>> data =
usdData.FindStage(prim.GetPath().GetName());

ParsePhysicsScene(prim, _world, data.second->MetersPerUnit());
ParseUSDPhysicsScene(prim, _world, data.second->MetersPerUnit());
continue;
}
}
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
*
*/

#include "Physics.hh"
#include "USDPhysics.hh"

#pragma push_macro ("__DEPRECATED")
#undef __DEPRECATED
@@ -30,7 +30,7 @@ namespace sdf
inline namespace SDF_VERSION_NAMESPACE {
namespace usd
{
void ParsePhysicsScene(
void ParseUSDPhysicsScene(
const pxr::UsdPrim &_prim,
std::shared_ptr<WorldInterface> &_world,
double _metersPerUnit)
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@
#include <pxr/usd/usd/primRange.h>
#pragma pop_macro ("__DEPRECATED")

#include <sdf/sdf_config.h>
#include "sdf/config.hh"
#include "sdf/usd/Export.hh"

namespace sdf
{
@@ -38,7 +39,7 @@ namespace sdf
/// \param[in] _prim Prim to extract the physics attributes
/// \param[out] _world World interface where the data is placed
/// \param[in] _metersPerUnit meter per unit in the USD
void ParsePhysicsScene(
void IGNITION_SDFORMAT_USD_VISIBLE ParseUSDPhysicsScene(
const pxr::UsdPrim &_prim,
std::shared_ptr<WorldInterface> &_world,
double _metersPerUnit);
57 changes: 57 additions & 0 deletions usd/src/usd_parser/USDPhysics_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 <gtest/gtest.h>

#include <memory>
#include <string>

// 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 <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/stage.h>
#pragma pop_macro ("__DEPRECATED")

#include "test_config.h"
#include "test_utils.hh"

#include "USDPhysics.hh"
#include "usd_model/WorldInterface.hh"

/////////////////////////////////////////////////
TEST(USDLightsTest, DistanceLight)
{
std::string filename = sdf::testing::TestFile("usd", "upAxisZ.usda");
auto stage = pxr::UsdStage::Open(filename);
ASSERT_TRUE(stage);

pxr::UsdPrim prim = stage->GetPrimAtPath(pxr::SdfPath("/shapes/physics"));

std::shared_ptr<sdf::usd::WorldInterface> worldInterface =
std::make_shared<sdf::usd::WorldInterface>();

double metersPerUnit = 1.0;

sdf::usd::ParseUSDPhysicsScene(
prim, worldInterface, metersPerUnit);
EXPECT_EQ(ignition::math::Vector3d(0, 0, -1), worldInterface->gravity);
EXPECT_NEAR(9.8, worldInterface->magnitude, 0.0001);
}