Skip to content

Commit c03c363

Browse files
committed
review feedback
Signed-off-by: Ashton Larkin <42042756+adlarkin@users.noreply.github.com>
1 parent d1230a3 commit c03c363

File tree

3 files changed

+25
-39
lines changed

3 files changed

+25
-39
lines changed

test/sdf/double_pendulum.sdf

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
<axis>
199199
<xyz>1.0 0 0</xyz>
200200
<dynamics>
201-
<damping>35.000000</damping>
201+
<damping>35</damping>
202202
</dynamics>
203203
<limit>
204204
<stiffness>350</stiffness>
@@ -212,7 +212,7 @@
212212
<axis>
213213
<xyz>1.0 0 0</xyz>
214214
<dynamics>
215-
<damping>35.000000</damping>
215+
<damping>35</damping>
216216
</dynamics>
217217
<limit>
218218
<stiffness>350</stiffness>

usd/src/sdf_parser/Joint.cc

+19-29
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include "sdf/usd/sdf_parser/Joint.hh"
1919

20+
#include <sstream>
21+
2022
#include <ignition/math/Angle.hh>
2123
#include <ignition/math/Pose3.hh>
2224
#include <ignition/math/Vector3.hh>
@@ -89,43 +91,29 @@ namespace usd
8991
{
9092
auto poseResolutionErrors =
9193
_joint.SemanticPose().Resolve(parentToJoint, _joint.ParentLinkName());
92-
std::vector<UsdError> poseResolutionUSDErrors;
93-
for (const auto & error : poseResolutionErrors)
94-
{
95-
poseResolutionUSDErrors.emplace_back(error);
96-
}
9794
if (!poseResolutionErrors.empty())
9895
{
9996
errors.push_back(UsdError(
10097
sdf::Error(sdf::ErrorCode::POSE_RELATIVE_TO_INVALID,
10198
"Unable to get the pose of joint [" + _joint.Name() +
10299
"] w.r.t. its parent link [" + _joint.ParentLinkName() + "].")));
103-
errors.insert(
104-
errors.end(),
105-
poseResolutionUSDErrors.begin(),
106-
poseResolutionUSDErrors.end());
100+
for (const auto &e : poseResolutionErrors)
101+
errors.push_back(UsdError(e));
107102
return errors;
108103
}
109104
}
110105

111106
ignition::math::Pose3d childToJoint;
112107
auto poseResolutionErrors = _joint.SemanticPose().Resolve(childToJoint,
113108
_joint.ChildLinkName());
114-
std::vector<UsdError> poseResolutionUSDErrors;
115-
for (const auto & error : poseResolutionErrors)
116-
{
117-
poseResolutionUSDErrors.emplace_back(error);
118-
}
119109
if (!poseResolutionErrors.empty())
120110
{
121111
errors.push_back(UsdError(
122112
sdf::Error(sdf::ErrorCode::POSE_RELATIVE_TO_INVALID,
123113
"Unable to get the pose of joint [" + _joint.Name() +
124114
"] w.r.t. its child [" + _joint.ChildLinkName() + "].")));
125-
errors.insert(
126-
errors.end(),
127-
poseResolutionUSDErrors.begin(),
128-
poseResolutionUSDErrors.end());
115+
for (const auto &e : poseResolutionErrors)
116+
errors.push_back(UsdError(e));
129117
return errors;
130118
}
131119

@@ -142,7 +130,7 @@ namespace usd
142130
childToJoint.Rot().Z());
143131

