Skip to content

Commit ec16504

Browse files
committed
Fixed free variables in double doors
1 parent b67d3a5 commit ec16504

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/semantic_digital_twin/semantic_annotations/factories.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,19 @@ def _add_double_door_to_world(
267267
new_connections.append(new_connection)
268268
new_dofs.append(new_dof)
269269

270-
with parent_world.modify_world(), double_door_world.modify_world():
271-
for new_dof in new_dofs:
272-
parent_world.add_degree_of_freedom(new_dof)
270+
with parent_world.modify_world():
271+
272+
with double_door_world.modify_world():
273+
for new_dof in new_dofs:
274+
parent_world.add_degree_of_freedom(new_dof)
273275

274-
for new_door_world, new_parent_C_left in zip(new_worlds, new_connections):
275-
parent_world.merge_world(new_door_world, new_parent_C_left)
276+
for new_door_world, new_parent_C_left in zip(
277+
new_worlds, new_connections
278+
):
279+
parent_world.merge_world(new_door_world, new_parent_C_left)
276280

277-
double_door_world.remove_semantic_annotation(double_door)
278-
parent_world.add_semantic_annotation(double_door)
281+
double_door_world.remove_semantic_annotation(double_door)
282+
parent_world.add_semantic_annotation(double_door)
279283

280284
def _move_door_into_new_world(
281285
self,
@@ -294,7 +298,7 @@ def _move_door_into_new_world(
294298
double_door_world = door._world
295299
door_hinge_kse = door.body.parent_kinematic_structure_entity
296300
double_door_C_door: RevoluteConnection = door_hinge_kse.parent_connection
297-
double_door_T_door = double_door_C_door.origin_expression
301+
double_door_T_door = double_door_C_door.parent_T_connection_expression
298302
parent_T_door = parent_T_double_door @ double_door_T_door
299303
old_dof = double_door_C_door.dof
300304

src/semantic_digital_twin/world_description/degree_of_freedom.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class PositionVariable(cas.FloatVariable):
1818
"""
1919
Describes the position of a degree of freedom.
2020
"""
21+
2122
name: PrefixedName = field(kw_only=True)
2223
dof: DegreeOfFreedom = field(kw_only=True)
2324
""" Backreference """
@@ -31,6 +32,7 @@ class VelocityVariable(cas.FloatVariable):
3132
"""
3233
Describes the velocity of a degree of freedom.
3334
"""
35+
3436
name: PrefixedName = field(kw_only=True)
3537
dof: DegreeOfFreedom = field(kw_only=True)
3638
""" Backreference """
@@ -44,6 +46,7 @@ class AccelerationVariable(cas.FloatVariable):
4446
"""
4547
Describes the acceleration of a degree of freedom.
4648
"""
49+
4750
name: PrefixedName = field(kw_only=True)
4851
dof: DegreeOfFreedom = field(kw_only=True)
4952
""" Backreference """
@@ -57,6 +60,7 @@ class JerkVariable(cas.FloatVariable):
5760
"""
5861
Describes the jerk of a degree of freedom.
5962
"""
63+
6064
name: PrefixedName = field(kw_only=True)
6165
dof: DegreeOfFreedom = field(kw_only=True)
6266
""" Backreference """

src/semantic_digital_twin/world_description/world_entity.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ def add_to_world(self, world: World):
860860
self._world = world
861861

862862
def __post_init__(self):
863+
863864
self.name = self.name or self._generate_default_name(
864865
parent=self.parent, child=self.child
865866
)
@@ -870,6 +871,11 @@ def __post_init__(self):
870871
if self._connection_T_child_expression is None:
871872
self._connection_T_child_expression = TransformationMatrix()
872873

874+
if not self.parent_T_connection_expression.is_constant():
875+
raise RuntimeError(
876+
f"Parent T matrix must be constant for connection. This one contains free variables: {self.parent_T_connection_expression.free_variables()}"
877+
)
878+
873879
if (
874880
self.parent_T_connection_expression.reference_frame is not None
875881
and self.parent_T_connection_expression.reference_frame != self.parent

0 commit comments

Comments
 (0)