Skip to content

Commit 01099bb

Browse files
Fixes backend asset state invalidation + provides a skip (isaac-sim#6150)
# Description Fix stale cached pose and velocity state after backend asset state writers push data into simulation. This updates the Newton, PhysX, and OV PhysX backend asset writers to invalidate the affected cached data through shared data-class reset helpers. Fixes # (issue): N/A ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Screenshots N/A ## Validation - `./isaaclab.sh -f` (all hooks passed except `check-git-lfs-pointers`, which failed because `git-lfs` is not installed locally) - `SKIP=check-git-lfs-pointers ./isaaclab.sh -f` ## Checklist - [ ] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
1 parent f547744 commit 01099bb

37 files changed

Lines changed: 1992 additions & 661 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Added
2+
^^^^^
3+
4+
* Added a ``skip_forward`` argument to the abstract root, body, and joint state writers of
5+
:class:`~isaaclab.assets.BaseArticulation`, :class:`~isaaclab.assets.BaseRigidObject`, and
6+
:class:`~isaaclab.assets.BaseRigidObjectCollection` to defer cached-buffer invalidation when
7+
several writes are batched before a single forward pass.
8+
* Added :func:`~isaaclab.utils.buffers.reset_timestamps` to invalidate a list of timestamped
9+
buffers in one call, shared by the backend asset data classes' cache-reset helpers.
10+
11+
Changed
12+
^^^^^^^
13+
14+
* **Breaking:** Added abstract ``_reset_pose`` and ``_reset_velocity`` cache-invalidation hooks to
15+
:class:`~isaaclab.assets.BaseArticulationData`, :class:`~isaaclab.assets.BaseRigidObjectData`,
16+
and :class:`~isaaclab.assets.BaseRigidObjectCollectionData`. Custom simulation-backend subclasses
17+
must now implement both methods to remain instantiable: ``_reset_pose`` invalidates the
18+
pose-derived cached buffers and ``_reset_velocity`` the velocity-derived ones (see the Newton,
19+
PhysX, and OV PhysX data classes for reference implementations).

source/isaaclab/isaaclab/assets/articulation/base_articulation.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def write_root_pose_to_sim_index(
345345
*,
346346
root_pose: torch.Tensor | wp.array,
347347
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
348+
skip_forward: bool = False,
348349
) -> None:
349350
"""Set the root pose over selected environment indices into the simulation.
350351
@@ -361,6 +362,8 @@ def write_root_pose_to_sim_index(
361362
root_pose: Root poses in simulation frame. Shape is (len(env_ids), 7)
362363
or (len(env_ids),) with dtype wp.transformf.
363364
env_ids: Environment indices. If None, then all indices are used.
365+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
366+
must invalidate stale cached data before reading it back. Defaults to False.
364367
"""
365368
raise NotImplementedError()
366369

@@ -370,6 +373,7 @@ def write_root_pose_to_sim_mask(
370373
*,
371374
root_pose: torch.Tensor | wp.array,
372375
env_mask: wp.array | None = None,
376+
skip_forward: bool = False,
373377
) -> None:
374378
"""Set the root pose over selected environment mask into the simulation.
375379
@@ -386,6 +390,8 @@ def write_root_pose_to_sim_mask(
386390
root_pose: Root poses in simulation frame. Shape is (num_instances, 7)
387391
or (num_instances,) with dtype wp.transformf.
388392
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
393+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
394+
must invalidate stale cached data before reading it back. Defaults to False.
389395
"""
390396
raise NotImplementedError()
391397

@@ -395,6 +401,7 @@ def write_root_link_pose_to_sim_index(
395401
*,
396402
root_pose: torch.Tensor | wp.array,
397403
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
404+
skip_forward: bool = False,
398405
) -> None:
399406
"""Set the root link pose over selected environment indices into the simulation.
400407
@@ -411,6 +418,8 @@ def write_root_link_pose_to_sim_index(
411418
root_pose: Root poses in simulation frame. Shape is (len(env_ids), 7)
412419
or (len(env_ids),) with dtype wp.transformf.
413420
env_ids: Environment indices. If None, then all indices are used.
421+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
422+
must invalidate stale cached data before reading it back. Defaults to False.
414423
"""
415424
raise NotImplementedError()
416425

@@ -420,6 +429,7 @@ def write_root_link_pose_to_sim_mask(
420429
*,
421430
root_pose: torch.Tensor | wp.array,
422431
env_mask: wp.array | None = None,
432+
skip_forward: bool = False,
423433
) -> None:
424434
"""Set the root link pose over selected environment mask into the simulation.
425435
@@ -436,6 +446,8 @@ def write_root_link_pose_to_sim_mask(
436446
root_pose: Root poses in simulation frame. Shape is (num_instances, 7)
437447
or (num_instances,) with dtype wp.transformf.
438448
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
449+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
450+
must invalidate stale cached data before reading it back. Defaults to False.
439451
"""
440452
raise NotImplementedError()
441453

@@ -445,6 +457,7 @@ def write_root_com_pose_to_sim_index(
445457
*,
446458
root_pose: torch.Tensor | wp.array,
447459
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
460+
skip_forward: bool = False,
448461
) -> None:
449462
"""Set the root center of mass pose over selected environment indices into the simulation.
450463
@@ -462,6 +475,8 @@ def write_root_com_pose_to_sim_index(
462475
root_pose: Root center of mass poses in simulation frame. Shape is (len(env_ids), 7)
463476
or (len(env_ids),) with dtype wp.transformf.
464477
env_ids: Environment indices. If None, then all indices are used.
478+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
479+
must invalidate stale cached data before reading it back. Defaults to False.
465480
"""
466481
raise NotImplementedError()
467482

@@ -471,6 +486,7 @@ def write_root_com_pose_to_sim_mask(
471486
*,
472487
root_pose: torch.Tensor | wp.array,
473488
env_mask: wp.array | None = None,
489+
skip_forward: bool = False,
474490
) -> None:
475491
"""Set the root center of mass pose over selected environment mask into the simulation.
476492
@@ -488,6 +504,8 @@ def write_root_com_pose_to_sim_mask(
488504
root_pose: Root center of mass poses in simulation frame. Shape is (num_instances, 7)
489505
or (num_instances,) with dtype wp.transformf.
490506
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
507+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
508+
must invalidate stale cached data before reading it back. Defaults to False.
491509
"""
492510
raise NotImplementedError()
493511

@@ -497,6 +515,7 @@ def write_root_velocity_to_sim_index(
497515
*,
498516
root_velocity: torch.Tensor | wp.array,
499517
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
518+
skip_forward: bool = False,
500519
) -> None:
501520
"""Set the root center of mass velocity over selected environment indices into the simulation.
502521
@@ -516,6 +535,8 @@ def write_root_velocity_to_sim_index(
516535
root_velocity: Root center of mass velocities in simulation world frame. Shape is (len(env_ids), 6)
517536
or (len(env_ids),) with dtype wp.spatial_vectorf.
518537
env_ids: Environment indices. If None, then all indices are used.
538+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
539+
must invalidate stale cached data before reading it back. Defaults to False.
519540
"""
520541
raise NotImplementedError()
521542

@@ -525,6 +546,7 @@ def write_root_velocity_to_sim_mask(
525546
*,
526547
root_velocity: torch.Tensor | wp.array,
527548
env_mask: wp.array | None = None,
549+
skip_forward: bool = False,
528550
) -> None:
529551
"""Set the root center of mass velocity over selected environment mask into the simulation.
530552
@@ -544,6 +566,8 @@ def write_root_velocity_to_sim_mask(
544566
root_velocity: Root center of mass velocities in simulation world frame. Shape is (num_instances, 6)
545567
or (num_instances,) with dtype wp.spatial_vectorf.
546568
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
569+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
570+
must invalidate stale cached data before reading it back. Defaults to False.
547571
"""
548572
raise NotImplementedError()
549573

@@ -553,6 +577,7 @@ def write_root_com_velocity_to_sim_index(
553577
*,
554578
root_velocity: torch.Tensor | wp.array,
555579
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
580+
skip_forward: bool = False,
556581
) -> None:
557582
"""Set the root center of mass velocity over selected environment indices into the simulation.
558583
@@ -572,6 +597,8 @@ def write_root_com_velocity_to_sim_index(
572597
root_velocity: Root center of mass velocities in simulation world frame. Shape is (len(env_ids), 6)
573598
or (len(env_ids),) with dtype wp.spatial_vectorf.
574599
env_ids: Environment indices. If None, then all indices are used.
600+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
601+
must invalidate stale cached data before reading it back. Defaults to False.
575602
"""
576603
raise NotImplementedError()
577604

@@ -581,6 +608,7 @@ def write_root_com_velocity_to_sim_mask(
581608
*,
582609
root_velocity: torch.Tensor | wp.array,
583610
env_mask: wp.array | None = None,
611+
skip_forward: bool = False,
584612
) -> None:
585613
"""Set the root center of mass velocity over selected environment mask into the simulation.
586614
@@ -600,6 +628,8 @@ def write_root_com_velocity_to_sim_mask(
600628
root_velocity: Root center of mass velocities in simulation world frame. Shape is (num_instances, 6)
601629
or (num_instances,) with dtype wp.spatial_vectorf.
602630
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
631+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
632+
must invalidate stale cached data before reading it back. Defaults to False.
603633
"""
604634
raise NotImplementedError()
605635

@@ -609,6 +639,7 @@ def write_root_link_velocity_to_sim_index(
609639
*,
610640
root_velocity: torch.Tensor | wp.array,
611641
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
642+
skip_forward: bool = False,
612643
) -> None:
613644
"""Set the root link velocity over selected environment indices into the simulation.
614645
@@ -628,6 +659,8 @@ def write_root_link_velocity_to_sim_index(
628659
root_velocity: Root frame velocities in simulation world frame. Shape is (len(env_ids), 6)
629660
or (len(env_ids),) with dtype wp.spatial_vectorf.
630661
env_ids: Environment indices. If None, then all indices are used.
662+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
663+
must invalidate stale cached data before reading it back. Defaults to False.
631664
"""
632665
raise NotImplementedError()
633666

@@ -637,6 +670,7 @@ def write_root_link_velocity_to_sim_mask(
637670
*,
638671
root_velocity: torch.Tensor | wp.array,
639672
env_mask: wp.array | None = None,
673+
skip_forward: bool = False,
640674
) -> None:
641675
"""Set the root link velocity over selected environment mask into the simulation.
642676
@@ -656,6 +690,8 @@ def write_root_link_velocity_to_sim_mask(
656690
root_velocity: Root frame velocities in simulation world frame. Shape is (num_instances, 6)
657691
or (num_instances,) with dtype wp.spatial_vectorf.
658692
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
693+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
694+
must invalidate stale cached data before reading it back. Defaults to False.
659695
"""
660696
raise NotImplementedError()
661697

@@ -666,6 +702,7 @@ def write_joint_position_to_sim_index(
666702
position: torch.Tensor | wp.array,
667703
joint_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
668704
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
705+
skip_forward: bool = False,
669706
) -> None:
670707
"""Write joint positions to the simulation.
671708
@@ -680,6 +717,8 @@ def write_joint_position_to_sim_index(
680717
position: Joint positions. Shape is (len(env_ids), len(joint_ids)).
681718
joint_ids: The joint indices to set the targets for. Defaults to None (all joints).
682719
env_ids: The environment indices to set the targets for. Defaults to None (all instances).
720+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
721+
must invalidate stale cached data before reading it back. Defaults to False.
683722
"""
684723
raise NotImplementedError()
685724

@@ -690,6 +729,7 @@ def write_joint_position_to_sim_mask(
690729
position: torch.Tensor | wp.array,
691730
joint_mask: wp.array | None = None,
692731
env_mask: wp.array | None = None,
732+
skip_forward: bool = False,
693733
) -> None:
694734
"""Write joint positions to the simulation.
695735
@@ -704,6 +744,8 @@ def write_joint_position_to_sim_mask(
704744
position: Joint positions. Shape is (num_instances, num_joints).
705745
joint_mask: Joint mask. If None, then all the joints are updated. Shape is (num_joints,).
706746
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
747+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
748+
must invalidate stale cached data before reading it back. Defaults to False.
707749
"""
708750
raise NotImplementedError()
709751

@@ -714,6 +756,7 @@ def write_joint_velocity_to_sim_index(
714756
velocity: torch.Tensor | wp.array,
715757
joint_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
716758
env_ids: Sequence[int] | torch.Tensor | wp.array | None = None,
759+
skip_forward: bool = False,
717760
) -> None:
718761
"""Write joint velocities to the simulation.
719762
@@ -728,6 +771,8 @@ def write_joint_velocity_to_sim_index(
728771
velocity: Joint velocities. Shape is (len(env_ids), len(joint_ids)).
729772
joint_ids: The joint indices to set the targets for. Defaults to None (all joints).
730773
env_ids: The environment indices to set the targets for. Defaults to None (all instances).
774+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
775+
must invalidate stale cached data before reading it back. Defaults to False.
731776
"""
732777
raise NotImplementedError()
733778

@@ -738,6 +783,7 @@ def write_joint_velocity_to_sim_mask(
738783
velocity: torch.Tensor | wp.array,
739784
joint_mask: wp.array | None = None,
740785
env_mask: wp.array | None = None,
786+
skip_forward: bool = False,
741787
) -> None:
742788
"""Write joint velocities to the simulation.
743789
@@ -752,6 +798,8 @@ def write_joint_velocity_to_sim_mask(
752798
velocity: Joint velocities. Shape is (num_instances, num_joints).
753799
joint_mask: Joint mask. If None, then all the joints are updated. Shape is (num_joints,).
754800
env_mask: Environment mask. If None, then all the instances are updated. Shape is (num_instances,).
801+
skip_forward: Whether to skip invalidating cached data after the write. When True, the caller
802+
must invalidate stale cached data before reading it back. Defaults to False.
755803
"""
756804
raise NotImplementedError()
757805

source/isaaclab/isaaclab/assets/articulation/base_articulation_data.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ def __init__(self, root_view, device: str):
5656
def update(self, dt: float) -> None:
5757
raise NotImplementedError
5858

59+
@abstractmethod
60+
def _reset_pose(self, from_link: bool = True) -> None:
61+
"""Invalidate cached pose-dependent quantities after a pose write to the simulation.
62+
63+
Backends implement this to mark the affected pose buffers stale (and trigger any
64+
forward-kinematics refresh) so the next read recomputes from the freshly written state.
65+
66+
Args:
67+
from_link: Set ``True`` when the root link pose was written so the derived
68+
center-of-mass pose (:attr:`root_com_pose_w`) is also invalidated; set ``False``
69+
when the center-of-mass pose was written directly so it is not clobbered.
70+
"""
71+
raise NotImplementedError
72+
73+
@abstractmethod
74+
def _reset_velocity(self, from_com: bool = True) -> None:
75+
"""Invalidate cached velocity-dependent quantities after a velocity write to the simulation.
76+
77+
Backends implement this to mark the affected velocity buffers stale (and trigger any
78+
forward-kinematics refresh) so the next read recomputes from the freshly written state.
79+
80+
Args:
81+
from_com: Set ``True`` when the root center-of-mass velocity was written so the derived
82+
link velocity (:attr:`root_link_vel_w`) is also invalidated; set ``False`` when the
83+
link velocity was written directly so it is not clobbered.
84+
"""
85+
raise NotImplementedError
86+
5987
##
6088
# Names.
6189
##

0 commit comments

Comments
 (0)