-
Notifications
You must be signed in to change notification settings - Fork 108
Adds raycast implementation and tests #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
18dfe90
Initial draft of ray cast queries
nvtw f65d95a
Add missing test files
nvtw 92ed8d5
Fix a couple of errors
nvtw 848b6fb
Fix more warp compatibility issues
nvtw 2a90a61
Adapting the tests to warp
nvtw fba0207
Tetrahedron test working
nvtw bc44ac5
Forgot to save a file
nvtw 62f9fd5
Add early out
nvtw b2038cb
Fix dodecahedron test
nvtw 62077a4
Started to introduce geomgroup
nvtw daa4241
First draft of filter logic
nvtw 0a301cd
test_ray_flg_static and test_ray_bodyexclude start to work
nvtw a8d58c9
All tests pass
nvtw b1397fc
Merge branch 'main' into dev/tw/ray_casting
nvtw 815fd29
Fix linter issues
nvtw 0f77d28
Implement first round of MR remarks
nvtw 279a5e4
Make _ray_box more similar to mujoco
nvtw 6cf2bf6
Follow the original even more closely
nvtw bf609ec
Add test test_ray_invisible
nvtw 844cf8a
Rename ray_geom to ray
nvtw e666462
Merge branch 'main' into dev/tw/ray_casting
nvtw 8b3e6fd
Merge branch 'main' into dev/tw/ray_casting
nvtw 2587108
Merge branch 'main' into dev/tw/ray_casting
nvtw 0cd1b17
Fixed cpu implementation
nvtw 6dbc655
Merge branch 'main' into dev/tw/ray_casting
nvtw af389a6
Merge branch 'main' into dev/tw/ray_casting
nvtw 3531da5
Reset io.py and types.py to the state of master since the merge was t…
nvtw 7e1b50c
Bring back vec6 type
nvtw 1eb27b5
Avoid using full model and data classes in ray casting
nvtw 0388b72
Fix tests
nvtw 697b593
Fix style issues
nvtw 1b41b2e
Add overload for _ray_geom as requested in MR
nvtw b8bd380
Removed unused stl file
nvtw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,8 @@ def put_model(mjm: mujoco.MjModel) -> types.Model: | |
| m.nwrap = mjm.nwrap | ||
| m.nsensor = mjm.nsensor | ||
| m.nsensordata = mjm.nsensordata | ||
| m.nmeshvert = mjm.nmeshvert | ||
| m.nmeshface = mjm.nmeshface | ||
| m.nlsp = mjm.opt.ls_iterations # TODO(team): how to set nlsp? | ||
| m.nexclude = mjm.nexclude | ||
| m.neq = mjm.neq | ||
|
|
@@ -227,10 +229,15 @@ def put_model(mjm: mujoco.MjModel) -> types.Model: | |
| tile_beg = tile_corners[i] | ||
| tile_end = mjm.nv if i == len(tile_corners) - 1 else tile_corners[i + 1] | ||
| tiles.setdefault(tile_end - tile_beg, []).append(tile_beg) | ||
| qLD_tile = np.concatenate([tiles[sz] for sz in sorted(tiles.keys())]) | ||
| tile_off = [0] + [len(tiles[sz]) for sz in sorted(tiles.keys())] | ||
| qLD_tileadr = np.cumsum(tile_off)[:-1] | ||
| qLD_tilesize = np.array(sorted(tiles.keys())) | ||
| if tiles: | ||
| qLD_tile = np.concatenate([tiles[sz] for sz in sorted(tiles.keys())]) | ||
| tile_off = [0] + [len(tiles[sz]) for sz in sorted(tiles.keys())] | ||
| qLD_tileadr = np.cumsum(tile_off)[:-1] | ||
| qLD_tilesize = np.array(sorted(tiles.keys())) | ||
| else: | ||
| qLD_tile = np.array([], dtype=int) | ||
| qLD_tileadr = np.array([], dtype=int) | ||
| qLD_tilesize = np.array([], dtype=int) | ||
|
|
||
| # tiles for actuator_moment - needs nu + nv tile size and offset | ||
| actuator_moment_offset_nv = np.empty(shape=(0,), dtype=int) | ||
|
|
@@ -243,7 +250,7 @@ def put_model(mjm: mujoco.MjModel) -> types.Model: | |
| # how many actuators for each tree | ||
| tile_corners = [i for i in range(mjm.nv) if mjm.dof_parentid[i] == -1] | ||
| tree_id = mjm.dof_treeid[tile_corners] | ||
| num_trees = int(np.max(tree_id)) | ||
| num_trees = int(np.max(tree_id)) if len(tree_id) > 0 else 0 | ||
| tree = mjm.body_treeid[mjm.jnt_bodyid[mjm.actuator_trnid[:, 0]]] | ||
| counts, ids = np.histogram(tree, bins=np.arange(0, num_trees + 2)) | ||
| acts_per_tree = dict(zip([int(i) for i in ids], [int(i) for i in counts])) | ||
|
|
@@ -363,9 +370,12 @@ def put_model(mjm: mujoco.MjModel) -> types.Model: | |
| m.geom_aabb = wp.array(mjm.geom_aabb, dtype=wp.vec3, ndim=3) | ||
| m.geom_rbound = wp.array(mjm.geom_rbound, dtype=wp.float32, ndim=1) | ||
| m.geom_dataid = wp.array(mjm.geom_dataid, dtype=wp.int32, ndim=1) | ||
| m.geom_group = wp.array(mjm.geom_group, dtype=wp.int32, ndim=1) | ||
| m.mesh_vertadr = wp.array(mjm.mesh_vertadr, dtype=wp.int32, ndim=1) | ||
| m.mesh_vertnum = wp.array(mjm.mesh_vertnum, dtype=wp.int32, ndim=1) | ||
| m.mesh_vert = wp.array(mjm.mesh_vert, dtype=wp.vec3, ndim=1) | ||
| m.mesh_faceadr = wp.array(mjm.mesh_faceadr, dtype=wp.int32, ndim=1) | ||
| m.mesh_face = wp.array(mjm.mesh_face, dtype=wp.int32, ndim=2) | ||
|
||
| m.eq_type = wp.array(mjm.eq_type, dtype=wp.int32, ndim=1) | ||
| m.eq_obj1id = wp.array(mjm.eq_obj1id, dtype=wp.int32, ndim=1) | ||
| m.eq_obj2id = wp.array(mjm.eq_obj2id, dtype=wp.int32, ndim=1) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the api function should be
raymujoco reference
mj_ray: https://github.com/google-deepmind/mujoco/blob/f317bd17c3494b954982de7bcf14030978d5013b/src/engine/engine_ray.c#L1145mjx reference
ray: https://github.com/google-deepmind/mujoco/blob/f317bd17c3494b954982de7bcf14030978d5013b/mjx/mujoco/mjx/__init__.py#L37