CUDA error with RigidPrimView.get_net_contact_forces()

I want to detect contact/collision for a procedurally generated articulation. The implementation is like adding two additional rigid bodies and then creating RigidPrimView for them:

self.bar = RigidPrimView(
    f"/World/envs/env_*/*/bar",
    reset_xform_properties=False,
    # track_contact_forces=True,
    contact_filter_prim_paths_expr=[
        "/World/envs/env_*/obstacle_0",
        "/World/envs/env_*/obstacle_1"
    ]
)
self.bar.initialize()
self.obstacles = RigidPrimView(
    "/World/envs/env_*/obstacle_*",
    reset_xform_properties=False,
    shape=[self.num_envs, -1],
    # track_contact_forces=True
)
self.obstacles.initialize()
self.payload = RigidPrimView(
    f"/World/envs/env_*/*/payload",
    reset_xform_properties=False,
    contact_filter_prim_paths_expr=[
        "/World/envs/env_*/obstacle_0",
        "/World/envs/env_*/obstacle_1"
    ]
)
self.payload.initialize()

The strange things happened:

  1. When I do
collision = (
    self.bar
    .get_net_contact_forces()
    .any(-1, keepdim=True)
) | (
    self.payload
    .get_net_contact_forces()
    .any(-1, keepdim=True)
)

it gives out CUDA errors like

../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [2,0,0], thread: [98,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [13,0,0], thread: [73,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [14,0,0], thread: [73,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [2,0,0], thread: [12,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [15,0,0], thread: [99,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [15,0,0], thread: [76,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [12,0,0], thread: [46,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [8,0,0], thread: [2,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [12,0,0], thread: [86,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.
../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:144: operator(): block: [15,0,0], thread: [22,0,0] Assertion `idx_dim >= 0 && idx_dim < index_size && "index out of bounds"` failed.

after running for a short while.

  1. Only detecting collision for bars would have a significantly lower probability to get this error.
  2. The results given by ·RiginPrimView.get_net_contact_forces()andRigidPrimView.get_contact_force_matric()` do not seem to be consistent.

I wonder what is the reason and solution here. Is it because the articulation is procedurally generated? If this is currently not solvable, what alternatives do I have to perform efficient collision/contact detection in an RL setting?

Hi there, the error seems to suggest an issue related to invalid indexing. Could you try running with the CPU pipeline (pipeline=cpu) to see if you get any more useful errors? In addition, you can also try specifying the dt parameter when retrieving contacts to help keep results more consistent.