Commit Graph

94 Commits

Author SHA1 Message Date
Yuval Tassa 395129bbd3 Improvements to lighting and replication logic in humanoid.xml and 22_humanoids.xml.
Minor fix to memory usage printing in simulate.

PiperOrigin-RevId: 683787943
Change-Id: I0a42dacc8af0e659c3817df57bceb76d9e4d5ae3
2024-10-08 15:36:22 -07:00
Yuval Tassa d3a1ca72d8 Report memory usage in simulate using percentage rather than decimal fraction.
PiperOrigin-RevId: 683098469
Change-Id: I7310848fb87e040996fcfc24991d45bf55872993
2024-10-07 02:37:58 -07:00
Yuval Tassa 088079eff0 Rename mpr_tolerance and mpr_iterations to ccd_tolerance and ccd_iterations.
PiperOrigin-RevId: 666438658
Change-Id: I23dbdf939b9ab581f0fca4445f95c5bb36f6b463
2024-08-22 12:01:54 -07:00
Yuval Tassa 24a555062d Rename mjDSBL_AUTORESETNAN to mjDSBL_AUTORESET.
- Expose in MJCF.
- Add documentation.
- Improve handling in simulate.

PiperOrigin-RevId: 657606140
Change-Id: I6a27c2f4842d7d4ae32642f2a6255e5f8f1f605a
2024-07-30 08:41:59 -07:00
Saran Tunyasuvunakool f62792594f Add a new disable flag mjDSBL_AUTORESETNAN.
PiperOrigin-RevId: 654677473
Change-Id: Id92383fe413729bf6697353aa6e0bc8a946ec7e8
2024-07-22 03:22:41 -07:00
Yuval Tassa 5a513a0afb simulate improvements
- Add RGBA color editing for visualization
- Make some separator sections closed by default

PiperOrigin-RevId: 646502122
Change-Id: Id863d983b7fb53e6bbe86a92833876e40b74a5d8
2024-06-25 09:16:25 -07:00
Emo Todorov ee6a1dba28 UI improvements. Fixes #1274.
Copybara import of the project:

--
a1297d997d0b3cc624bbd1e704ffb7fbb2c5db9d by Emo Todorov <etodorov@gmail.com>:

UI imrovements

When OpenGL buffer size is too small to hold entire UI with all sections open, older sections (as determined by latest mouse click) are automatically closed as needed.

To test this new functionality, uncomment the test near the top of mjui_resize().

UI items now have userid, which can be used for event handling.  It is set through the (new) last field of mjuiDef, called otherint.

Sections titles can now have a checkmark - in which case they are rendered differently. Set via mjuiDef.otherint: 0- none (as before), 1- rendering changed but box not shown, 2- box shown.  This can be used to label sections of special interest to the application.

--
b0405bfb3005586ef1d2656ea9cc43c608225927 by Emo Todorov <etodorov@gmail.com>:

more ui improvements

Implemented mjPRESERVE state for adding sections and separators, so you don't have to keep track of old states.

simulate.cc is now modified to use this new functionality.  I also made the separators in the Physics section collapsible. If you don't like it, change them back to state 1.

Also added functionality for handling section checkboxes.

--
10f4c49be62a6605a38b7c0c7bfae1629024ba31 by Emo Todorov <etodorov@gmail.com>:

even more ui improvements

Selection boxes that extend below the current UI height are finally rendered in full.

Sections and collapsible separators now have rounded corners. The radius can be controlled from theme spacing.

More theme color settings were added. In particular, color gradients can now be disabled (the two end colors are set independently).

--
96c2dc601a25d31c93b21f8e089d349e729e829e by Emo Todorov <etodorov@gmail.com>:

final ui improvements

Cleaned up the code a bit.

Added more control for color gradients.

--
c9eddb679f36df3f0745d37e3fa90c4e66ee6b98 by Emo Todorov <etodorov@gmail.com>:

bug fix

