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

sdf -> usd converter: add joints #837

Merged
merged 21 commits into from
Feb 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
codecheck, use USD component's visibility macro, properly construct w…
…rapped sdf errors

Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
adlarkin committed Feb 14, 2022
commit f898d2648213bbfb1c85eeaebc75ffa2a2d57028
2 changes: 1 addition & 1 deletion usd/include/sdf/usd/sdf_parser/Light.hh
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ namespace sdf
/// of _light.
/// \param[in] _path The USD path of the parsed light in _stage, which must
/// be a valid USD path.
/// \return UsdErrors, which is a vector of Error objects. Each Error
/// \return UsdErrors, which is a vector of UsdError objects. Each UsdError
/// includes an error code and message. An empty vector indicates no error.
UsdErrors IGNITION_SDFORMAT_USD_VISIBLE ParseSdfLight(
const sdf::Light &_light,
9 changes: 5 additions & 4 deletions usd/include/sdf/usd/sdf_parser/Link.hh
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
#pragma pop_macro ("__DEPRECATED")

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

@@ -48,10 +49,10 @@ namespace sdf
/// be a valid USD path.
/// \param[in] _rigidBody Whether the link is a rigid body (i.e.,
/// non-static) or not. True for rigid body, false otherwise
/// \return Errors, which is a vector of Error objects. Each Error includes
/// an error code and message. An empty vector indicates no errors occurred
/// when parsing _link to its USD representation.
UsdErrors SDFORMAT_VISIBLE ParseSdfLink(const sdf::Link &_link,
/// \return UsdErrors, which is a vector of UsdError objects. Each UsdError
/// includes an error code and message. An empty vector indicates no errors
/// occurred when parsing _link to its USD representation.
UsdErrors IGNITION_SDFORMAT_USD_VISIBLE ParseSdfLink(const sdf::Link &_link,
pxr::UsdStageRefPtr &_stage, const std::string &_path,
bool _rigidBody);
}
31 changes: 16 additions & 15 deletions usd/include/sdf/usd/sdf_parser/Model.hh
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@

#include <string>

// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
// 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.
@@ -31,6 +31,7 @@
#pragma pop_macro ("__DEPRECATED")

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

@@ -41,20 +42,20 @@ namespace sdf
//
namespace usd
{
/// \brief Parse an SDF model into a USD stage.
/// \param[in] _model The SDF model to parse.
/// \param[in] _stage The stage that should contain the USD representation
/// of _model. This must be a valid, initialized stage.
/// \param[in] _path The USD path of the parsed model in _stage, which must be
/// a valid USD path.
/// \param[in] _worldPath The path to the USD world prim. This is needed if
/// the model has any joints with the world as its parent.
/// \return Errors, which is a vector of Error objects. Each Error includes
/// an error code and message. An empty vector indicates no error occurred
/// when parsing _model to its USD representation.
UsdErrors SDFORMAT_VISIBLE ParseSdfModel(const sdf::Model &_model,
pxr::UsdStageRefPtr &_stage, const std::string &_path,
const pxr::SdfPath &_worldPath);
/// \brief Parse an SDF model into a USD stage.
/// \param[in] _model The SDF model to parse.
/// \param[in] _stage The stage that should contain the USD representation
/// of _model. This must be a valid, initialized stage.
/// \param[in] _path The USD path of the parsed model in _stage, which must
/// be a valid USD path.
/// \param[in] _worldPath The path to the USD world prim. This is needed if
/// the model has any joints with the world as its parent.
/// \return UsdErrors, which is a vector of UsdError objects. Each UsdError
/// includes an error code and message. An empty vector indicates no error
/// occurred when parsing _model to its USD representation.
UsdErrors IGNITION_SDFORMAT_USD_VISIBLE ParseSdfModel(
const sdf::Model &_model, pxr::UsdStageRefPtr &_stage,
const std::string &_path, const pxr::SdfPath &_worldPath);
}
}
}
5 changes: 3 additions & 2 deletions usd/src/sdf_parser/Light.cc
Original file line number Diff line number Diff line change
@@ -64,8 +64,9 @@ namespace usd
break;
case sdf::LightType::INVALID:
default:
errors.push_back(UsdError(sdf::usd::UsdErrorCode::SDF_ERROR,
"The light type that was given cannot be parsed to USD."));
errors.push_back(UsdError(sdf::Error(
sdf::ErrorCode::ATTRIBUTE_INCORRECT_TYPE,
"The light type that was given cannot be parsed to USD.")));
return errors;
}

7 changes: 4 additions & 3 deletions usd/src/sdf_parser/Link.cc
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
#include "sdf/usd/sdf_parser/Link.hh"

#include <string>
// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
// 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.
@@ -100,9 +100,10 @@ namespace usd
const auto light = *(_link.LightByIndex(i));
auto lightPath = std::string(_path + "/" + light.Name());
UsdErrors lightErrors = ParseSdfLight(light, _stage, lightPath);
if (!errors.empty())
if (!lightErrors.empty())
{
errors.push_back(UsdError(sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
errors.push_back(
UsdError(sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
"Error parsing light [" + light.Name() + "]"));
errors.insert(errors.end(), lightErrors.begin(), lightErrors.end());
}
9 changes: 5 additions & 4 deletions usd/src/sdf_parser/Model.cc
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>

// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
// 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.
@@ -52,8 +52,9 @@ namespace usd

if (_model.ModelCount())
{
errors.push_back(UsdError(sdf::usd::UsdErrorCode::SDF_ERROR,
"Nested models currently aren't supported."));
errors.push_back(UsdError(
sdf::Error(sdf::ErrorCode::ATTRIBUTE_INCORRECT_TYPE,
"Nested models currently aren't supported.")));
return errors;
}

@@ -91,7 +92,7 @@ namespace usd
sdfLinkToUSDPath[link.Name()] = pxr::SdfPath(linkPath);
UsdErrors linkErrors = ParseSdfLink(
link, _stage, linkPath, !_model.Static());
if (linkErrors.size() > 0)
if (!linkErrors.empty())
{
errors.push_back(
UsdError(sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
8 changes: 5 additions & 3 deletions usd/src/sdf_parser/World.cc
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@

#include <ignition/common/Util.hh>

// TODO(ahcorde):this is to remove deprecated "warnings" in usd, these warnings
// 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.
@@ -79,7 +79,8 @@ namespace usd
ParseSdfModel(model, _stage, modelPath, worldPrimPath);
if (!modelErrors.empty())
{
errors.push_back(UsdError(sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
errors.push_back(UsdError(
sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
"Error parsing model [" + model.Name() + "]"));
errors.insert(errors.end(), modelErrors.begin(), modelErrors.end());
}
@@ -93,7 +94,8 @@ namespace usd
UsdErrors lightErrors = ParseSdfLight(light, _stage, lightPath);
if (!lightErrors.empty())
{
errors.push_back(UsdError(sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
errors.push_back(UsdError(
sdf::usd::UsdErrorCode::SDF_TO_USD_PARSING_ERROR,
"Error parsing light [" + light.Name() + "]"));
errors.insert(errors.end(), lightErrors.begin(), lightErrors.end());
}