17
17
18
18
#include " sdf/usd/sdf_parser/Joint.hh"
19
19
20
+ #include < sstream>
21
+
20
22
#include < ignition/math/Angle.hh>
21
23
#include < ignition/math/Pose3.hh>
22
24
#include < ignition/math/Vector3.hh>
@@ -89,43 +91,29 @@ namespace usd
89
91
{
90
92
auto poseResolutionErrors =
91
93
_joint.SemanticPose ().Resolve (parentToJoint, _joint.ParentLinkName ());
92
- std::vector<UsdError> poseResolutionUSDErrors;
93
- for (const auto & error : poseResolutionErrors)
94
- {
95
- poseResolutionUSDErrors.emplace_back (error);
96
- }
97
94
if (!poseResolutionErrors.empty ())
98
95
{
99
96
errors.push_back (UsdError (
100
97
sdf::Error (sdf::ErrorCode::POSE_RELATIVE_TO_INVALID,
101
98
" Unable to get the pose of joint [" + _joint.Name () +
102
99
" ] 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));
107
102
return errors;
108
103
}
109
104
}
110
105
111
106
ignition::math::Pose3d childToJoint;
112
107
auto poseResolutionErrors = _joint.SemanticPose ().Resolve (childToJoint,
113
108
_joint.ChildLinkName ());
114
- std::vector<UsdError> poseResolutionUSDErrors;
115
- for (const auto & error : poseResolutionErrors)
116
- {
117
- poseResolutionUSDErrors.emplace_back (error);
118
- }
119
109
if (!poseResolutionErrors.empty ())
120
110
{
121
111
errors.push_back (UsdError (
122
112
sdf::Error (sdf::ErrorCode::POSE_RELATIVE_TO_INVALID,
123
113
" Unable to get the pose of joint [" + _joint.Name () +
124
114
" ] 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));
129
117
return errors;
130
118
}
131
119
@@ -142,7 +130,7 @@ namespace usd
142
130
childToJoint.Rot ().Z ());
143
131
144
132
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.
146
134
if (axis && (axis->Xyz () == ignition::math::Vector3d::UnitY))
147
135
{
148
136
if (auto jointRevolute = pxr::UsdPhysicsRevoluteJoint (_jointPrim))
@@ -229,10 +217,12 @@ namespace usd
229
217
}
230
218
else
231
219
{
220
+ std::stringstream axisStr;
221
+ axisStr << axis->Xyz ();
232
222
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." )));
236
226
return errors;
237
227
}
238
228
@@ -256,10 +246,8 @@ namespace usd
256
246
}
257
247
258
248
// 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 ()));
263
251
drive.CreateMaxForceAttr ().Set (static_cast <float >(axis->Effort ()));
264
252
265
253
return errors;
@@ -302,10 +290,12 @@ namespace usd
302
290
}
303
291
else
304
292
{
293
+ std::stringstream axisStr;
294
+ axisStr << axis->Xyz ();
305
295
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." )));
309
299
return errors;
310
300
}
311
301
0 commit comments