Fixed some rendering bugs in the new functionality.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/1749 from emotodorov:ui_improve ddfc21dbcf0482b8f0d5eacab21847c302f71440
PiperOrigin-RevId: 646060325
Change-Id: Idb27aae7cd0311d00f26387bcadf5891175e867d
2024-06-24 05:33:51 -07:00
Yuval Tassa 3f3b39bbb1 Fix type-related issues in dependent code. Remove hardcoded mjUSEDOUBLE. Add mjUSESINGLE compiler flag.
This CL does not change the default build behavior of MuJoCo. To use single-precision floating-point, build MuJoCo with `-DmjUSESINGLE`.

PiperOrigin-RevId: 644782648
Change-Id: Ie815df9916798ca8054306437b39a33f84ce9e08
2024-06-19 10:52:18 -07:00
Yuval Tassa 6a532fc53e Fix bug in simulate noise injection logic.
Noise injection was occurring at every iteration of the physics thread, rather than before every call to `mj_step`, leading to time-step-dependent noise rate.

- Moved the logic from main.cc to a `Simulate::` method, called before `mj_step`.
- Reduced the maximum time-scale slider value back to 4 seconds (recent increase was due to this bug).

PiperOrigin-RevId: 643350296
Change-Id: I96832905e6614f92ac725298b16fcabe64ea1df1
2024-06-14 08:13:24 -07:00
Yuval Tassa c9bcf8371e Add mj_setKeyframe function to save current state in k-th model keyframe.
Fixes #1719.

Also improve documentation of `mju_sigmoid`, was previously only documented in changelog.

PiperOrigin-RevId: 642637458
Change-Id: I811a0bf8f881c8b76c9a62d2faec8fdec4e7585b
2024-06-12 09:22:52 -07:00
Yuval Tassa 07fc95ca9a Add orthographic cameras.
Orthographic cameras are specified by setting the `orthographic` attribute of the `<camera>` element. The `fovy` attribute is still used to specify the field-of-view, but its semantic is different for orthographic cameras. For orthographic cameras, the field-of-view is expressed in units of length, rather than degrees.

Other related changes:

* Fix bug in the ordering of `cam_xxx` elements in `mjModel`.
* Make camera visualization translucent only when the frustum is visualized.
* Added a button to `simulate` to toggle between perspective and orthographic free cameras.

https://youtu.be/ZXBTEIDWHhs

PiperOrigin-RevId: 642293435
Change-Id: Id090a421ad88ab404b5b27ddbbd6bfc81ad49bc5
2024-06-11 09:23:18 -07:00
Yuval Tassa 55e2c76c01 Use mj_resetDataKeyframe when loading key frames in simulate.
PiperOrigin-RevId: 608209431
Change-Id: I1ee78c837cbc098144143b90e8c0b4618568c9cf
2024-02-18 20:49:09 -08:00
Yuval Tassa eb844a4b77 When computing suitable initial font scale for a display, let 250% be the maximum size. Workaround for #1274.
PiperOrigin-RevId: 603791510
Change-Id: I37aa3431dcaf42dae8daa77ed87e108ca4d78ea0
2024-02-02 14:41:12 -08:00
Saran Tunyasuvunakool 914a001753 Update UI when rendering flags are changed via user_scn.
PiperOrigin-RevId: 603679619
Change-Id: If094836f97c8086a7f70bd235b8c8cc8ab69c639
2024-02-02 07:16:37 -08:00
Saran Tunyasuvunakool 7bb0ce4211 [Python Viewer] Allow users to override rendering flags via user_scn.
Fixes #1190

PiperOrigin-RevId: 603672602
Change-Id: I3ff1bb0dca7e913b36f1b241aaea8b8bb95cadff
2024-02-02 06:39:08 -08:00
Yuval Tassa fea7c10b95 Add bvhactive flag to visual/global. Fixes #1279.
PiperOrigin-RevId: 599778272
Change-Id: If5530629035cc68b198447503388f59a04041b13
2024-01-19 02:59:56 -08:00
Yuval Tassa 4c066a26b5 Change mjVISSTRING of connect and weld equality constraints from "Constraint" to "Equality". This is more consistent with the 'E' shortcut key and with mjDISABLESTRING ("constraint" means all constraints, "equality" means bilateral constraints).
Also remove unused ampersands from `mjVISSTRING` names, these are a remnant from a very old version of the UI framework.

