Skip to content

Commit 334da29

Browse files
authored
Merge pull request #130 from ichumuh/main
added test_split_chain_of_connections
2 parents b54679b + 23ea8a9 commit 334da29

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

src/semantic_digital_twin/world.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,8 @@ def compute_split_chain_of_connections(
14741474
root_chain, common_ancestor, tip_chain = (
14751475
self.compute_split_chain_of_kinematic_structure_entities(root, tip)
14761476
)
1477-
root_chain.append(common_ancestor[0])
1478-
tip_chain.insert(0, common_ancestor[0])
1477+
root_chain = root_chain + [common_ancestor[0]]
1478+
tip_chain = [common_ancestor[0]] + tip_chain
14791479

14801480
root_connections = [
14811481
self.get_connection(root_chain[i + 1], root_chain[i])

test/test_robots/test_world_pr2.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,42 @@ def test_pr2_tighten_dof_velocity_limits_of_1dof_connections(pr2_world):
418418
pr2._world.get_connection_by_name("torso_lift_joint").dof.upper_limits.velocity
419419
== 0.013
420420
)
421+
422+
423+
def test_split_chain_of_connections(pr2_world):
424+
body1 = pr2_world.get_kinematic_structure_entity_by_name("r_gripper_r_finger_link")
425+
body2 = pr2_world.get_kinematic_structure_entity_by_name("l_gripper_l_finger_link")
426+
result = pr2_world.compute_split_chain_of_connections(root=body1, tip=body2)
427+
result1_names = [c.name for c in result[0]]
428+
result2_names = [c.name for c in result[1]]
429+
chain1 = [
430+
PrefixedName(name="r_gripper_r_finger_joint", prefix="pr2"),
431+
PrefixedName(name="r_gripper_palm_joint", prefix="pr2"),
432+
PrefixedName(name="r_wrist_roll_joint", prefix="pr2"),
433+
PrefixedName(name="r_wrist_flex_joint", prefix="pr2"),
434+
PrefixedName(name="r_forearm_joint", prefix="pr2"),
435+
PrefixedName(name="r_forearm_roll_joint", prefix="pr2"),
436+
PrefixedName(name="r_elbow_flex_joint", prefix="pr2"),
437+
PrefixedName(name="r_upper_arm_joint", prefix="pr2"),
438+
PrefixedName(name="r_upper_arm_roll_joint", prefix="pr2"),
439+
PrefixedName(name="r_shoulder_lift_joint", prefix="pr2"),
440+
PrefixedName(name="r_shoulder_pan_joint", prefix="pr2"),
441+
]
442+
443+
chain2 = [
444+
PrefixedName(name="l_shoulder_pan_joint", prefix="pr2"),
445+
PrefixedName(name="l_shoulder_lift_joint", prefix="pr2"),
446+
PrefixedName(name="l_upper_arm_roll_joint", prefix="pr2"),
447+
PrefixedName(name="l_upper_arm_joint", prefix="pr2"),
448+
PrefixedName(name="l_elbow_flex_joint", prefix="pr2"),
449+
PrefixedName(name="l_forearm_roll_joint", prefix="pr2"),
450+
PrefixedName(name="l_forearm_joint", prefix="pr2"),
451+
PrefixedName(name="l_wrist_flex_joint", prefix="pr2"),
452+
PrefixedName(name="l_wrist_roll_joint", prefix="pr2"),
453+
PrefixedName(name="l_force_torque_adapter_joint", prefix="pr2"),
454+
PrefixedName(name="l_force_torque_joint", prefix="pr2"),
455+
PrefixedName(name="l_gripper_palm_joint", prefix="pr2"),
456+
PrefixedName(name="l_gripper_l_finger_joint", prefix="pr2"),
457+
]
458+
assert result1_names == chain1
459+
assert result2_names == chain2

0 commit comments

Comments
 (0)