semantic_digital_twin.world_description.world_entity

Contents

semantic_digital_twin.world_description.world_entity#

Attributes#

Classes#

WorldEntity

A class representing an entity in the world.

WorldEntityWithID

A WorldEntity that has a unique identifier.

CollisionCheckingConfig

Class for automatic (de)serialization of subclasses using importlib.

KinematicStructureEntity

An entity that is part of the kinematic structure of the world.

Body

Represents a body in the world.

Region

Virtual KinematicStructureEntity representing a semantic region in the world.

SemanticAnnotation

Represents a semantic annotation on a set of bodies in the world.

RootedSemanticAnnotation

Represents a semantic annotation that is rooted in a specific KinematicStructureEntity.

SemanticEnvironmentAnnotation

Represents a semantic annotation of the environment.

Connection

Represents a connection between two entities in the world.

Actuator

Represents an actuator in the world model.

Module Contents#

semantic_digital_twin.world_description.world_entity.id_generator#
class semantic_digital_twin.world_description.world_entity.WorldEntity#

Bases: krrood.entity_query_language.predicate.Symbol

A class representing an entity in the world.

Warning

The WorldEntity class is not meant to be instantiated directly.

name: semantic_digital_twin.datastructures.prefixed_name.PrefixedName = None#

The identifier for this world entity.

add_to_world(world: semantic_digital_twin.world.World)#
remove_from_world()#
class semantic_digital_twin.world_description.world_entity.WorldEntityWithID#

Bases: WorldEntity, krrood.adapters.json_serializer.SubclassJSONSerializer

A WorldEntity that has a unique identifier.

Warning

The WorldEntity class is not meant to be instantiated directly.

id: uuid.UUID#

A unique identifier for this world entity.

add_to_world(world: semantic_digital_twin.world.World)#
to_json() typing_extensions.Dict[str, typing_extensions.Any]#
class semantic_digital_twin.world_description.world_entity.CollisionCheckingConfig#

Bases: krrood.adapters.json_serializer.SubclassJSONSerializer

Class for automatic (de)serialization of subclasses using importlib.

Stores the fully qualified class name in type during serialization and imports that class during deserialization.

buffer_zone_distance: typing_extensions.Optional[float] = None#

Distance defining a buffer zone around the entity. The buffer zone represents a soft boundary where proximity should be monitored but minor violations are acceptable.

violated_distance: float = 0.0#

Critical distance threshold that must not be violated. Any proximity below this threshold represents a severe collision risk requiring immediate attention.

disabled: typing_extensions.Optional[bool] = None#

Flag to enable/disable collision checking for this entity. When True, all collision checks are ignored.

max_avoided_bodies: int = 1#

Maximum number of other bodies this body should avoid simultaneously. If more bodies than this are in the buffer zone, only the closest ones are avoided.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
class semantic_digital_twin.world_description.world_entity.KinematicStructureEntity#

Bases: WorldEntityWithID, krrood.adapters.json_serializer.SubclassJSONSerializer, abc.ABC

An entity that is part of the kinematic structure of the world.

index: typing_extensions.Optional[int] = None#

The index of the entity in _world.kinematic_structure.

remove_from_world()#
property combined_mesh: typing_extensions.Optional[trimesh.Trimesh]#
Abstractmethod:

Computes the combined mesh of this KinematicStructureEntity.

property center_of_mass: semantic_digital_twin.spatial_types.spatial_types.Point3#

Computes the center of mass of this KinematicStructureEntity.

property global_pose: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix#

Computes the pose of the KinematicStructureEntity in the world frame. :return: TransformationMatrix representing the global pose.

property parent_connection: Connection#

Returns the parent connection of this KinematicStructureEntity.

property child_kinematic_structure_entities: typing_extensions.List[KinematicStructureEntity]#

Returns the direct child KinematicStructureEntity of this entity.

property parent_kinematic_structure_entity: KinematicStructureEntity#

Returns the parent KinematicStructureEntity of this entity.

get_first_parent_connection_of_type(connection_type: typing_extensions.Type[GenericConnection]) GenericConnection#

Traverse the chain up until an active connection is found.

class semantic_digital_twin.world_description.world_entity.Body#

Bases: KinematicStructureEntity, krrood.adapters.json_serializer.SubclassJSONSerializer

Represents a body in the world. A body is a semantic atom, meaning that it cannot be decomposed into meaningful smaller parts.

visual: semantic_digital_twin.world_description.shape_collection.ShapeCollection#

List of shapes that represent the visual appearance of the link. The poses of the shapes are relative to the link.

collision: semantic_digital_twin.world_description.shape_collection.ShapeCollection#

List of shapes that represent the collision geometry of the link. The poses of the shapes are relative to the link.

collision_config: typing_extensions.Optional[CollisionCheckingConfig]#

Configuration for collision checking.

temp_collision_config: typing_extensions.Optional[CollisionCheckingConfig] = None#

Temporary configuration for collision checking, takes priority over collision_config.

index: typing_extensions.Optional[int] = None#

The index of the entity in _world.kinematic_structure.