PiperOrigin-RevId: 593469811
Change-Id: I0f6f73c9f5d2c61b2280f395f76434b0710ce4f3
2023-12-24 12:06:59 -08:00
Nimrod Gileadi 7cb7c87f70 Fix a few issues with the passive viewer.
1. Create an arena for the mjData instance used by the passive viewer visualization.

When using the passive viewer, stuff gets copied from the real mjData into a minimal struct.
That struct didn't have a stack, and now visualization for Flex does stack allocs.

2. Add missing a missing field in scene state for flex visualization.

3. Fix a memory leak where mjvScene wasn't released on exit in the passive viewer.

4. Add some locks in places where the render thread and Simulate::Sync collide.

This fixes #1280.

PiperOrigin-RevId: 591891676
Change-Id: I592f286cab9719c8d9af84e42f9756ea1f9f1971
2023-12-18 07:33:19 -08:00
Yuval Tassa dc0d0c59d4 Fix bug in simulate where the "LOADING..." label was not properly showing.
PiperOrigin-RevId: 591257979
Change-Id: Id09754b1e5a87decfb68b9fe305388aa8f0f5ed3
2023-12-15 08:12:28 -08:00
Yuval Tassa 35f095d7c5 When paused in simulate, add index of history scrubber if not 0.
PiperOrigin-RevId: 590184966
Change-Id: Id0914c41a1339cf71ebdea02ec486c52c3d37179
2023-12-12 06:43:37 -08:00
Alessio Quaglino 7cb84d45c1 Prevent integer overflow in history buffer for large models.
PiperOrigin-RevId: 585949038
Change-Id: Iabec5feedd1632b635583a608a5488b39e6bb9a2
2023-11-28 06:04:00 -08:00
Yuval Tassa 25ddb3e6e8 simulate: Add states to history when stepping with right arrow key.
PiperOrigin-RevId: 585613870
Change-Id: I7fb051946e8a91a900442e3d7048dfa8b8bd7c5c
2023-11-27 04:45:51 -08:00
Yuval Tassa 8693e0bba5 Stop actuator group disable from mistakenly binding to the number keys (should toggle geom groups, not actuators).
PiperOrigin-RevId: 583038620
Change-Id: Ibf339aed339b7ad862f61ac72298f43e717e3973
2023-11-16 07:34:58 -08:00
Yuval Tassa 7051ab99e0 Enable keyframe loading and saving in passive viewer. Fixes #1175
PiperOrigin-RevId: 582332757
Change-Id: Iff23359e670906c0e88a2d34273c493bc8cbe2af
2023-11-14 08:38:04 -08:00
Yuval Tassa 893c404230 Runtime disabling of actuators according to group.
Added `option-actuatorgroupdisable` attribute and associated `mjOption.disableactuator` integer bitfield, used to disable sets of actuators at runtime according to their group.

- The first 6 actuator groups are toggleable in the `simulate` viewer.
- Minor refactor and cleanup of actuator documentation.

https://youtu.be/H9qG9Zf2W44

Fixes #1092.

PiperOrigin-RevId: 578335600
Change-Id: I4cf663b90ea768e4380acfa2fe3b8c15c7cbb568
2023-10-31 16:24:38 -07:00
Yuval Tassa 8eb36d9a7c Improvements to simulate UI
- Improved Help overlay text, mention shortcuts for UI toggle.
- Removed buttons for UI toggle.
- Moved Spacing / Color / Font to the end of the Option section.

PiperOrigin-RevId: 576480554
Change-Id: Ie1427b97cb784421490c276a8544d570a6042188
2023-10-25 04:03:38 -07:00
Nimrod Gileadi 9393c690d4 Correctly handle full screen and vsync buttons.
Fixes #1110.

