Commit Graph

135 Commits

Author SHA1 Message Date
Yuval Tassa f712eed4ce Allow flex sleeping
PiperOrigin-RevId: 917817500
Change-Id: Ia3bd5e52e7c2eaa3f70c81352d82c130b1d357f6
2026-05-19 07:15:27 -07:00
Alessio Quaglino a891782553 Clean-up flex assumptions.
Do not allow a mix of `elastic2d != none` with `dof = trilinear` since the latter assumes 3d elasticity.

Also, do not assume that `flex_interp > 0` in the engine. This will enable to use, e.g., `flex_interp = -1` to mean a linear surface finite element instead of a 3d finite element which is currently identified with `flex_interp = 1`.

PiperOrigin-RevId: 903852035
Change-Id: Ia6290b4a05e9e510ffb7f36d141cd525b40d3110
2026-04-22 08:01:34 -07:00
Alessio Quaglino 508e581ba9 Optimize flex by pinning nodes in empty cells.
This change introduces an optimization for flexcomp objects defined by a mesh. It identifies grid cells that do not contain any mesh vertices and marks them as empty. Nodes that are exclusively part of empty cells are pinned, preventing them from moving. Stiffness computations are skipped for empty cells, reducing computational cost. The total mass is now distributed only among the non-pinned nodes.

PiperOrigin-RevId: 902565735
Change-Id: Id0a9a685536d5e18a3e42124a25ab08ff3a918f2
2026-04-20 04:41:17 -07:00
Alessio Quaglino 6c7ed66781 Implement multi-cell finite element method for interpolated flexes.
This change introduces a `flex_cellcount` field to `mjModel` to specify the number of cells in each dimension for interpolated flexes. The stiffness computation, passive force calculation, and Jacobian derivatives are updated to operate on a per-cell basis, significantly improving performance by localizing computations to the nodes within each cell.

PiperOrigin-RevId: 901216393
Change-Id: Ic23132e609de11e71bb7fef8d1f139daad2ec264
2026-04-17 04:13:19 -07:00
Yuval Tassa 0e04436d51 Remove `mjWARN_VGEOMFULL, handle visual geom buffer full warnings in mjvScene`.
PiperOrigin-RevId: 896483023
Change-Id: I6dde2c20d8e8e229cf95e1f002dd10525d3376e6
2026-04-08 07:17:53 -07:00
Yuval Tassa efae9157a7 Polynomial stiffness and damping https://youtu.be/aKa3ZlEF9_Y
PiperOrigin-RevId: 884607673
Change-Id: If8088dbf37fed1055304778a7eb84dec52cba920
2026-03-16 13:25:25 -07:00
Kevin Zakka 77ce80bc63 Fix swapped vertical frustum bounds for cameras with principal point offset.
The frustum_top and frustum_bottom assignments in mjv_updateCamera used
the wrong elements of the zver array, causing the principal point cy
offset to be applied with an inverted sign. This shifted the rendered
image vertically by 2*cy pixels.
2026-03-04 01:03:55 -08:00
Yuval Tassa f3ad0eff2b Fix body category check for mocap body descendants in visualization.
PiperOrigin-RevId: 856179240
Change-Id: I29f4758fee0ff3b16d0b9f452c28e640b5558993
2026-01-14 06:06:55 -08:00
Yuval Tassa 70bc7be4bc Add additional data fields that can be reported by rangefinder sensors.
PiperOrigin-RevId: 848316991
Change-Id: Idbf7ba81b4da711a22c23302c8782ab2b0b98d82
2025-12-23 15:33:00 -08:00
Yuval Tassa 9d646e6548 Extend rangefinder sensor to support cameras.
PiperOrigin-RevId: 848255889
Change-Id: I6e1a9ed13d29d2242558625a47e24e47ad6e87db
2025-12-23 12:04:49 -08:00
Yuval Tassa c7f5766345 Add frustum visualization for orthographic cameras.
PiperOrigin-RevId: 847698917
Change-Id: I13633e8ba2d4718b127a5838c404ab74c6180e3d
2025-12-22 03:43:54 -08:00
Yuval Tassa b8a4ac5d48 Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
2025-12-20 03:28:29 -08:00
Yuval Tassa 6bcb22730d Minor clean-up of some visualization code.
Move mjvGeom acquire/release into helper functions, where possible.

PiperOrigin-RevId: 842675435
Change-Id: Ie5aaf206927251e79b20cc4101a7017645d5dd4b
2025-12-10 05:09:53 -08:00
Yuval Tassa 769f37b653 Implement sleeping in engine
PiperOrigin-RevId: 829361787
Change-Id: I6f64d8e25c4248cf32c18cd94d37ff5def78946e
2025-11-07 03:33:07 -08:00
Alessio Quaglino 3a7aa84e53 Add quadratic stiffness to flex.
PiperOrigin-RevId: 827409919
Change-Id: I3dff8ea49fb1726fec4acf5b91138d6d52c4bfba
2025-11-03 03:01:38 -08:00
Haroon Qureshi 66a1c22cae Label all bodies, not just selected bodies, when mjLABEL_BODY is set.
An earlier refactor incorrectly assumed that only selected bodies needed
labels.

