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 to SDF: Added diff drive plugin #904

Merged
merged 154 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
154 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
d10b6ec
USD -> SDF: Added lights attached to the world
ahcorde Mar 9, 2022
a869404
Fixed var name
ahcorde Mar 9, 2022
0d2f1ae
Added tests
ahcorde Mar 9, 2022
4b09785
Fixed build and added USDLight test
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
3dd8022
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 10, 2022
840088b
USD -> SDF: Added model tag
ahcorde Mar 10, 2022
a01e4f9
Fix when physics schema is not available
ahcorde Mar 10, 2022
a051214
USD -> SDF: Added link tag
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
1f4f124
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
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
f1b85ae
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
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
952099e
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 14, 2022
17f2b61
Fixed bad merge
ahcorde Mar 14, 2022
d81483e
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 14, 2022
b2364c1
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Mar 14, 2022
5b5d637
Fixed primType var
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
c4230ac
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 16, 2022
958fb3a
Parse some more values
ahcorde Mar 16, 2022
06bf561
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 16, 2022
d20c6f4
improvemetns
ahcorde Mar 16, 2022
e348833
Remove
ahcorde Mar 16, 2022
9b55364
make linters happy
ahcorde Mar 16, 2022
b94f473
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 16, 2022
a1f1ebf
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 16, 2022
b5c76e7
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 21, 2022
91bb545
make linters happy
ahcorde Mar 21, 2022
0707730
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 21, 2022
ca78463
make linters happy
ahcorde Mar 21, 2022
156aaae
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 21, 2022
bc60a10
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Mar 21, 2022
e81e815
Removed trace
ahcorde Mar 21, 2022
7dab68b
Improve implementation
ahcorde Mar 21, 2022
02e3b04
Merge branch 'sdf12' into ahcorde/usd_to_sdf_transforms
ahcorde Mar 22, 2022
78900ff
USD to SDF: Added visuals
ahcorde Mar 22, 2022
969f1c9
USD to SDF: Added Collisions
ahcorde Mar 22, 2022
21250cc
USD to SDF: Added Joints
ahcorde Mar 22, 2022
08dfb79
SDF to USD: Added Sensors
ahcorde Mar 22, 2022
1a238cd
diagonal inertia
ahcorde Mar 22, 2022
16e2831
fix light intensity
ahcorde Mar 22, 2022
2f1b91c
USD to SDF: Added Lights attached to models
ahcorde Mar 22, 2022
8d268c8
Fixed damping, maxfoce and stiffness for revolute joints
ahcorde Mar 22, 2022
4c8810c
USD to SDF: Added diff drive plugin
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
0ab33ec
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_transforms' i…
ahcorde Mar 28, 2022
7299701
fixed light test
ahcorde Mar 28, 2022
c615e3d
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 28, 2022
d995cfd
review feedback
adlarkin Mar 31, 2022
261e92a
Added feedback
ahcorde Mar 31, 2022
b06bb8c
Added comment about intensity
ahcorde Mar 31, 2022
d762c88
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_l…
ahcorde Mar 31, 2022
3325f5b
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_lights' into …
ahcorde Mar 31, 2022
af2ce4c
move error type to end of enum to avoid ABI break
adlarkin Mar 31, 2022
a907dda
parse models that are children of the root stage prim
adlarkin Mar 31, 2022
553b93b
check for static models, add test
adlarkin Mar 31, 2022
c07aba4
Improved implementation
ahcorde Apr 1, 2022
a8249fb
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_m…
ahcorde Apr 1, 2022
eeb3f91
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Apr 1, 2022
f7378e8
revert changes in favor of #914
adlarkin Apr 1, 2022
611ac14
initial review feedback
adlarkin Apr 1, 2022
d27cb4f
review nits
adlarkin Apr 1, 2022
2e0f45c
Added feedback
ahcorde Apr 5, 2022
2f61d37
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Apr 5, 2022
a63b384
remove trace
ahcorde Apr 5, 2022
0f7ead2
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Apr 5, 2022
b01801f
Merge branch 'sdf12' into ahcorde/usd_to_sdf_models
ahcorde Apr 5, 2022
01745f3
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_models' into …
ahcorde Apr 5, 2022
38bd7f4
Added feedback and tests
ahcorde Apr 5, 2022
baa3e27
Merge branch 'ahcorde/usd_to_sdf_links' of https://github.com/ignitio…
ahcorde Apr 5, 2022
32b9968
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_l…
ahcorde Apr 5, 2022
d62eaba
make linters happy
ahcorde Apr 6, 2022
384d860
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_links' into a…
ahcorde Apr 6, 2022
b38a5c5
Added visual test
ahcorde Apr 6, 2022
41df412
make linters happy
ahcorde Apr 6, 2022
a26ee8e
mke linters happy
ahcorde Apr 6, 2022
47474d8
Fixed test
ahcorde Apr 7, 2022
b63601a
review feedback
adlarkin Apr 7, 2022
47aa317
Added feedback
ahcorde Apr 8, 2022
9f58f6b
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_links' into a…
ahcorde Apr 8, 2022
d7590f9
Merge branch 'sdf12' into ahcorde/usd_to_sdf_visuals
adlarkin Apr 11, 2022
b8690d4
Added feedback
ahcorde Apr 11, 2022
078c747
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_visuals' into…
ahcorde Apr 11, 2022
68cc1e5
make linters happy
ahcorde Apr 11, 2022
b0085d0
fix build, review feedback
adlarkin Apr 11, 2022
d8de8ba
Fix
ahcorde Apr 11, 2022
21a07e3
Merge branch 'ahcorde/usd_to_sdf_visuals' into ahcorde/usd_to_sdf_col…
adlarkin Apr 11, 2022
ba47d64
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_c…
ahcorde Apr 11, 2022
4213b66
Merge branch 'sdf12' into ahcorde/usd_to_sdf_collisions
ahcorde Apr 12, 2022
9ebffa3
Added collision tests
ahcorde Apr 12, 2022
aeae8c9
Added feedback
ahcorde Apr 12, 2022
758cd19
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_collisions' i…
ahcorde Apr 12, 2022
5d2d7f9
Merge branch 'ahcorde/usd_to_sdf_joints' into ahcorde/usd_to_sdf_sensors
ahcorde Apr 12, 2022
9c98e12
review feedback, fix build
adlarkin Apr 12, 2022
ca7c9e6
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_j…
ahcorde Apr 13, 2022
d49ff05
Added tests
ahcorde Apr 13, 2022
44fb5d2
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_joints' into …
ahcorde Apr 13, 2022
526c699
make linters happy
ahcorde Apr 13, 2022
a4bbe53
Added Sensor tests
ahcorde Apr 13, 2022
548773d
Added sensors usda
ahcorde Apr 13, 2022
5f5919b
Fixed test
ahcorde Apr 13, 2022
85ce7f6
review feedback
adlarkin Apr 13, 2022
b85bbd8
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_joints' into …
ahcorde Apr 13, 2022
a43b2f0
Merge remote-tracking branch 'origin/sdf12' into ahcorde/usd_to_sdf_s…
ahcorde Apr 13, 2022
51563bc
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_sensors' into…
ahcorde Apr 13, 2022
6c281de
review feedback
adlarkin Apr 13, 2022
77ada72
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_sensors' into…
ahcorde Apr 13, 2022
3b1d3ad
make linters happy
ahcorde Apr 13, 2022
c64fc3d
Fixed tests
ahcorde Apr 14, 2022
0ed046c
Merge remote-tracking branch 'origin/ahcorde/usd_to_sdf_sensors' into…
ahcorde Apr 14, 2022
0099fe0
Merge branch 'sdf12' into ahcorde/usd_to_sdf_link_lights
adlarkin Apr 14, 2022
238ee64
review feedback
adlarkin Apr 14, 2022
7a4ce0a
add tests
adlarkin Apr 14, 2022
72a9eec
fix tests
adlarkin Apr 14, 2022
a897ad8
make tests more robust
adlarkin Apr 14, 2022
ab60b1a
Merge branch 'sdf12' into ahcorde/usd_to_sdf_link_lights
adlarkin Apr 15, 2022
b9e04dc
Merge branch 'ahcorde/usd_to_sdf_link_lights' into ahcorde/usd_to_sdf…
adlarkin Apr 15, 2022
4d4292c
allow usage of gazebo plugins to be set at command line
adlarkin Apr 15, 2022
cb54e9c
Merge branch 'sdf12' into ahcorde/usd_to_sdf_diff_drive_plugin
ahcorde Apr 19, 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
28 changes: 26 additions & 2 deletions test/usd/upAxisZ.usda
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ def "shapes"
float physics:gravityMagnitude = 9.8
}