The code was using outdated indices since 48eb75ae92. It now uses the more stable pdata pointer.

PiperOrigin-RevId: 574805349
Change-Id: If6112fb2af7d60f17b35599233b24f33b6a8cac6
2023-10-19 03:38:11 -07:00
Alessio Quaglino 5a70ad08ab Add Flex component.
PiperOrigin-RevId: 572830650
Change-Id: I6908228087b7b9683be3506c8d9cdc725ed5dcd5
2023-10-12 10:49:35 +01:00
Saran Tunyasuvunakool ba03ebdadd Fix a segfault in the passive viewer on macOS.
The segfault is caused by a call to mjui_update outside of the macOS main thread, introduced in 3e12f0d50c.

PiperOrigin-RevId: 572531447
Change-Id: Ib8424c746d18a776c0b91087d9501aa8ee463026
2023-10-11 04:06:23 -07:00
Saran Tunyasuvunakool 2e15574b58 Allow user-defined visualization geoms to be added to the passive viewer.
Fixes #1023, #1082

PiperOrigin-RevId: 572303635
Change-Id: Ia8399f816f311b38a7b137f5bd4f359f77a1da1c
2023-10-10 10:52:21 -07:00
Saran Tunyasuvunakool a1b39d5959 Fix a segfault in simulate on mouse scroll without a loaded model.
Fixes #1089

