Skip to content

Commit 6ec0d34

Browse files
author
Peter
committed
new test for sdf_serial_chain
1 parent 0ac2a0a commit 6ec0d34

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test_kinematics.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ def test_fk_simple_arm():
182182
assert list(tg.get_matrix().shape) == [N, 4, 4]
183183

184184

185+
def test_sdf_serial_chain():
186+
chain = pk.build_serial_chain_from_sdf(open(os.path.join(TEST_DIR, "simple_arm.sdf")).read(), 'arm_wrist_roll')
187+
chain = chain.to(dtype=torch.float64)
188+
tg = chain.forward_kinematics([0., math.pi / 2.0, -0.5, 0.])
189+
pos, rot = quat_pos_from_transform3d(tg)
190+
assert quaternion_equality(rot, torch.tensor([0.70710678, 0., 0., 0.70710678], dtype=torch.float64))
191+
assert torch.allclose(pos, torch.tensor([1.05, 0.55, 0.5], dtype=torch.float64))
192+
193+
185194
def test_cuda():
186195
if torch.cuda.is_available():
187196
d = "cuda"
@@ -197,9 +206,9 @@ def test_cuda():
197206

198207
ret = chain.forward_kinematics({
199208
'arm_shoulder_pan_joint': 0,
200-
'arm_elbow_pan_joint': math.pi / 2.0,
201-
'arm_wrist_lift_joint': -0.5,
202-
'arm_wrist_roll_joint': 0,
209+
'arm_elbow_pan_joint': math.pi / 2.0,
210+
'arm_wrist_lift_joint': -0.5,
211+
'arm_wrist_roll_joint': 0,
203212
})
204213
tg = ret['arm_wrist_roll']
205214
pos, rot = quat_pos_from_transform3d(tg)

0 commit comments

Comments
 (0)