def DistantLight "defaultLight" (
prepend apiSchemas = ["ShapingAPI"]
kind = "model"
)
{
float angle = 1
float inputs:intensity = 5000
float shaping:cone:angle = 180
float3 xformOp:rotateZYX = (0, 45, 0)
float3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]
}

def DiskLight "diskLight" (
prepend apiSchemas = ["ShapingAPI"]
kind = "model"
)
{
float inputs:intensity = 3000
float3 xformOp:rotateZYX = (0, 0, 45)
float3 xformOp:translate = (0, 0, 1000)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]
}

def Xform "ground_plane"
{
float3 xformOp:rotateXYZ = (0, 0, 0)
Expand Down Expand Up @@ -172,9 +196,9 @@ def "shapes"

def Xform "capsule_visual"
{
float3 xformOp:rotateXYZ = (0, 0, 0)
float3 xformOp:rotateZYX = (0, 0, 90)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]

def Capsule "geometry" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
Expand Down
3 changes: 3 additions & 0 deletions usd/include/sdf/usd/UsdError.hh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ namespace sdf
/// \brief Parsing of SDF object to a USD object failed.
SDF_TO_USD_PARSING_ERROR,

/// \brief Parsing of USD object to a SDF object failed.
USD_TO_SDF_PARSING_ERROR,

/// \brief The pxr::SdfPath does not point to a valid USD prim.
INVALID_PRIM_PATH,

Expand Down
146 changes: 146 additions & 0 deletions usd/include/sdf/usd/usd_parser/USDTransforms.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* 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_USD_PARSER_UTILS_HH_
#define SDF_USD_USD_PARSER_UTILS_HH_

#include <string>
#include <vector>

#include <ignition/math/Pose3.hh>
#include <ignition/math/Quaternion.hh>
#include <ignition/math/Vector3.hh>

#include <ignition/utils/ImplPtr.hh>

// 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/usdGeom/gprim.h>
#pragma pop_macro ("__DEPRECATED")

#include "sdf/sdf_config.h"
#include "sdf/system_util.hh"
#include "sdf/usd/Export.hh"
#include "sdf/usd/UsdError.hh"

#include "USDData.hh"

namespace sdf
{
// Inline bracke to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {
//
namespace usd
{
/// \brief This class stores the transforms of a schema
/// This might contain scale, translate or rotation operations
/// The booleans are used to check if there is a transform defined
/// in the schema
/// Rotation is splitted in a vector because this might be defined
/// as a rotation of 3 angles (ZYX, XYZ, etc).
class IGNITION_SDFORMAT_USD_VISIBLE UDSTransforms
{
/// \brief Default constructor
public: UDSTransforms();

/// \brief Translate
public: ignition::math::Vector3d Translate();

/// \brief Scale
public: ignition::math::Vector3d Scale();

/// \brief Rotation
public: std::vector<ignition::math::Quaterniond> Rotations();

/// \brief Set translate
public: void SetTranslate(const ignition::math::Vector3d &_translate);

/// \brief Set scale
public: void SetScale(const ignition::math::Vector3d &_scale);

/// \brief Add rotation
public: void AddRotation(const ignition::math::Quaterniond &_q);

/// \brief True if there is a rotation ZYX defined or false otherwise
bool RotationZYX();

/// \brief True if there is a rotation XYZ defined or false otherwise
bool RotationXYZ();

/// \brief True if there is a rotation (as a quaterion) defined
/// or false otherwise
bool Rotation();

/// \brief Set if there is any rotation ZYX defined
void SetRotationZYX(bool _rotationZYX);

/// \brief Set if there is any rotation XYZ defined
void SetRotationXYZ(bool _rotationXYZ);

/// \brief Set if there is any rotation defined
void SetRotation(bool _rotation);

/// \brief Private data pointer.
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief This function will parse all the parents transforms of a prim
/// This will stop when the name of the parent is the same as _schemaToStop
/// \param[in] _prim Initial prim to read the transform
/// \param[in] _usdData USDData structure to get info about the prim, for
/// example: metersperunit
/// \param[out] _tfs A vector with all the transforms
/// \param[out] _scale The scale of the prims
/// \param[in] _schemaToStop Name of the prim where the loop will stop
/// reading transforms
void GetAllTransforms(
const pxr::UsdPrim &_prim,
USDData &_usdData,
std::vector<ignition::math::Pose3d> &_tfs,
ignition::math::Vector3d &_scale,
const std::string &_schemaToStop);

/// \brief This function get the transform from a prim to the specified
/// schemaToStop variable
/// This will stop when the name of the parent is the same as _schemaToStop
/// \param[in] _prim Initial prim to read the transform
/// \param[in] _usdData USDData structure to get info about the prim, for
/// example: metersperunit
/// \param[out] _pose Pose of the prim
/// \param[out] _scale The scale of the prim
/// \param[in] _schemaToStop Name of the prim where the loop will stop
/// reading transforms
void IGNITION_SDFORMAT_USD_VISIBLE GetTransform(
const pxr::UsdPrim &_prim,
USDData &_usdData,
ignition::math::Pose3d &_pose,
ignition::math::Vector3d &_scale,
const std::string &_schemaToStop);

/// \brief Read the usd prim transforms. Scale, rotation or transform might
/// be defined as float or doubles
/// \param[in] _prim Prim where the transforms are read
UDSTransforms IGNITION_SDFORMAT_USD_VISIBLE ParseUSDTransform(
const pxr::UsdPrim &_prim);
}
}
}
#endif
10 changes: 9 additions & 1 deletion usd/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ set(sources
sdf_parser/Visual.cc
sdf_parser/World.cc
usd_parser/Parser.cc
usd_parser/polygon_helper.cc
usd_parser/USD2SDF.cc
usd_parser/USDData.cc
usd_parser/USDJoints.cc
usd_parser/USDLights.cc
usd_parser/USDLinks.cc
usd_parser/USDMaterial.cc
usd_parser/USDPhysics.cc
usd_parser/USDSensors.cc
usd_parser/USDStage.cc
usd_parser/USDTransforms.cc
usd_parser/USDWorld.cc
)

Expand Down Expand Up @@ -46,7 +52,9 @@ set(gtest_sources
sdf_parser/World_Sdf2Usd_TEST.cc
usd_parser/USDData_TEST.cc
usd_parser/USDPhysics_TEST.cc
usd_parser/USDLight_TEST.cc
usd_parser/USDStage_TEST.cc
usd_parser/USDTransforms_TEST.cc
Conversions_TEST.cc
UsdError_TEST.cc
UsdUtils_TEST.cc
Expand All @@ -57,7 +65,7 @@ ign_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS ${usd_target} ignition-cmake${IGN_CMAKE_VER}::utilities
INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test
INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/test usd_parser
)

if (TARGET UNIT_USDPhysics_TEST)
Expand Down
1 change: 1 addition & 0 deletions usd/src/cmd/usd2sdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <ignition/utils/cli/CLI.hpp>

#include "sdf/usd/usd_parser/Parser.hh"
#include "sdf/usd/UsdError.hh"
#include "sdf/config.hh"

//////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion usd/src/sdf_parser/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace usd
return errors;
}

