@@ -309,6 +309,24 @@ def jerk(self, value: float) -> None:
309309 self ._world .state [self .raw_dof .name ].jerk = value / self .multiplier
310310 self ._world .notify_state_change ()
311311
312+ def copy_for_world (self , world : World ):
313+ (
314+ other_parent ,
315+ other_child ,
316+ parent_T_connection_expression ,
317+ ) = self ._find_references_in_world (world )
318+
319+ return self .__class__ (
320+ name = PrefixedName (self .name .name , self .name .prefix ),
321+ parent = other_parent ,
322+ child = other_child ,
323+ parent_T_connection_expression = parent_T_connection_expression ,
324+ dof_name = PrefixedName (self .dof_name .name , self .dof_name .prefix ),
325+ axis = self .axis ,
326+ multiplier = self .multiplier ,
327+ offset = self .offset ,
328+ )
329+
312330
313331@dataclass (eq = False )
314332class PrismaticConnection (ActiveConnection1DOF ):
@@ -557,6 +575,32 @@ def origin(
557575 self ._world .state [self .qw .name ].position = orientation [3 ]
558576 self ._world .notify_state_change ()
559577
578+ def copy_for_world (self , world : World ) -> Connection6DoF :
579+ """
580+ Copies this 6DoF connection for another world. Returns a new connection with references to the given world.
581+ :param world: The world to copy this connection for.
582+ :return: A copy of this connection for the given world.
583+ """
584+ (
585+ other_parent ,
586+ other_child ,
587+ parent_T_connection_expression ,
588+ ) = self ._find_references_in_world (world )
589+
590+ return Connection6DoF (
591+ name = deepcopy (self .name ),
592+ parent = other_parent ,
593+ child = other_child ,
594+ parent_T_connection_expression = parent_T_connection_expression ,
595+ x_name = deepcopy (self .x_name ),
596+ y_name = deepcopy (self .y_name ),
597+ z_name = deepcopy (self .z_name ),
598+ qx_name = deepcopy (self .qx_name ),
599+ qy_name = deepcopy (self .qy_name ),
600+ qz_name = deepcopy (self .qz_name ),
601+ qw_name = deepcopy (self .qw_name ),
602+ )
603+
560604
561605@dataclass (eq = False )
562606class OmniDrive (ActiveConnection , HasUpdateState ):
@@ -821,3 +865,30 @@ def has_hardware_interface(self, value: bool) -> None:
821865 self .x_velocity .has_hardware_interface = value
822866 self .y_velocity .has_hardware_interface = value
823867 self .yaw .has_hardware_interface = value
868+
869+ def copy_for_world (self , world : World ) -> OmniDrive :
870+ """
871+ Copies this OmniDriveConnection for the provided world. This finds the references for the parent and child in
872+ the new world and returns a new connection with references to the new parent and child.
873+ :param world: The world where the connection is copied.
874+ :return: The connection with references to the new parent and child.
875+ """
876+ (
877+ other_parent ,
878+ other_child ,
879+ parent_T_connection_expression ,
880+ ) = self ._find_references_in_world (world )
881+
882+ return OmniDrive (
883+ name = deepcopy (self .name ),
884+ parent = other_parent ,
885+ child = other_child ,
886+ parent_T_connection_expression = parent_T_connection_expression ,
887+ x_name = deepcopy (self .x_name ),
888+ y_name = deepcopy (self .y_name ),
889+ roll_name = deepcopy (self .roll_name ),
890+ pitch_name = deepcopy (self .pitch_name ),
891+ yaw_name = deepcopy (self .yaw_name ),
892+ x_velocity_name = deepcopy (self .x_velocity_name ),
893+ y_velocity_name = deepcopy (self .y_velocity_name ),
894+ )
0 commit comments