144132
const auto axis = _joint.Axis();
145-
// TODO(anyone): Review this logic which convert a Y axis into a X axis.
133+
// TODO(anyone) Review this logic which converts a Y axis into a X axis.
146134
if (axis && (axis->Xyz() == ignition::math::Vector3d::UnitY))
147135
{
148136
if (auto jointRevolute = pxr::UsdPhysicsRevoluteJoint(_jointPrim))
@@ -229,10 +217,12 @@ namespace usd
229217
}
230218
else
231219
{
220+
std::stringstream axisStr;
221+
axisStr << axis->Xyz();
232222
errors.push_back(UsdError(sdf::Error(sdf::ErrorCode::ELEMENT_INVALID,
233-
"Revolute joint [" + _joint.Name() + "] has specified an axis "
234-
"[x y z], but USD only supports integer values of [0, 1] when"
235-
"specifying joint axis unit vectors.")));
223+
"Revolute joint [" + _joint.Name() + "] has specified an axis ["
224+
+ axisStr.str() + "], but USD only supports integer values of [0, 1] "
225+
"when specifying joint axis unit vectors.")));
236226
return errors;
237227
}
238228

@@ -256,10 +246,8 @@ namespace usd
256246
}
257247

258248
// TODO(ahcorde) Review damping and stiffness values
259-
double damping = axis->Damping();
260-
drive.CreateDampingAttr().Set(static_cast<float>(damping));
261-
double stiffness = axis->Stiffness();
262-
drive.CreateStiffnessAttr().Set(static_cast<float>(stiffness));
249+
drive.CreateDampingAttr().Set(static_cast<float>(axis->Damping()));
250+
drive.CreateStiffnessAttr().Set(static_cast<float>(axis->Stiffness()));
263251
drive.CreateMaxForceAttr().Set(static_cast<float>(axis->Effort()));
264252

265253
return errors;
@@ -302,10 +290,12 @@ namespace usd
302290
}
303291
else
304292
{
293+
std::stringstream axisStr;
294+
axisStr << axis->Xyz();
305295
errors.push_back(UsdError(sdf::Error(sdf::ErrorCode::ELEMENT_INVALID,
306-
"Prismatic joint [" + _joint.Name() + "] has specified an axis "
307-
"[x y z], but USD only supports integer values of [0, 1] when"
308-
"specifying joint axis unit vectors.")));
296+
"Prismatic joint [" + _joint.Name() + "] has specified an axis ["
297+
+ axisStr.str() + "], but USD only supports integer values of [0, 1] "
298+
"when specifying joint axis unit vectors.")));
309299
return errors;
310300
}
311301

usd/src/sdf_parser/Joint_Sdf2Usd_TEST.cc

+4-8
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,17 @@ TEST_F(UsdJointStageFixture, RevoluteJoints)
309309
ASSERT_TRUE(dampingAttr);
310310
float usdDamping;
311311
EXPECT_TRUE(dampingAttr.Get(&usdDamping));
312-
const auto sdfDamping =
313-
ignition::math::equal(0.0, sdfJoint->Axis()->Damping()) ?
314-
35.0f : static_cast<float>(sdfJoint->Axis()->Damping());
315-
EXPECT_FLOAT_EQ(usdDamping, sdfDamping);
312+
EXPECT_FLOAT_EQ(usdDamping,
313+
static_cast<float>(sdfJoint->Axis()->Damping()));
316314

317315
// check stiffness
318316
const auto stiffnessAttr =
319317
prim.GetAttribute(pxr::TfToken(driveApiAttrPrefix + "stiffness"));
320318
ASSERT_TRUE(stiffnessAttr);
321319
float usdStiffness;
322320
EXPECT_TRUE(stiffnessAttr.Get(&usdStiffness));
323-
const auto sdfStiffness =
324-
ignition::math::equal(1e8, sdfJoint->Axis()->Stiffness()) ?
325-
350 : static_cast<float>(sdfJoint->Axis()->Stiffness());
326-
EXPECT_FLOAT_EQ(usdStiffness, sdfStiffness);
321+
EXPECT_FLOAT_EQ(usdStiffness,
322+
static_cast<float>(sdfJoint->Axis()->Stiffness()));
327323

328324
// check max force/effort
329325
const auto maxForceAttr =

0 commit comments

Comments
 (0)