PiperOrigin-RevId: 571985561
Change-Id: I4acc7c2a6032d678023783646c3f00cfe30641f2
2023-10-09 11:01:08 -07:00
Yuval Tassa e9613f0cc9 Rename simulate.fully_managed_ to simulate.is_passive_ with flipped semantics.
PiperOrigin-RevId: 570815258
Change-Id: Iaffdb0e52bcdb31cff7bd29cb820913e3838f0ee
2023-10-04 14:49:52 -07:00
Yuval Tassa 3e12f0d50c Add history scrubbing mechanism to simulate.
[screen capture](https://www.youtube.com/watch?v=YSvWn_poqWs)

PiperOrigin-RevId: 570676968
Change-Id: Id9a1fccc9418b851e007ddcf3fa89acd4edff3e9
2023-10-04 06:36:34 -07:00
Yuval Tassa 177aec68dc Add overlay positions in the center of viewport edges, move PAUSE and LOADING... overlays to the top center.
PiperOrigin-RevId: 570054949
Change-Id: If0046df382e67ad3a48e7138a75e9e200c0626b9
2023-10-02 07:05:50 -07:00
Levi Burner e7d1f2f110 simulate: fix display of loading message 2023-09-27 16:04:36 -04:00
Yuval Tassa 9cf1f6eba4 Remove mjOption.collision and associated option/collision attribute.
PiperOrigin-RevId: 566427090
Change-Id: I6e5873b8db707586820b17b53c7ab4bbff0f0b2b
2023-09-18 15:15:54 -07:00
Yuval Tassa 86d8b912f4 Rejigged solver statistics in preparation for islanding.
- See public description below.
- Stopped incrementing the iteration count in saveStats().
- `sizeof(mjSolverStat) == 40`, so this ends up costing 160KB, up from 40KB.

BEGIN_PUBLIC

Changed the size of `mjData.solver`, the structure used to collect solver diagnostic information. The array is now of length `mjNISLAND * mjNSOLVER`, where each row of length `mjNSOLVER` contains separate solver statistics for each constraint island. Until solver islanding is implemented, only row 0 is used.

- The new constant `mjNISLAND` is set to 20.
- `mjNSOLVER` is reduced from 1000 to 200.
- Added `mjData.solver_nisland`, the number of islands for which the solver ran.
- `mjData.solver_niter` (renamed from mjData.solver_iter) and `mjData.solver_nnz` are now integer vectors of length `mjNISLAND`.

END_PUBLIC

PiperOrigin-RevId: 565030093
Change-Id: I773e918805c6ced79f0dab5f19ea23956760c8c5
2023-09-13 06:18:37 -07:00
Yuval Tassa 48eb75ae92 In simulate, by default, keep updating profiler and sensor figures in Pause mode. Add UI option to disable.
PiperOrigin-RevId: 564710460
Change-Id: I893535e258ec2485d2ec997ecadfbdafba05bb99
2023-09-12 07:06:09 -07:00
Google DeepMind 040d3efce2 Add options for controlling early termination criteria of CG/Newton linesearch.
Useful for performance tuning models.

PiperOrigin-RevId: 563175078
Change-Id: Id64a510d6080038ea8d5876dabbf0b2b311435bb
2023-09-06 12:02:58 -07:00
Nimrod Gileadi 5279ce6f6f Fix comment typo in simulate.cc
PiperOrigin-RevId: 561921946
Change-Id: I423378df566be7a6ad88fb3526769d298ac32a3b
2023-09-01 04:56:34 -07:00
Saran Tunyasuvunakool daa2ac7f8b Rename nstack to narena, change it and pstack to count bytes.
PiperOrigin-RevId: 561066311
Change-Id: I4d0e645e6c254dd906bfc42159e0e99149a7c6c8
2023-08-29 10:13:33 -07:00
Alessio Quaglino fdb041580c Add Signed Distance Field to collision geometries.
PiperOrigin-RevId: 557507088
Change-Id: I358a642407aee1ba8dfc9d405eb9a4f609435fe9
2023-08-16 09:15:23 -07:00
Yuval Tassa ac3ac0d28f Fix timing plots issue in simulate.
Before this change timing plots would report zeros if the render thread was faster than the physics thread, making them unreadable when slowdown was used.

PiperOrigin-RevId: 557432042
Change-Id: Ie9a18fb84cab788d11dfbede4e3052f24441b4c4
2023-08-16 04:03:50 -07:00
Yuval Tassa 3e034e38b2 Add constraint island discovery
PiperOrigin-RevId: 557067599
Change-Id: Ic41e1d0efef02b7a79142518afe49cf9d4e74725
2023-08-15 02:30:05 -07:00
Yuval Tassa 6d7b49ccf5 Remove collision pruning statistics from simulate info panel.
PiperOrigin-RevId: 554452244
Change-Id: I4f9f1d5e38d4b4bc37b5a2f0980b352db04a73c6
2023-08-07 06:05:13 -07:00
Saran Tunyasuvunakool 0ccfef7314 Add update_{hfield,mesh,texture} methods to the passive viewer.
Fixes #812.
Fixes #958.
Fixes #965.

PiperOrigin-RevId: 548181282
Change-Id: I6eb0cd2ce52c66083e83dd08d69e0cfb4178dbba
2023-07-14 11:43:36 -07:00
Yuval Tassa 906a8e8b27 Correct shortening of camera name in simulate.cc (for UI menu item)
Fixes #963

PiperOrigin-RevId: 545187656
Change-Id: Ib213d693569d884915fba99f150df4fd5f53984c
2023-07-03 04:32:27 -07:00
Yuval Tassa d40c395917 Add Visualization tab to simulate.
Also:
- Increased label width in mjUI tight theme spacing.
- Added `mjITEM_EDITFLOAT` for editing float values.
- Move mjUI numpad key codes to header file.
PiperOrigin-RevId: 535839953
Change-Id: Ibdc0a9a20be514caa5b487211212ed6f5b8a6ba9
2023-05-27 05:08:15 -07:00
Yuval Tassa bb8044e5f3 Set minimum tree slider depth to 0.
PiperOrigin-RevId: 534003561
Change-Id: I42ccd0eab15b5a3c9852f8944c6b191f7999c113
2023-05-22 02:39:58 -07:00
Yuval Tassa 20e06ba353 Add missing braces.
PiperOrigin-RevId: 533419351
Change-Id: Iad54f6cb6d63c05e6a2f81526b22a914e2a23ba2
2023-05-19 04:35:12 -07:00