if (!pxr::UsdPhysicsRigidBodyAPI::Apply(linkPrim))
if (!pxr::UsdPhysicsRigidBodyAPI::Apply(linkPrim.GetParent()))
{
errors.push_back(UsdError(sdf::usd::UsdErrorCode::FAILED_PRIM_API_APPLY,
"Internal error: unable to mark link at path [" + _path
Expand Down
28 changes: 28 additions & 0 deletions usd/src/sdf_parser/World.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/tokens.h>
#include <pxr/usd/usdPhysics/scene.h>
#include <pxr/usd/usdPhysics/articulationRootAPI.h>
#pragma pop_macro ("__DEPRECATED")

#include "sdf/Joint.hh"
#include "sdf/World.hh"
#include "sdf/usd/sdf_parser/Light.hh"
#include "sdf/usd/sdf_parser/Model.hh"
Expand Down Expand Up @@ -84,6 +86,32 @@ namespace usd
"Error parsing model [" + model.Name() + "]"));
errors.insert(errors.end(), modelErrors.begin(), modelErrors.end());
}

if (model.JointCount() > 0)
{
for (uint64_t j = 0; j < model.JointCount(); j++)
{
const auto joint = *(model.JointByIndex(j));
if (joint.Type() == sdf::JointType::REVOLUTE)
{
auto prim = _stage->GetPrimAtPath(pxr::SdfPath(modelPath));
if (prim)
{
if (!pxr::UsdPhysicsArticulationRootAPI::Apply(prim))
{
errors.push_back(UsdError(
sdf::usd::UsdErrorCode::FAILED_PRIM_API_APPLY,
"Internal error: unable to mark Xform at path [" +
modelPath + "] as ArticulationRootAPI some feature might not"
"work"));
errors.insert(errors.end(), modelErrors.begin(), modelErrors.end());
return errors;
}
}
break;
}
}
}
}

for (uint64_t i = 0; i < _world.LightCount(); ++i)
Expand Down
1 change: 1 addition & 0 deletions usd/src/usd_parser/USD2SDF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "USDWorld.hh"

#include "sdf/Error.hh"
#include "sdf/Light.hh"
#include "sdf/Root.hh"
#include "sdf/World.hh"

Expand Down
Loading