PiperOrigin-RevId: 818568645
Change-Id: I7aea07c5342673dd589e1891d0db1f2b0c489fe4
2025-10-13 02:54:34 -07:00
Haroon Qureshi abe88202d0 Remove redundant flags argument.
PiperOrigin-RevId: 817115667
Change-Id: I4e5096206d7c24f5861e1bb9e8049149803dceeb
2025-10-09 04:07:43 -07:00
Haroon Qureshi 8e4932170a Remove unused params.
PiperOrigin-RevId: 816654011
Change-Id: Ib26bc90dcda167e8acf1feaa3b015acb5aa7aceb
2025-10-08 05:05:59 -07:00
Haroon Qureshi e7e331b11e Update sensor decor elements to be of type mjOBJ_SENSOR.
PiperOrigin-RevId: 816640568
Change-Id: I838608c0482ec1ee499fe9598ddb33aa6c5331e9
2025-10-08 04:17:40 -07:00
Haroon Qureshi 7b9f6a5cc1 Invert early-out checks to reduce nesting.
PiperOrigin-RevId: 816606107
Change-Id: I325d3f4695cdeb189694088d8a81b198d65f96ea
2025-10-08 02:21:14 -07:00
Haroon Qureshi a849fedcd2 Separate mjv_addGeoms into separate functions for each category.
PiperOrigin-RevId: 815607891
Change-Id: I16b29061c7e2229146bd0e0152721bca40fa4fd1
2025-10-06 01:30:26 -07:00
Haroon Qureshi 24679b47e4 Separate out site and geom frame construction.
PiperOrigin-RevId: 814677737
Change-Id: I623f9d1e23ac6b3076a577e97911f7ec73492f52
2025-10-03 06:56:53 -07:00
Haroon Qureshi 493d73062c Misc cleanup to addFrameGeoms.
PiperOrigin-RevId: 814582959
Change-Id: I2546bf1c13334628d379ad24737de095085e1b1f
2025-10-03 01:14:32 -07:00
Haroon Qureshi 6ed2ceaa83 Add non-decorative elements before decorative elements.
PiperOrigin-RevId: 814165875
Change-Id: Iab09e2fe1fa129b0c19760c969b5639e690a95d9
2025-10-02 03:59:06 -07:00
Yuval Tassa edbdb5195c Change MuJoCo engine source code function-spacing convention from 3 blank lines to 2
PiperOrigin-RevId: 813754244
Change-Id: I6836e41c3b021cb727e922c25c60f629b9814c93
2025-10-01 07:58:17 -07:00
Haroon Qureshi b1ae44d10f Refactor duplicated frame drawing logic into a utility function.
PiperOrigin-RevId: 813675737
Change-Id: I7f9094852f26b2ddc08534bf87cf2f71476d99ec
2025-10-01 03:36:14 -07:00
Haroon Qureshi f9d0bedb44 Minor cleanup: Move geom-related functions together.
PiperOrigin-RevId: 813661319
Change-Id: I6cdf74ff57f39f932ddd39268f15f1128ddf1df4
2025-10-01 02:46:45 -07:00
Haroon Qureshi 328a4ab293 Merge geomsExhausted into acquireGeom.
PiperOrigin-RevId: 813347956
Change-Id: I07bd566388383cc5c49e675f5b85fffb379ef6d1
2025-09-30 11:19:53 -07:00
Haroon Qureshi 59d0676dcc Remove redundant checks for exhausted geoms.
PiperOrigin-RevId: 813284297
Change-Id: I565c517bef782ba07ff323e206b75f6f905e5809
2025-09-30 08:44:17 -07:00
Haroon Qureshi 70d03adc71 Store the status of the scene in the scene itself.
PiperOrigin-RevId: 813119377
Change-Id: Iebff9e7796ca9809ea22902522982bfd96eeba06
2025-09-30 00:06:00 -07:00
Yuval Tassa fe8384b6c5 Visualize joint and tendon limits by re-coloring.
PiperOrigin-RevId: 811590674
Change-Id: I5b65f2294a4bcda3c321fb51ebf29501bd0d416d
2025-09-25 19:02:26 -07:00
Haroon Qureshi 0baac58999 Remove redundant ngeoms check.
PiperOrigin-RevId: 810787607
Change-Id: I5d04b1d7f5f8ad758960a46ff08cc47d2887e851
2025-09-24 02:21:35 -07:00
Yuval Tassa 33b09e0822 Stop using stack allocation for catenary drawing
PiperOrigin-RevId: 810434095
Change-Id: Iee8c01ff721c2af216c5725fc9eaf6267b2e5284
2025-09-23 07:37:34 -07:00
Haroon Qureshi 09e6723dab Remove unnecessary stack mark/free in engine_vis_visualize.c
PiperOrigin-RevId: 810391913
Change-Id: Id02f4dadba7ef08f60bb7726470082f45c5761c5
2025-09-23 04:53:50 -07:00
Haroon Qureshi 7fc6b29afd Replace PREPARE_NEXT_GEOM and FINISH_GEOM macros with functions.
PiperOrigin-RevId: 809940866
Change-Id: I1d45eede9ddf8606e7fd2a8caa2ed0224b0e24a7
2025-09-22 03:21:13 -07:00
Haroon Qureshi d9da8e2570 Replace RETURN_IF_GEOMS_EXHAUSTED macro with inlined code.
PiperOrigin-RevId: 809919921
Change-Id: Icf2afbd4168ebb18577b5915afa9d457001259d6
2025-09-22 02:03:19 -07:00
Haroon Qureshi d7500e0dec Split START macro into two parts: one for control flow and one for assignment.
PiperOrigin-RevId: 808497167
Change-Id: I4d78426af69d98f57600cb7fd76edaf5b20b0039
2025-09-18 03:23:12 -07:00
Yuval Tassa 7eab0117f7 Don't smooth tracking camera motion
PiperOrigin-RevId: 808110613
Change-Id: Ib8631e5ace6db7c7bb780f26b79a72e26e72f451
2025-09-17 05:25:17 -07:00
Yuval Tassa 52da7586dc Clean up includes in src/engine
PiperOrigin-RevId: 807726978
Change-Id: I02800deb79bfb3c328d941861ded9d817e8f6e32
2025-09-16 09:36:44 -07:00
Haroon Qureshi ad5f07e060 Extract functions from mjv_updateCamera for calculating frames and frustums.
PiperOrigin-RevId: 805770746
Change-Id: Id2a6022a2ee2e8b1a783debf54b470a9df81051a
2025-09-11 04:10:59 -07:00
Haroon Qureshi 017e7d5a73 Add light ids.
PiperOrigin-RevId: 805755907
Change-Id: I92a1b1ea4ce1495c2746fd518f33ab2d1ad81399
2025-09-11 03:20:44 -07:00
Yuval Tassa b9900db00e Extract memory allocation functions and core utilities
PiperOrigin-RevId: 801745499
Change-Id: Iaf05c3430769d3115743d8ab020d13148cb2eb59
2025-09-01 03:38:25 -07:00
Yuval Tassa 7c10a62f21 Improve island visualization colors and logic.
- Make island visualization off by default
- Give it the keyboard shortcut 'N'
- Use HSV island coloring

