1
1
/*
2
- * Copyright (C) 2021 Open Source Robotics Foundation
2
+ * Copyright (C) 2022 Open Source Robotics Foundation
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
29
29
#include < ignition/common/Util.hh>
30
30
31
31
#include " sdf/usd/usd_parser/USDData.hh"
32
-
33
32
#include " sdf/Console.hh"
34
33
#include " sdf/Joint.hh"
35
34
#include " sdf/JointAxis.hh"
36
35
37
36
namespace sdf
38
37
{
39
- // Inline bracke to help doxygen filtering.
38
+ // Inline bracket to help doxygen filtering.
40
39
inline namespace SDF_VERSION_NAMESPACE {
41
40
//
42
41
namespace usd
43
42
{
44
43
sdf::Joint ParseJoints (
45
44
const pxr::UsdPrim &_prim,
46
45
const std::string &_path,
47
- USDData &_usdData)
46
+ const USDData &_usdData)
48
47
{
49
48
sdf::Joint joint;
50
49
51
- std::pair<std::string, std::shared_ptr<USDStage>> USDData =
50
+ std::pair<std::string, std::shared_ptr<USDStage>> usdData =
52
51
_usdData.FindStage (_prim.GetPath ().GetName ());
53
-
54
- double metersPerUnit = USDData.second ->MetersPerUnit ();
52
+ double metersPerUnit = usdData.second ->MetersPerUnit ();
55
53
56
54
pxr::SdfPathVector body0, body1;
57
55
@@ -67,14 +65,11 @@ namespace sdf
67
65
joint.SetChildLinkName (ignition::common::basename (
68
66
body1[0 ].GetString ()));
69
67
}
70
- else
68
+ else if (body0. size () > 0 )
71
69
{
72
- if (body0.size () > 0 )
73
- {
74
- joint.SetParentLinkName (" world" );
75
- joint.SetChildLinkName (ignition::common::basename (
76
- body0[0 ].GetString ()));
77
- }
70
+ joint.SetParentLinkName (" world" );
71
+ joint.SetChildLinkName (ignition::common::basename (
72
+ body0[0 ].GetString ()));
78
73
}
79
74
80
75
if (body0.size () > 0 && joint.ParentLinkName ().empty ())
@@ -116,26 +111,28 @@ namespace sdf
116
111
{
117
112
pxr::UsdPhysicsRevoluteJoint (_prim).GetAxisAttr ().Get (&axis);
118
113
}
114
+
119
115
if (axis == pxr::UsdGeomTokens->x )
120
116
{
121
117
axisVector = ignition::math::Vector3d (1 , 0 , 0 );
122
118
}
123
- if (axis == pxr::UsdGeomTokens->y )
119
+ else if (axis == pxr::UsdGeomTokens->y )
124
120
{
125
121
axisVector = ignition::math::Vector3d (0 , 1 , 0 );
126
122
}
127
- if (axis == pxr::UsdGeomTokens->z )
123
+ else if (axis == pxr::UsdGeomTokens->z )
128
124
{
129
125
axisVector = ignition::math::Vector3d (0 , 0 , 1 );
130
126
}
131
127
132
128
pxr::GfVec3f localPose0, localPose1;
133
129
pxr::GfQuatf localRot0, localRot1;
134
130
135
- pxr::UsdPhysicsJoint (_prim).GetLocalPos0Attr ().Get (&localPose0);
136
- pxr::UsdPhysicsJoint (_prim).GetLocalPos1Attr ().Get (&localPose1);
137
- pxr::UsdPhysicsJoint (_prim).GetLocalRot0Attr ().Get (&localRot0);
138
- pxr::UsdPhysicsJoint (_prim).GetLocalRot1Attr ().Get (&localRot1);
131
+ const auto usdPhysicsJoint = pxr::UsdPhysicsJoint (_prim);
132
+ usdPhysicsJoint.GetLocalPos0Attr ().Get (&localPose0);
133
+ usdPhysicsJoint.GetLocalPos1Attr ().Get (&localPose1);
134
+ usdPhysicsJoint.GetLocalRot0Attr ().Get (&localRot0);
135
+ usdPhysicsJoint.GetLocalRot1Attr ().Get (&localRot1);
139
136
140
137
trans = (localPose0 + localPose1) * metersPerUnit;
141
138
@@ -223,9 +220,9 @@ namespace sdf
223
220
ignition::math::Vector3d (trans[0 ], trans[1 ], trans[2 ]),
224
221
ignition::math::Quaterniond (q1 * q2)));
225
222
226
- joint.SetAxis (0 , jointAxis);
227
223
jointAxis.SetLower (lowerLimit * metersPerUnit);
228
224
jointAxis.SetUpper (upperLimit * metersPerUnit);
225
+ joint.SetAxis (0 , jointAxis);
229
226
230
227
return joint;
231
228
}
@@ -244,14 +241,13 @@ namespace sdf
244
241
std::cerr << e << " \n " ;
245
242
}
246
243
247
- joint.SetRawPose (
248
- ignition::math::Pose3d (
244
+ joint.SetRawPose (ignition::math::Pose3d (
249
245
ignition::math::Vector3d (trans[0 ], trans[1 ], trans[2 ]),
250
- ignition::math::Quaterniond (q1) ));
246
+ q1 ));
251
247
252
- joint.SetAxis (0 , jointAxis);
253
248
jointAxis.SetLower (IGN_DTOR (lowerLimit));
254
249
jointAxis.SetUpper (IGN_DTOR (upperLimit));
250
+ joint.SetAxis (0 , jointAxis);
255
251
256
252
return joint;
257
253
}
0 commit comments