Skip to content

Commit df4f258

Browse files
authored
Merge pull request #128 from ichumuh/compose_expression
compose forward kinematics expression
2 parents dfc0f70 + 8174456 commit df4f258

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/semantic_digital_twin/spatial_computations/ik_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def build_goal_constraints(
481481
self, active_symbols: List[cas.Symbol]
482482
) -> Tuple[cas.Expression, cas.Expression]:
483483
"""Build position and rotation goal constraints."""
484-
root_T_tip = self.world._forward_kinematic_manager.compose_expression(
484+
root_T_tip = self.world.compose_forward_kinematics_expression(
485485
self.root, self.tip
486486
)
487487

src/semantic_digital_twin/world.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,18 @@ def compute_forward_kinematics(
16091609
"""
16101610
return self._forward_kinematic_manager.compute(root, tip)
16111611

1612+
def compose_forward_kinematics_expression(
1613+
self, root: KinematicStructureEntity, tip: KinematicStructureEntity
1614+
) -> cas.TransformationMatrix:
1615+
"""
1616+
:param root: The root KinematicStructureEntity in the kinematic chain.
1617+
It determines the starting point of the forward kinematics calculation.
1618+
:param tip: The tip KinematicStructureEntity in the kinematic chain.
1619+
It determines the endpoint of the forward kinematics calculation.
1620+
:return: An expression representing the computed forward kinematics of the tip KinematicStructureEntity relative to the root KinematicStructureEntity.
1621+
"""
1622+
return self._forward_kinematic_manager.compose_expression(root, tip)
1623+
16121624
def compute_forward_kinematics_np(
16131625
self, root: KinematicStructureEntity, tip: KinematicStructureEntity
16141626
) -> NpMatrix4x4:

test/test_robots/test_world_pr2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_compute_fk_np_l_elbow_flex_joint_pr2(pr2_world):
170170
PrefixedName("l_upper_arm_link")
171171
)
172172

173-
fk_expr = pr2_world._forward_kinematic_manager.compose_expression(root, tip)
173+
fk_expr = pr2_world.compose_forward_kinematics_expression(root, tip)
174174
fk_expr_compiled = fk_expr.compile()
175175
fk2 = fk_expr_compiled(
176176
symbol_manager.resolve_symbols(*fk_expr_compiled.symbol_parameters)

test/test_worlds/test_world.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_compute_fk_expression(world_setup):
259259
world.state[connection.dof.name].position = 1.0
260260
world.notify_state_change()
261261
fk = world.compute_forward_kinematics_np(r2, l2)
262-
fk_expr = world._forward_kinematic_manager.compose_expression(r2, l2)
262+
fk_expr = world.compose_forward_kinematics_expression(r2, l2)
263263
fk_expr_compiled = fk_expr.compile()
264264
fk2 = fk_expr_compiled(
265265
*symbol_manager.resolve_symbols(fk_expr_compiled.symbol_parameters)
@@ -850,6 +850,7 @@ def test_symbol_removal():
850850
c_root_bf = OmniDrive.create_with_dofs(parent=body1, child=body2, world=world1)
851851
world1.add_connection(c_root_bf)
852852

853+
853854
def test_set_static_collision_config():
854855
w = World()
855856

@@ -869,6 +870,4 @@ def test_set_static_collision_config():
869870
collision_config = CollisionCheckingConfig(
870871
buffer_zone_distance=0.05, violated_distance=0.0, max_avoided_bodies=4
871872
)
872-
connection.set_static_collision_config_for_direct_child_bodies(
873-
collision_config
874-
)
873+
connection.set_static_collision_config_for_direct_child_bodies(collision_config)

0 commit comments

Comments
 (0)