PiperOrigin-RevId: 796375514
Change-Id: I3cc8d6f8142412c771b2b8e57e82e70000727770
2025-08-18 05:03:41 -07:00
Alessio Quaglino 7baaa39846 Add SDF geom to test/testdata/model.xml.
Also, when a mesh has both an octree and a bvh, render only the octree.

PiperOrigin-RevId: 790680831
Change-Id: Iaf3896933f6728af4db1eaa83ff5b06558ab0d19
2025-08-04 03:53:51 -07:00
Alessio Quaglino 100b1a06fd Decrease opacity of taxels with zero value.
This prevents the taxels from being occluded by the convex hull for meshes that do not provide face connectivity.

PiperOrigin-RevId: 790420616
Change-Id: I543fd7b52e4625d921b6b5b5b77b4720020df42a
2025-08-03 08:36:39 -07:00
Alessio Quaglino 80befd64ae Do not cull mjGEOM_TRIANGLE.
PiperOrigin-RevId: 789723631
Change-Id: I8a5aaa78a9fe63458c07b823c7550846c14413b1
2025-08-01 05:28:30 -07:00
Alessio Quaglino 51babec9c5 Move tactile sensor to the engine.
PiperOrigin-RevId: 788863133
Change-Id: I3172ebb7641fa8146469da25cba7db794760e7b1
2025-07-30 05:27:44 -07:00
Copybara-Service 6416e548aa Merge pull request #2348 from jjyyxx:patch-3
PiperOrigin-RevId: 785518837
Change-Id: I2bbdcb6aea0ff3edfa354389ef758c2d34b93f68
2025-07-21 11:49:39 -07:00
Yuval Tassa 5e666635f6 Remove mjtVisFlag.mjVIS_FLEXBVH and mjvOption.oct_depth
PiperOrigin-RevId: 783355711
Change-Id: I1e11999d5c533925f1d07266aeca95598a5691ba
2025-07-15 09:08:22 -07:00
Alessio Quaglino 4ea778f2d3 Add octree support to MJX API.
Also, enable the touch sensor to use the octree SDF.

PiperOrigin-RevId: 783313462
Change-Id: I0032c2a7164f4770aa10a3612db3fd70bea954db
2025-07-15 06:44:43 -07:00