inertial: typing_extensions.Optional[semantic_digital_twin.world_description.inertial_properties.Inertial]#

Inertia properties of the body.

property combined_mesh: typing_extensions.Optional[trimesh.Trimesh]#

Computes the combined mesh of this KinematicStructureEntity.

get_collision_config() CollisionCheckingConfig#
set_static_collision_config(collision_config: CollisionCheckingConfig)#
set_static_collision_distances(buffer_zone_distance: float, violated_distance: float)#
set_temporary_collision_config(collision_config: CollisionCheckingConfig)#
reset_temporary_collision_config()#
has_collision(volume_threshold: float = 1.001e-06, surface_threshold: float = 0.00061) bool#

Check if collision geometry is mesh or simple shape with volume/surface bigger than thresholds.

Parameters:
  • volume_threshold – Ignore simple geometry shapes with a volume less than this (in m^3)

  • surface_threshold – Ignore simple geometry shapes with a surface area less than this (in m^2)

Returns:

True if collision geometry is mesh or simple shape exceeding thresholds

compute_closest_points_multi(others: list[Body], sample_size=25) typing_extensions.Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Computes the closest points to each given body respectively.

Parameters:
  • others – The list of bodies to compute the closest points to.

  • sample_size – The number of samples to take from the surface of the other bodies.

Returns:

A tuple containing: The points on the self body, the points on the other bodies, and the distances. All points are in the of this body.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
get_semantic_annotations_by_type(type_: typing_extensions.Type[semantic_digital_twin.world.GenericSemanticAnnotation]) typing_extensions.List[semantic_digital_twin.world.GenericSemanticAnnotation]#

Returns all semantic annotations of a given type which belong to this body. :param type_: The type of semantic annotations to return. :returns: A list of semantic annotations of the given type.

class semantic_digital_twin.world_description.world_entity.Region#

Bases: KinematicStructureEntity

Virtual KinematicStructureEntity representing a semantic region in the world.

area: semantic_digital_twin.world_description.shape_collection.ShapeCollection#

The shapes that represent the area of the region.

property combined_mesh: typing_extensions.Optional[trimesh.Trimesh]#

Computes the combined mesh of this KinematicStructureEntity.

classmethod from_3d_points(name: semantic_digital_twin.datastructures.prefixed_name.PrefixedName, points_3d: typing_extensions.List[semantic_digital_twin.spatial_types.spatial_types.Point3], reference_frame: typing_extensions.Optional[KinematicStructureEntity] = None, minimum_thickness: float = 0.005, sv_ratio_tol: float = 1e-07) typing_extensions.Self#

Constructs a Region from a list of 3D points by creating a convex hull around them. The points are analyzed to determine if they are approximately planar. If they are, a minimum thickness is added to ensure the region has a non-zero volume.

Parameters:
  • name – Prefixed name for the region.

  • points_3d – List of 3D points.

  • reference_frame – Optional reference frame.

  • minimum_thickness – Minimum thickness to add if points are near-planar.

  • sv_ratio_tol – Tolerance for determining planarity based on singular value ratio.

Returns:

Region object.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
semantic_digital_twin.world_description.world_entity.GenericKinematicStructureEntity#
semantic_digital_twin.world_description.world_entity.GenericWorldEntity#
class semantic_digital_twin.world_description.world_entity.SemanticAnnotation#

Bases: WorldEntity, krrood.adapters.json_serializer.SubclassJSONSerializer

Represents a semantic annotation on a set of bodies in the world.

This class can hold references to certain bodies that gain meaning in this context.

Warning

The hash of a semantic annotation is based on the hash of its type and kinematic structure entities. Overwrite this with extreme care and only if you know what you are doing. Hashes are used inside rules to check if a new semantic annotation has been created. If you, for instance, just use the object identity, this will fail since python assigns new memory pointers always. The same holds for the equality operator. If you do not want to change the behavior, make sure to use @dataclass(eq=False) to decorate your class.

classmethod class_name_tokens() typing_extensions.Set[str]#
Returns:

Set of tokens from the class name.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
property kinematic_structure_entities: collections.abc.Iterable[KinematicStructureEntity]#

Returns a Iterable of all relevant KinematicStructureEntity in this semantic annotation. The default behaviour is to aggregate all KinematicStructureEntity that are accessible through the properties and fields of this semantic annotation, recursively. If this behaviour is not desired for a specific semantic annotation, it can be overridden by implementing the KinematicStructureEntity property.

property bodies: collections.abc.Iterable[Body]#

Returns an Iterable of all relevant bodies in this semantic annotation. The default behaviour is to aggregate all bodies that are accessible through the properties and fields of this semantic annotation, recursively. If this behaviour is not desired for a specific semantic annotation, it can be overridden by implementing the bodies property.

property regions: collections.abc.Iterable[Region]#

Returns an Iterable of all relevant regions in this semantic annotation. The default behaviour is to aggregate all regions that are accessible through the properties and fields of this semantic annotation, recursively. If this behaviour is not desired for a specific semantic annotation, it can be overridden by implementing the regions property.

