9
9
from __future__ import annotations
10
10
11
11
import torch
12
- import warnings
13
12
from collections .abc import Sequence
14
13
from prettytable import PrettyTable
15
14
from typing import TYPE_CHECKING
@@ -156,25 +155,6 @@ def root_physx_view(self) -> physx.ArticulationView:
156
155
"""
157
156
return self ._root_physx_view
158
157
159
- @property
160
- def body_physx_view (self ) -> physx .RigidBodyView :
161
- """Rigid body view for the asset (PhysX).
162
-
163
- .. deprecated:: v0.3.0
164
-
165
- In previous versions, this attribute returned the rigid body view over all the links of the articulation.
166
- However, this led to confusion with the link ordering as they were not ordered in the same way as the
167
- articulation view.
168
-
169
- Therefore, this attribute will be removed in v0.4.0. Please use the :attr:`root_physx_view` attribute
170
- instead.
171
-
172
- """
173
- dep_msg = "The attribute 'body_physx_view' will be removed in v0.4.0. Please use 'root_physx_view' instead."
174
- warnings .warn (dep_msg , DeprecationWarning )
175
- carb .log_error (dep_msg )
176
- return self ._body_physx_view
177
-
178
158
"""
179
159
Operations.
180
160
"""
@@ -194,16 +174,8 @@ def write_data_to_sim(self):
194
174
If any explicit actuators are present, then the actuator models are used to compute the
195
175
joint commands. Otherwise, the joint commands are directly set into the simulation.
196
176
"""
197
- # write external wrench
198
- if self .has_external_wrench :
199
- # apply external forces and torques
200
- self ._body_physx_view .apply_forces_and_torques_at_position (
201
- force_data = self ._external_force_body_view_b .view (- 1 , 3 ),
202
- torque_data = self ._external_torque_body_view_b .view (- 1 , 3 ),
203
- position_data = None ,
204
- indices = self ._ALL_BODY_INDICES ,
205
- is_global = False ,
206
- )
177
+ # apply external forces and torques
178
+ super ().write_data_to_sim ()
207
179
208
180
# apply actuator models
209
181
self ._apply_actuator_model ()
@@ -260,24 +232,6 @@ def find_fixed_tendons(
260
232
# find tendons
261
233
return string_utils .resolve_matching_names (name_keys , tendon_subsets , preserve_order )
262
234
263
- """
264
- Operations - Setters.
265
- """
266
-
267
- def set_external_force_and_torque (
268
- self ,
269
- forces : torch .Tensor ,
270
- torques : torch .Tensor ,
271
- body_ids : Sequence [int ] | slice | None = None ,
272
- env_ids : Sequence [int ] | None = None ,
273
- ):
274
- # call parent to set the external forces and torques into buffers
275
- super ().set_external_force_and_torque (forces , torques , body_ids , env_ids )
276
- # reordering of the external forces and torques to match the body view ordering
277
- if self .has_external_wrench :
278
- self ._external_force_body_view_b = self ._external_force_b [:, self ._body_view_ordering ]
279
- self ._external_torque_body_view_b = self ._external_torque_b [:, self ._body_view_ordering ]
280
-
281
235
"""
282
236
Operations - Writers.
283
237
"""
@@ -332,6 +286,7 @@ def write_joint_state_to_sim(
332
286
physx_env_ids = self ._ALL_INDICES
333
287
if joint_ids is None :
334
288
joint_ids = slice (None )
289
+ # broadcast env_ids if needed to allow double indexing
335
290
if env_ids != slice (None ) and joint_ids != slice (None ):
336
291
env_ids = env_ids [:, None ]
337
292
# set into internal buffers
@@ -364,6 +319,7 @@ def write_joint_stiffness_to_sim(
364
319
physx_env_ids = self ._ALL_INDICES
365
320
if joint_ids is None :
366
321
joint_ids = slice (None )
322
+ # broadcast env_ids if needed to allow double indexing
367
323
if env_ids != slice (None ) and joint_ids != slice (None ):
368
324
env_ids = env_ids [:, None ]
369
325
# set into internal buffers
@@ -394,6 +350,7 @@ def write_joint_damping_to_sim(
394
350
physx_env_ids = self ._ALL_INDICES
395
351
if joint_ids is None :
396
352
joint_ids = slice (None )
353
+ # broadcast env_ids if needed to allow double indexing
397
354
if env_ids != slice (None ) and joint_ids != slice (None ):
398
355
env_ids = env_ids [:, None ]
399
356
# set into internal buffers
@@ -422,6 +379,7 @@ def write_joint_effort_limit_to_sim(
422
379
physx_env_ids = self ._ALL_INDICES
423
380
if joint_ids is None :
424
381
joint_ids = slice (None )
382
+ # broadcast env_ids if needed to allow double indexing
425
383
if env_ids != slice (None ) and joint_ids != slice (None ):
426
384
env_ids = env_ids [:, None ]
427
385
# move tensor to cpu if needed
@@ -453,6 +411,7 @@ def write_joint_armature_to_sim(
453
411
physx_env_ids = self ._ALL_INDICES
454
412
if joint_ids is None :
455
413
joint_ids = slice (None )
414
+ # broadcast env_ids if needed to allow double indexing
456
415
if env_ids != slice (None ) and joint_ids != slice (None ):
457
416
env_ids = env_ids [:, None ]
458
417
# set into internal buffers
@@ -480,6 +439,7 @@ def write_joint_friction_to_sim(
480
439
physx_env_ids = self ._ALL_INDICES
481
440
if joint_ids is None :
482
441
joint_ids = slice (None )
442
+ # broadcast env_ids if needed to allow double indexing
483
443
if env_ids != slice (None ) and joint_ids != slice (None ):
484
444
env_ids = env_ids [:, None ]
485
445
# set into internal buffers
@@ -508,6 +468,7 @@ def write_joint_limits_to_sim(
508
468
physx_env_ids = self ._ALL_INDICES
509
469
if joint_ids is None :
510
470
joint_ids = slice (None )
471
+ # broadcast env_ids if needed to allow double indexing
511
472
if env_ids != slice (None ) and joint_ids != slice (None ):
512
473
env_ids = env_ids [:, None ]
513
474
# set into internal buffers
@@ -538,6 +499,7 @@ def set_joint_position_target(
538
499
env_ids = slice (None )
539
500
if joint_ids is None :
540
501
joint_ids = slice (None )
502
+ # broadcast env_ids if needed to allow double indexing
541
503
if env_ids != slice (None ) and joint_ids != slice (None ):
542
504
env_ids = env_ids [:, None ]
543
505
# set targets
@@ -562,6 +524,7 @@ def set_joint_velocity_target(
562
524
env_ids = slice (None )
563
525
if joint_ids is None :
564
526
joint_ids = slice (None )
527
+ # broadcast env_ids if needed to allow double indexing
565
528
if env_ids != slice (None ) and joint_ids != slice (None ):
566
529
env_ids = env_ids [:, None ]
567
530
# set targets
@@ -586,6 +549,7 @@ def set_joint_effort_target(
586
549
env_ids = slice (None )
587
550
if joint_ids is None :
588
551
joint_ids = slice (None )
552
+ # broadcast env_ids if needed to allow double indexing
589
553
if env_ids != slice (None ) and joint_ids != slice (None ):
590
554
env_ids = env_ids [:, None ]
591
555
# set targets
@@ -821,24 +785,6 @@ def _initialize_impl(self):
821
785
root_prim_path_expr = self .cfg .prim_path + root_prim_path [len (template_prim_path ) :]
822
786
# -- articulation
823
787
self ._root_physx_view = self ._physics_sim_view .create_articulation_view (root_prim_path_expr .replace (".*" , "*" ))
824
- # -- link views
825
- # note: we use the root view to get the body names, but we use the body view to get the
826
- # actual data. This is mainly needed to apply external forces to the bodies.
827
- physx_body_names = self .root_physx_view .shared_metatype .link_names
828
- body_names_regex = r"(" + "|" .join (physx_body_names ) + r")"
829
- body_names_regex = f"{ self .cfg .prim_path } /{ body_names_regex } "
830
- self ._body_physx_view = self ._physics_sim_view .create_rigid_body_view (body_names_regex .replace (".*" , "*" ))
831
-
832
- # create ordering from articulation view to body view for body names
833
- # note: we need to do this since the body view is not ordered in the same way as the articulation view
834
- # -- root view
835
- root_view_body_names = self .body_names
836
- # -- body view
837
- prim_paths = self ._body_physx_view .prim_paths [: self .num_bodies ]
838
- body_view_body_names = [path .split ("/" )[- 1 ] for path in prim_paths ]
839
- # -- mapping from articulation view to body view
840
- self ._body_view_ordering = [root_view_body_names .index (name ) for name in body_view_body_names ]
841
- self ._body_view_ordering = torch .tensor (self ._body_view_ordering , dtype = torch .long , device = self .device )
842
788
843
789
# log information about the articulation
844
790
carb .log_info (f"Articulation initialized at: { self .cfg .prim_path } with root '{ root_prim_path_expr } '." )
@@ -848,9 +794,6 @@ def _initialize_impl(self):
848
794
carb .log_info (f"Number of joints: { self .num_joints } " )
849
795
carb .log_info (f"Joint names: { self .joint_names } " )
850
796
carb .log_info (f"Number of fixed tendons: { self .num_fixed_tendons } " )
851
- # -- assert that parsing was successful
852
- if set (physx_body_names ) != set (self .body_names ):
853
- raise RuntimeError ("Failed to parse all bodies properly in the articulation." )
854
797
855
798
# container for data access
856
799
self ._data = ArticulationData (self .root_physx_view , self .device )
0 commit comments