Are there any examples of the use of omni. kit. raycast. inquiry. I want to use add_raycast_sequence/remove_raycast_sequence, submit_ray_to_raycast_sequence, get_latest_result_from_raycast_sequence Queries for multiple rays are not more efficient than a single ray.
import omni.kit.raycast.query as raycast
from pxr import Gf, UsdGeom
raycast = omni.kit.raycast.query.acquire_raycast_query_interface()
stage = omni.usd.get_context().get_stage()
CUBE_PATH = "/Cube"
cube = UsdGeom.Cube.Define(stage, CUBE_PATH)
UsdGeom.XformCommonAPI(cube.GetPrim()).SetTranslate(Gf.Vec3d(0, 0, 0))
sequence_id = 1
ray = omni.kit.raycast.query.Ray(
origin=(1000, 0, 0),
direction=(-1, 0, 0),
)
raycast.submit_ray_to_raycast_sequence(1, ray)
res = raycast.get_latest_result_from_raycast_sequence(1)
print(res)
def callback(ray, result):
if result.valid:
print("Hit position:", Gf.Vec3d(*result.hit_position))
print("Hit t:", result.hit_t)
print("Normal:", Gf.Vec3d(*result.normal))
print("Instance ID:", result.instance_id)
print("Primitive ID:", result.primitive_id)
print("Hit USD path:", result.get_target_usd_path())
else:
print("No hit detected.")
print("Single raycast query:")
raycast.submit_raycast_query(ray, callback)
I’m looking up the results with get_latest.result_from-raycast.sequence (1), but the results are all false. The reason the adderraycast sequence was not used was because it would cause a crash.
We have some good examples of this in the Physics Demo samples. If you enable the Physics Bundle from Extension manager, and then once that is loaded and enabled, go to Window > Physics Demos, we have some examples in there.
Thank you for your reply. I looked at the content you mentioned, and I found that it mostly used PhysX’s raycast feature, and some were based on the Action graph. I need to act on an arbitrary triangular mesh, but PhysX’s raycast can only act on a rigid body. OMNI. Kit. Raycast’s introduction is said to be based on RTX Raycast Queries, which is perfect for what I’m trying to do. I wanted to find out how to do lots of Raycast calculations at the same time, but every time I used the add_raycast_sequence, my whole program crashed.
Well then I would try to ramp up that “n” number slowly and see when it crashes. Does it crash with one query, no. Does it crash with 10, no. What about 100 and just keep refining the n number. And that may be either the limit of our code or the limit of your system.
I can ask about this as well.
In my tests, this had nothing to do with the number of rays (“n”), and my biggest doubt was that my code would crash just by calling sequence_id = raycast.add_raycast_sequence().
import omni.kit.raycast.query
from pxr import Gf, UsdGeom
raycast = omni.kit.raycast.query.acquire_raycast_query_interface()
stage = omni.usd.get_context().get_stage()
CUBE_PATH = "/Cube"
cube = UsdGeom.Cube.Define(stage, CUBE_PATH)
UsdGeom.XformCommonAPI(cube.GetPrim()).SetTranslate(Gf.Vec3d(0, 0, 0))
sequence_id = raycast.add_raycast_sequence()
ray = omni.kit.raycast.query.Ray(
origin=(1000, 0, 0),
direction=(-1, 0, 0),
min_t=0.0,
max_t=float('inf'),
adjust_for_section=True
)
raycast.submit_ray_to_raycast_sequence(sequence_id, ray)
res = raycast.get_latest_result_from_raycast_sequence(sequence_id)
print(res)
I ran the same code on both computers, and both used isaac - sim and kit-app-template, and the result was a crash. Configured as follows
---------------------------------------------------------------------------------------------|
| Driver Version: 572.83 | Graphics API: D3D12
|=============================================================================================|
| GPU | Name | Active | LDA | GPU Memory | Vendor-ID | LUID |
| | | | | | Device-ID | UUID |
| | | | | | Bus-ID | |
|---------------------------------------------------------------------------------------------|
| 0 | NVIDIA GeForce RTX 3070 Ti Lap.. | Yes: 0 | | 8018 MB | 10de | 74260100.. |
| | | | | | 24a0 | 0 |
| | | | | | 1 | |
|=============================================================================================|
| OS: Windows 11 Home China, Version: 10.0 (23H2), Build: 22631, Kernel: 10.0.22621.5037
| Processor: 12th Gen Intel(R) Core™ i7-12700H
| Cores: 14 | Logical Cores: 20
|---------------------------------------------------------------------------------------------|
| Total Memory (MB): 32508 | Free Memory: 17672
| Total Page/Swap (MB): 34556 | Free Page/Swap: 16954
Driver Version: 560.94 | Graphics API: D3D12
|=============================================================================================|
| GPU | Name | Active | LDA | GPU Memory | Vendor-ID | LUID |
| | | | | | Device-ID | UUID |
| | | | | | Bus-ID | |
|---------------------------------------------------------------------------------------------|
| 0 | NVIDIA GeForce RTX 3080 | Yes: 0 | | 10053 MB | 10de | 8da60500.. |
| | | | | | 2216 | 0 |
| | | | | | 73 | |
|=============================================================================================|
| OS: Windows 11 Pro, Version: 10.0 (21H2), Build: 22000, Kernel: 10.0.22000.2538
| Processor: Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz
| Cores: 20 | Logical Cores: 40
|---------------------------------------------------------------------------------------------|
| Total Memory (MB): 261790 | Free Memory: 202105
| Total Page/Swap (MB): 303757 | Free Page/Swap: 173072