as_bounding_box_collection_at_origin(origin: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix) semantic_digital_twin.world_description.shape_collection.BoundingBoxCollection#

Returns a bounding box collection that contains the bounding boxes of all bodies in this semantic annotation. :param reference_frame: The reference frame to express the bounding boxes in. :returns: A collection of bounding boxes in world-space coordinates.

as_bounding_box_collection_in_frame(reference_frame: KinematicStructureEntity) semantic_digital_twin.world_description.shape_collection.BoundingBoxCollection#

Provides the bounding box collection for this entity in the given reference frame. :param reference_frame: The reference frame to express the bounding boxes in. :returns: A collection of bounding boxes in world-space coordinates.

class semantic_digital_twin.world_description.world_entity.RootedSemanticAnnotation#

Bases: SemanticAnnotation

Represents a semantic annotation that is rooted in a specific KinematicStructureEntity.

root: Body = None#
property connections: typing_extensions.List[Connection]#
property bodies: typing_extensions.List[Body]#

Returns an Iterable of all relevant bodies in this semantic annotation. The default behaviour is to aggregate all bodies that are accessible through the properties and fields of this semantic annotation, recursively. If this behaviour is not desired for a specific semantic annotation, it can be overridden by implementing the bodies property.

property bodies_with_collisions: typing_extensions.List[Body]#
property bodies_with_enabled_collision: typing_extensions.Set[Body]#
class semantic_digital_twin.world_description.world_entity.SemanticEnvironmentAnnotation#

Bases: RootedSemanticAnnotation

Represents a semantic annotation of the environment.

property kinematic_structure_entities: typing_extensions.Set[KinematicStructureEntity]#

Returns a set of all KinematicStructureEntity in the environment semantic annotation.

class semantic_digital_twin.world_description.world_entity.Connection#

Bases: WorldEntity, krrood.adapters.json_serializer.SubclassJSONSerializer

Represents a connection between two entities in the world.

parent: KinematicStructureEntity#

The parent KinematicStructureEntity of the connection.

child: KinematicStructureEntity#

The child KinematicStructureEntity of the connection.

parent_T_connection_expression: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix = None#
kinematics: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix#
connection_T_child_expression: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix = None#

The origin expression of a connection is split into 2 transforms: 1. parent_T_connection describes the pose of the connection relative to its parent and must be constant.

It typically describes the fixed part of the origin expression, equivalent to the origin tag in urdf.

  1. A transformation describing the connection’s kinematics. For example, how a revolute joint rotate around its axis. This is always created by the connection and not should be copied.

  1. connection_T_child describes the pose of the child relative to the connection and must be constant.

This split is necessary for copying Connections, because they need parent_T_connection as an input parameter and connection_T_child is generated in the __post_init__ method.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
property origin_expression: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix#
property active_dofs: typing_extensions.List[semantic_digital_twin.world_description.degree_of_freedom.DegreeOfFreedom]#
property passive_dofs: typing_extensions.List[semantic_digital_twin.world_description.degree_of_freedom.DegreeOfFreedom]#
property is_controlled#
property has_hardware_interface: bool#
add_to_world(world: semantic_digital_twin.world.World)#
property origin: semantic_digital_twin.spatial_types.spatial_types.TransformationMatrix#
Returns:

The relative transform between the parent and child frame.

origin_as_position_quaternion() semantic_digital_twin.spatial_types.spatial_types.Expression#
property dofs: typing_extensions.Set[semantic_digital_twin.world_description.degree_of_freedom.DegreeOfFreedom]#

Returns the degrees of freedom associated with this connection.

classmethod create_with_dofs(world: semantic_digital_twin.world.World, parent: KinematicStructureEntity, child: KinematicStructureEntity, name: typing_extensions.Optional[semantic_digital_twin.datastructures.prefixed_name.PrefixedName] = None, *args, **kwargs) typing_extensions.Self#
Abstractmethod:

This method will automatically generate the degrees of freedom for this connection into the given world and initialize the connection with the generated dofs. :param world: Reference to the world where the dofs should be added. :param parent: parent of the connection. :param child: child of the connection. :param name: name of the connection. :param args: additional arguments the subclass might need :param kwargs: additional keyword arguments the subclass might need :return:

copy_for_world(world: semantic_digital_twin.world.World) typing_extensions.Self#

Copies this connection to the given world the parent and child references are updated to the new world as well as the references from the expression. :param world: World in which the connection should be copied. :return: The copied connection.

semantic_digital_twin.world_description.world_entity.GenericConnection#
class semantic_digital_twin.world_description.world_entity.Actuator#

Bases: WorldEntityWithID, krrood.adapters.json_serializer.SubclassJSONSerializer

Represents an actuator in the world model.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
property dofs: typing_extensions.List[semantic_digital_twin.world_description.degree_of_freedom.DegreeOfFreedom]#

Returns the degrees of freedom associated with this actuator.

add_dof(dof: semantic_digital_twin.world_description.degree_of_freedom.DegreeOfFreedom) None#

Adds a degree of freedom to this actuator.

Parameters:

dof – The degree of freedom to add.