@@ -945,7 +945,7 @@ def substep(self, f):
945945
946946 def check_errno (self ):
947947 if gs .use_zerocopy :
948- errno = ti_to_torch (self ._errno , copy = None ).item ()
948+ errno = ti_to_torch (self ._errno ).item ()
949949 else :
950950 errno = kernel_get_errno (self ._errno )
951951
@@ -2217,21 +2217,21 @@ def get_sol_params(self, geoms_idx=None, envs_idx=None, *, joints_idx=None, eqs_
22172217 """
22182218 if eqs_idx is not None :
22192219 # Always batched
2220- tensor = ti_to_torch (self .equalities_info .sol_params , envs_idx , eqs_idx , transpose = True )
2220+ tensor = ti_to_torch (self .equalities_info .sol_params , envs_idx , eqs_idx , transpose = True , copy = True )
22212221 if self .n_envs == 0 :
22222222 tensor = tensor [0 ]
22232223 elif joints_idx is not None :
22242224 # Conditionally batched
22252225 assert envs_idx is None
22262226 # batch_shape = (envs_idx, joints_idx) if self._options.batch_joints_info else (joints_idx,)
22272227 # tensor = ti_to_torch(self.joints_info.sol_params, *batch_shape, transpose=True)
2228- tensor = ti_to_torch (self .joints_info .sol_params , envs_idx , joints_idx , transpose = True )
2228+ tensor = ti_to_torch (self .joints_info .sol_params , envs_idx , joints_idx , transpose = True , copy = True )
22292229 if self .n_envs == 0 and self ._options .batch_joints_info :
22302230 tensor = tensor [0 ]
22312231 else :
22322232 # Never batched
22332233 assert envs_idx is None
2234- tensor = ti_to_torch (self .geoms_info .sol_params , geoms_idx , transpose = True )
2234+ tensor = ti_to_torch (self .geoms_info .sol_params , geoms_idx , transpose = True , copy = True )
22352235 return tensor
22362236
22372237 @staticmethod
@@ -2260,37 +2260,37 @@ def get_links_pos(
22602260
22612261 ref = self ._convert_ref_to_idx (ref )
22622262 if ref == 0 :
2263- tensor = ti_to_torch (self .links_state .root_COM , envs_idx , links_idx , transpose = True )
2263+ tensor = ti_to_torch (self .links_state .root_COM , envs_idx , links_idx , transpose = True , copy = True )
22642264 elif ref == 1 :
22652265 i_pos = ti_to_torch (self .links_state .i_pos , envs_idx , links_idx , transpose = True )
22662266 root_COM = ti_to_torch (self .links_state .root_COM , envs_idx , links_idx , transpose = True )
22672267 tensor = i_pos + root_COM
22682268 elif ref == 2 :
2269- tensor = ti_to_torch (self .links_state .pos , envs_idx , links_idx , transpose = True )
2269+ tensor = ti_to_torch (self .links_state .pos , envs_idx , links_idx , transpose = True , copy = True )
22702270 else :
22712271 gs .raise_exception ("'ref' must be either 'link_origin', 'link_com', or 'root_com'." )
22722272
22732273 return tensor [0 ] if self .n_envs == 0 else tensor
22742274
22752275 def get_links_quat (self , links_idx = None , envs_idx = None , * , to_torch = True ):
2276- tensor = ti_to_torch (self .links_state .quat , envs_idx , links_idx , transpose = True )
2276+ tensor = ti_to_torch (self .links_state .quat , envs_idx , links_idx , transpose = True , copy = True )
22772277 return tensor [0 ] if self .n_envs == 0 else tensor
22782278
22792279 def get_links_vel (
22802280 self , links_idx = None , envs_idx = None , * , ref : Literal ["link_origin" , "link_com" , "root_com" ] = "link_origin"
22812281 ):
22822282 if gs .use_zerocopy :
22832283 mask = (0 , * indices_to_mask (links_idx )) if self .n_envs == 0 else indices_to_mask (envs_idx , links_idx )
2284- cd_vel = ti_to_torch (self .links_state .cd_vel , transpose = True , copy = False )
2284+ cd_vel = ti_to_torch (self .links_state .cd_vel , transpose = True )
22852285 if ref == "root_com" :
22862286 return cd_vel [mask ]
2287- cd_ang = ti_to_torch (self .links_state .cd_ang , transpose = True , copy = False )
2287+ cd_ang = ti_to_torch (self .links_state .cd_ang , transpose = True )
22882288 if ref == "link_com" :
2289- i_pos = ti_to_torch (self .links_state .i_pos , transpose = True , copy = False )
2289+ i_pos = ti_to_torch (self .links_state .i_pos , transpose = True )
22902290 delta = i_pos [mask ]
22912291 else :
2292- pos = ti_to_torch (self .links_state .pos , transpose = True , copy = False )
2293- root_COM = ti_to_torch (self .links_state .root_COM , transpose = True , copy = False )
2292+ pos = ti_to_torch (self .links_state .pos , transpose = True )
2293+ root_COM = ti_to_torch (self .links_state .root_COM , transpose = True )
22942294 delta = pos [mask ] - root_COM [mask ]
22952295 return cd_vel [mask ] + cd_ang [mask ].cross (delta , dim = - 1 )
22962296
@@ -2303,7 +2303,7 @@ def get_links_vel(
23032303 return _tensor
23042304
23052305 def get_links_ang (self , links_idx = None , envs_idx = None , * , to_torch = True ):
2306- tensor = ti_to_torch (self .links_state .cd_ang , envs_idx , links_idx , transpose = True )
2306+ tensor = ti_to_torch (self .links_state .cd_ang , envs_idx , links_idx , transpose = True , copy = True )
23072307 return tensor [0 ] if self .n_envs == 0 else tensor
23082308
23092309 def get_links_acc (self , links_idx = None , envs_idx = None ):
@@ -2321,7 +2321,7 @@ def get_links_acc(self, links_idx=None, envs_idx=None):
23212321 return _tensor
23222322
23232323 def get_links_acc_ang (self , links_idx = None , envs_idx = None , * , to_torch = True ):
2324- tensor = ti_to_torch (self .links_state .cacc_ang , envs_idx , links_idx , transpose = True )
2324+ tensor = ti_to_torch (self .links_state .cacc_ang , envs_idx , links_idx , transpose = True , copy = True )
23252325 return tensor [0 ] if self .n_envs == 0 else tensor
23262326
23272327 def get_links_root_COM (self , links_idx = None , envs_idx = None , * , to_torch = True ):
@@ -2331,39 +2331,39 @@ def get_links_root_COM(self, links_idx=None, envs_idx=None, *, to_torch=True):
23312331 This corresponds to the global COM of each entity, assuming a single-rooted structure - that is, as long as no
23322332 two successive links are connected by a free-floating joint (ie a joint that allows all 6 degrees of freedom).
23332333 """
2334- tensor = ti_to_torch (self .links_state .root_COM , envs_idx , links_idx , transpose = True )
2334+ tensor = ti_to_torch (self .links_state .root_COM , envs_idx , links_idx , transpose = True , copy = True )
23352335 return tensor [0 ] if self .n_envs == 0 else tensor
23362336
23372337 def get_links_mass_shift (self , links_idx = None , envs_idx = None , * , to_torch = True ):
2338- tensor = ti_to_torch (self .links_state .mass_shift , envs_idx , links_idx , transpose = True )
2338+ tensor = ti_to_torch (self .links_state .mass_shift , envs_idx , links_idx , transpose = True , copy = True )
23392339 return tensor [0 ] if self .n_envs == 0 else tensor
23402340
23412341 def get_links_COM_shift (self , links_idx = None , envs_idx = None , * , to_torch = True ):
2342- tensor = ti_to_torch (self .links_state .i_pos_shift , envs_idx , links_idx , transpose = True )
2342+ tensor = ti_to_torch (self .links_state .i_pos_shift , envs_idx , links_idx , transpose = True , copy = True )
23432343 return tensor [0 ] if self .n_envs == 0 else tensor
23442344
23452345 def get_links_inertial_mass (self , links_idx = None , envs_idx = None ):
23462346 if self ._options .batch_links_info and envs_idx is not None :
23472347 gs .raise_exception ("`envs_idx` cannot be specified for non-batched links info." )
2348- tensor = ti_to_torch (self .links_info .inertial_mass , envs_idx , links_idx , transpose = True )
2348+ tensor = ti_to_torch (self .links_info .inertial_mass , envs_idx , links_idx , transpose = True , copy = True )
23492349 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_links_info else tensor
23502350
23512351 def get_links_invweight (self , links_idx = None , envs_idx = None ):
23522352 if self ._options .batch_links_info and envs_idx is not None :
23532353 gs .raise_exception ("`envs_idx` cannot be specified for non-batched links info." )
2354- tensor = ti_to_torch (self .links_info .invweight , envs_idx , links_idx , transpose = True )
2354+ tensor = ti_to_torch (self .links_info .invweight , envs_idx , links_idx , transpose = True , copy = True )
23552355 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_links_info else tensor
23562356
23572357 def get_geoms_friction_ratio (self , geoms_idx = None , envs_idx = None ):
2358- tensor = ti_to_torch (self .geoms_state .friction_ratio , envs_idx , geoms_idx , transpose = True )
2358+ tensor = ti_to_torch (self .geoms_state .friction_ratio , envs_idx , geoms_idx , transpose = True , copy = True )
23592359 return tensor [0 ] if self .n_envs == 0 else tensor
23602360
23612361 def get_geoms_pos (self , geoms_idx = None , envs_idx = None ):
2362- tensor = ti_to_torch (self .geoms_state .pos , envs_idx , geoms_idx , transpose = True )
2362+ tensor = ti_to_torch (self .geoms_state .pos , envs_idx , geoms_idx , transpose = True , copy = True )
23632363 return tensor [0 ] if self .n_envs == 0 else tensor
23642364
23652365 def get_qpos (self , qs_idx = None , envs_idx = None ):
2366- tensor = ti_to_torch (self .qpos , envs_idx , qs_idx , transpose = True )
2366+ tensor = ti_to_torch (self .qpos , envs_idx , qs_idx , transpose = True , copy = True )
23672367 return tensor [0 ] if self .n_envs == 0 else tensor
23682368
23692369 def get_dofs_control_force (self , dofs_idx = None , envs_idx = None ):
@@ -2375,92 +2375,94 @@ def get_dofs_control_force(self, dofs_idx=None, envs_idx=None):
23752375 return _tensor
23762376
23772377 def get_dofs_force (self , dofs_idx = None , envs_idx = None ):
2378- tensor = ti_to_torch (self .dofs_state .force , envs_idx , dofs_idx , transpose = True )
2378+ tensor = ti_to_torch (self .dofs_state .force , envs_idx , dofs_idx , transpose = True , copy = True )
23792379 return tensor [0 ] if self .n_envs == 0 else tensor
23802380
23812381 def get_dofs_velocity (self , dofs_idx = None , envs_idx = None ):
2382- tensor = ti_to_torch (self .dofs_state .vel , envs_idx , dofs_idx , transpose = True )
2382+ tensor = ti_to_torch (self .dofs_state .vel , envs_idx , dofs_idx , transpose = True , copy = True )
23832383 return tensor [0 ] if self .n_envs == 0 else tensor
23842384
23852385 def get_dofs_position (self , dofs_idx = None , envs_idx = None ):
2386- tensor = ti_to_torch (self .dofs_state .pos , envs_idx , dofs_idx , transpose = True )
2386+ tensor = ti_to_torch (self .dofs_state .pos , envs_idx , dofs_idx , transpose = True , copy = True )
23872387 return tensor [0 ] if self .n_envs == 0 else tensor
23882388
23892389 def get_dofs_kp (self , dofs_idx = None , envs_idx = None ):
23902390 if not self ._options .batch_dofs_info and envs_idx is not None :
23912391 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2392- tensor = ti_to_torch (self .dofs_info .kp , envs_idx , dofs_idx , transpose = True )
2392+ tensor = ti_to_torch (self .dofs_info .kp , envs_idx , dofs_idx , transpose = True , copy = True )
23932393 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
23942394
23952395 def get_dofs_kv (self , dofs_idx = None , envs_idx = None ):
23962396 if not self ._options .batch_dofs_info and envs_idx is not None :
23972397 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2398- tensor = ti_to_torch (self .dofs_info .kv , envs_idx , dofs_idx , transpose = True )
2398+ tensor = ti_to_torch (self .dofs_info .kv , envs_idx , dofs_idx , transpose = True , copy = True )
23992399 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24002400
24012401 def get_dofs_force_range (self , dofs_idx = None , envs_idx = None ):
24022402 if not self ._options .batch_dofs_info and envs_idx is not None :
24032403 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2404- tensor = ti_to_torch (self .dofs_info .force_range , envs_idx , dofs_idx , transpose = True )
2404+ tensor = ti_to_torch (self .dofs_info .force_range , envs_idx , dofs_idx , transpose = True , copy = True )
24052405 if self .n_envs == 0 and self ._options .batch_dofs_info :
24062406 tensor = tensor [0 ]
24072407 return tensor [..., 0 ], tensor [..., 1 ]
24082408
24092409 def get_dofs_limit (self , dofs_idx = None , envs_idx = None ):
24102410 if not self ._options .batch_dofs_info and envs_idx is not None :
24112411 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2412- tensor = ti_to_torch (self .dofs_info .limit , envs_idx , dofs_idx , transpose = True )
2412+ tensor = ti_to_torch (self .dofs_info .limit , envs_idx , dofs_idx , transpose = True , copy = True )
24132413 if self .n_envs == 0 and self ._options .batch_dofs_info :
24142414 tensor = tensor [0 ]
24152415 return tensor [..., 0 ], tensor [..., 1 ]
24162416
24172417 def get_dofs_stiffness (self , dofs_idx = None , envs_idx = None ):
24182418 if not self ._options .batch_dofs_info and envs_idx is not None :
24192419 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2420- tensor = ti_to_torch (self .dofs_info .stiffness , envs_idx , dofs_idx , transpose = True )
2420+ tensor = ti_to_torch (self .dofs_info .stiffness , envs_idx , dofs_idx , transpose = True , copy = True )
24212421 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24222422
24232423 def get_dofs_invweight (self , dofs_idx = None , envs_idx = None ):
24242424 if not self ._options .batch_dofs_info and envs_idx is not None :
24252425 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2426- tensor = ti_to_torch (self .dofs_info .invweight , envs_idx , dofs_idx , transpose = True )
2426+ tensor = ti_to_torch (self .dofs_info .invweight , envs_idx , dofs_idx , transpose = True , copy = True )
24272427 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24282428
24292429 def get_dofs_armature (self , dofs_idx = None , envs_idx = None ):
24302430 if not self ._options .batch_dofs_info and envs_idx is not None :
24312431 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2432- tensor = ti_to_torch (self .dofs_info .armature , envs_idx , dofs_idx , transpose = True )
2432+ tensor = ti_to_torch (self .dofs_info .armature , envs_idx , dofs_idx , transpose = True , copy = True )
24332433 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24342434
24352435 def get_dofs_damping (self , dofs_idx = None , envs_idx = None ):
24362436 if not self ._options .batch_dofs_info and envs_idx is not None :
24372437 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2438- tensor = ti_to_torch (self .dofs_info .damping , envs_idx , dofs_idx , transpose = True )
2438+ tensor = ti_to_torch (self .dofs_info .damping , envs_idx , dofs_idx , transpose = True , copy = True )
24392439 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24402440
24412441 def get_dofs_frictionloss (self , dofs_idx = None , envs_idx = None ):
24422442 if not self ._options .batch_dofs_info and envs_idx is not None :
24432443 gs .raise_exception ("`envs_idx` cannot be specified for non-batched dofs info." )
2444- tensor = ti_to_torch (self .dofs_info .frictionloss , envs_idx , dofs_idx , transpose = True )
2444+ tensor = ti_to_torch (self .dofs_info .frictionloss , envs_idx , dofs_idx , transpose = True , copy = True )
24452445 return tensor [0 ] if self .n_envs == 0 and self ._options .batch_dofs_info else tensor
24462446
24472447 def get_mass_mat (self , dofs_idx = None , envs_idx = None , decompose = False ):
2448- tensor = ti_to_torch (self .mass_mat_L if decompose else self .mass_mat , envs_idx , transpose = True )
2448+ tensor = ti_to_torch (self .mass_mat_L if decompose else self .mass_mat , envs_idx , transpose = True , copy = True )
24492449 if dofs_idx is not None :
24502450 tensor = tensor [indices_to_mask (None , dofs_idx , dofs_idx )]
24512451 if self .n_envs == 0 :
24522452 tensor = tensor [0 ]
24532453
24542454 if decompose :
2455- mass_mat_D_inv = ti_to_torch (self ._rigid_global_info .mass_mat_D_inv , envs_idx , dofs_idx , transpose = True )
2455+ mass_mat_D_inv = ti_to_torch (
2456+ self ._rigid_global_info .mass_mat_D_inv , envs_idx , dofs_idx , transpose = True , copy = True
2457+ )
24562458 if self .n_envs == 0 :
24572459 mass_mat_D_inv = mass_mat_D_inv [0 ]
24582460 return tensor , mass_mat_D_inv
24592461
24602462 return tensor
24612463
24622464 def get_geoms_friction (self , geoms_idx = None ):
2463- return ti_to_torch (self .geoms_info .friction , geoms_idx , None )
2465+ return ti_to_torch (self .geoms_info .friction , geoms_idx , copy = True )
24642466
24652467 def get_AABB (self , entities_idx = None , envs_idx = None ):
24662468 from genesis .engine .couplers import LegacyCoupler
0 commit comments