Commit Graph

889 Commits

Author SHA1 Message Date
Yuval Tassa 621ea29382 Improve error message for keyframe size mismatch. Fixes #2041
PiperOrigin-RevId: 671069582
Change-Id: Ie63d3bf2b543f7bb5e3c123093095e76a95b7b48
2024-09-04 12:58:31 -07:00
Kyle Bayes b9822e4347 Check hexahedron in polytope3 to make sure it contains the origin. Otherwise, EPA can return invalid results.
PiperOrigin-RevId: 671057312
Change-Id: Ieb21a77ea679ee5c18972d3a0375578d9a98405e
2024-09-04 12:17:54 -07:00
Kyle Bayes 79a5bd0915 Add better boundary tests in polytope3 for EPA.
PiperOrigin-RevId: 671038835
Change-Id: I259260a7b40e825678b52187bee4791266ae10c4
2024-09-04 11:25:44 -07:00
Yuval Tassa 8954a088ce Add automatic free-joint alignment.
PiperOrigin-RevId: 671010083
Change-Id: Ib7d60f75c7f545b1886703715663db8de77feeef
2024-09-04 10:07:33 -07:00
Alessio Quaglino ae4987026c Add tree element support to mjs_firstElement() and mjs_nextElement().
PiperOrigin-RevId: 671003046
Change-Id: I9e07d7c85c7218e9bded0f50af9db62d0f1e21e1
2024-09-04 09:46:24 -07:00
Alessio Quaglino d3dfa6f970 Add mjs_findElement() to find any element in a spec by name.
Also, remove mjs_findMesh() and mjs_findKeyframe().

PiperOrigin-RevId: 670978980
Change-Id: Id88b800eb8a4c5efc40866f72a4442bf1d1437d0
2024-09-04 08:24:22 -07:00
Alessio Quaglino 0e8c0b80eb add content_type to model in the XML schema.
PiperOrigin-RevId: 670961443
Change-Id: I98cd6bb61b50029cdd4f5b31e23d268989d136da
2024-09-04 07:25:55 -07:00
Kyle Bayes e9a85764ea Native CCD: Replace mju_malloc with C standard malloc, fix bug in computing v5 in polytope3, and add another warning in EPA.
PiperOrigin-RevId: 670939250
Change-Id: Ia0d8b7c78ed2ef7019f2a691c066b20e98dc1889
2024-09-04 05:53:31 -07:00
Yuval Tassa 3437361bfb Add reduced sparse dof-dof matrix structures to mjData.
PiperOrigin-RevId: 670919263
Change-Id: I3592de802ae84648d97230115c2e9c3437424968
2024-09-04 04:24:02 -07:00
Yuval Tassa 42eb669e4e Precompute mappings between M <-> D sparse representations.
PiperOrigin-RevId: 670898353
Change-Id: I4b15477b1b6eb4a64cf7d4a0bb5af8fcb95d4e45
2024-09-04 02:57:13 -07:00
Yuval Tassa 2d3d5415b7 Add mj_jacDot: Time derivative of kinematic Jacobian.
PiperOrigin-RevId: 670505417
Change-Id: Icf30cff5dc955e002bd2f5d5fb3a04f8388d0780
2024-09-03 04:49:47 -07:00
Taylor Howell 9cab5a42a4 Remove unnecessary normal vector computation from mju_wrap cylinder case.
PiperOrigin-RevId: 669010760
Change-Id: Ie3869a9f112ca88b2a7ec4990c402ef3e92d36a8
2024-08-29 11:46:38 -07:00
Yuval Tassa a1036b86d3 Allow connect constraints to be specified using sites.
PiperOrigin-RevId: 668925419
Change-Id: I10cb71e6706e617c830cd90d6d0836b94a5a8cfa
2024-08-29 07:10:51 -07:00
Yuval Tassa f3cfe7a84a Minor clean up in mj_jac.
PiperOrigin-RevId: 668395751
Change-Id: I5c3104ad59a5a709cf1639df663c864fa9d02399
2024-08-28 04:45:40 -07:00
Taylor Howell 3e701b2125 Fix tendon sphere wrapping when using external sidesite.
PiperOrigin-RevId: 668391942
Change-Id: I78b44e1f90bb26fa6f5544eeb884c8ea22e41d33
2024-08-28 04:30:07 -07:00
Yuval Tassa 72a0ab145d Refactor frustum drawing to use a local makeTriangle function.
PiperOrigin-RevId: 668168658
Change-Id: I0ee9038c36eb28e2c4a0a8c94bea7430f68c6b77
2024-08-27 15:42:31 -07:00
Kyle Bayes ddb29e9293 Fix bug in computing pos in EPA by replacing S2D with computing affine coordinates directly to recover the witness points.
PiperOrigin-RevId: 668006152
Change-Id: I1de33c5bb94de1a14523a88a5dff7d6ec984628e
2024-08-27 08:55:40 -07:00
Kyle Bayes cad8ca6ffd Do pre-checking when creating initial polytope for EPA.
PiperOrigin-RevId: 666807572
Change-Id: I64c3715dc72c24f9b6b2206b3568951bd8c2384a
2024-08-23 08:37:34 -07:00
Yuval Tassa 9d4f8edad9 Avoid pointer access in loop conditionals in engine_core_smooth.c
PiperOrigin-RevId: 666800203
Change-Id: Iec6ce752d0cac1a98809ab085ed8f94416f79e95
2024-08-23 08:13:52 -07:00
Kyle Bayes d360ea1ce6 Minor GJK + EPA improvements:
1. Correct stopping criteria for GJK.
2. Store witness points from EPA in mjCCDObj,
3. Get dir directly from EPA instead of computing dir from witness points.

PiperOrigin-RevId: 666791852
Change-Id: I6a168f635b57c17692d31da6f6076b48c32ff2e3
2024-08-23 07:44:30 -07:00
Alessio Quaglino 505d01a1c1 Add error handling to mj_recompile.
This CL adds error handling to the mj_recompile function. If the recompile fails, the function will return -1 and set the error message in the spec. The Python wrapper for mj_recompile will catch the error and raise a ValueError exception.

PiperOrigin-RevId: 666784579
Change-Id: I225eca1769ea839c782be3c03fc4ff1ea5885a48
2024-08-23 07:18:28 -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 2efbd31762 Add mjSAMEFRAME_BODYROT and mjSAMEFRAME_INERTIAROT frame alignment shortcuts.
PiperOrigin-RevId: 666318799
Change-Id: I0af1824d2bd9eaca7b48a9e33e09f873dd33b22d
2024-08-22 06:08:25 -07:00
Yuval Tassa 8b03daa09b Add mjtSameFrame enum to specify frame alignment of bodies with their children.
PiperOrigin-RevId: 666303674
Change-Id: I53dc56e1ca52afa280ae5abaf4158edc465fb1e0
2024-08-22 05:17:06 -07:00
Kyle Bayes f986a52e1e Compute witness points from EPA, and use witness points to determine pos and dir for contact.
PiperOrigin-RevId: 665791337
Change-Id: If33ca1f455804c4cda534508803f5c3e99c3c52a
2024-08-21 03:06:17 -07:00
Yuval Tassa ad9cd7301e Correctly apply frame transform to light direction.
PiperOrigin-RevId: 665340267
Change-Id: Ida16ddbf3a057ffd3e260b71180a45acbf749931
2024-08-20 06:48:11 -07:00
Yuval Tassa 5d91231d31 Rename mjBuffer to mjByteVec.
PiperOrigin-RevId: 664872558
Change-Id: I7b003374c390958667635fb21089faf2ece54b14
2024-08-19 10:40:26 -07:00
Yuval Tassa 4aab00fa2d Minor cleanups to body and joint compilers.
PiperOrigin-RevId: 664824939
Change-Id: I6014ff10683849e2926f1b1c8df8b6862192cd00
2024-08-19 08:43:10 -07:00
Yuval Tassa 0fa39164f7 Speed up mesh support function with warmstarts.
PiperOrigin-RevId: 664807396
Change-Id: I9124e65efd9140a8e858b7b6be0867c26961477b
2024-08-19 07:54:50 -07:00
Kyle Bayes 0bffd744f9 Add nativeccd flag. When this flag is enabled, general convex collision detection is handled natively, as opposed to using libccd.
PiperOrigin-RevId: 663859009
Change-Id: Ife18bb1de62f2154e4725fdf764484a18586b836
2024-08-16 14:08:35 -07:00
Yuval Tassa f864108c23 using for std::{string, string_view}, where helpful for readibility.
PiperOrigin-RevId: 663707900
Change-Id: Icbea374d5f99c7d267140d83f541f0ee872de8c1
2024-08-16 06:14:54 -07:00
Yuval Tassa e0e08aa597 Rename xml_native_writer variables to be consistent with xml_native_reader.
PiperOrigin-RevId: 663699130
Change-Id: If11ed48d3b30d3c6d09ca77e3d8048c2a3d9f054
2024-08-16 05:34:30 -07:00
Yuval Tassa 0bcaa85650 Fixed a bug wherein, for models that have both muscles and stateless actuators and used one of the implicit integrators, wrong derivatives would be computed.
PiperOrigin-RevId: 663680592
Change-Id: I5d72888cab19dd5e51f552f63fe0968db93f5dcd
2024-08-16 04:07:23 -07:00
Michael Ahn 9924d9ca89 Fixed incorrect mesh face circumradius calculation
- In 8e2f830, this was changed from `mju_norm3` to `mjuu_normvec`, but the
  latter will mutate its input to be normalized instead of just
returning the norm (the former was likely mistaken as `mju_normalize3`
which does mutate its input).
2024-08-15 20:53:57 -07:00
Alessio Quaglino e0e134ca63 Add plugin tests for mjSpec.
Fixes #1903.

PiperOrigin-RevId: 663352920
Change-Id: I3a9e17aec5694e49c20b542f4b0a4402f88a2f17
2024-08-15 10:19:53 -07:00
Kyle Bayes 64575f399b Add heightfield collision support for GJK + EPA implementation.
PiperOrigin-RevId: 663321119
Change-Id: I01a85ae15386c997bff4e9c6d71555a4380dfffe
2024-08-15 08:50:09 -07:00
Alessio Quaglino 4b88e9bebf Do not delete keyframes during mjs_detachBody.
PiperOrigin-RevId: 663281082
Change-Id: I6eedf8c5a3a422bcd78086f2fe30c2099f0b9d16
2024-08-15 06:10:43 -07:00
Yuval Tassa b2018ff506 Replace function with static array in engine_forward.c
PiperOrigin-RevId: 663268322
Change-Id: Ibd161a8eda55fc04cf37e465f0d0ac0adcfc7847
2024-08-15 05:11:38 -07:00
Kyle Bayes 7f09a7d8c6 Fix bug in S2D and improve readability of GJK + EPA code.
PiperOrigin-RevId: 663261102
Change-Id: Ibb1d801078cc02bc7ccec246be6dc50fa4f2be18
2024-08-15 04:35:15 -07:00
Yuval Tassa 1f5f9a8a67 Improve variable naming in xml_native_reader.cc
PiperOrigin-RevId: 663236609
Change-Id: I0a3af8432054172a3fe687867706eeef14a2529d
2024-08-15 02:42:30 -07:00
Yuval Tassa d932faa1d4 Flip order of cases in user_objects.cc (readability)
PiperOrigin-RevId: 663040865
Change-Id: I27d06a6a769d5bfc41189d270021b4fc1d4b5932
2024-08-14 13:49:11 -07:00
Alessio Quaglino 4c64e6f036 Add mocap state to SaveState/RestoreState and attached keyframes.
PiperOrigin-RevId: 662975257
Change-Id: I3edb44f34426525813033902caf31db16ad7b2ab
2024-08-14 10:42:49 -07:00
Alessio Quaglino 5927b3d4d9 Add time to attached keyframes.
PiperOrigin-RevId: 662886533
Change-Id: If9118a226250d2e806d184c9715c7e6a1390fd95
2024-08-14 05:47:43 -07:00
Alessio Quaglino 7be4df7e03 Add ctrl to attached keyframes.
PiperOrigin-RevId: 662878508
Change-Id: Ie273fae0220c8b257766cbbd90a880d44b901725
2024-08-14 05:14:49 -07:00
Alessio Quaglino afd7c73f44 Attach multiple keyframes.
Still missing: support for ctrl, mocap, and time.

PiperOrigin-RevId: 662871569
Change-Id: I8a418c4007663e3063d7146bd72db4eba78ddc5d
2024-08-14 04:42:54 -07:00
Alessio Quaglino 19aa68c2b2 Add keyframe support to attach.
Limitations:
- Supports attaching a single keyframe. If multiple keyframes are present in the child, only the first one will be attached.
- Does not support time, ctrl, mpos, mquat.
- If mjs_detachBody is used, all keyframes are removed.
PiperOrigin-RevId: 662517666
Change-Id: If6e3839471e1884afc14e1a75e7ce1957c2f3581
2024-08-13 08:00:01 -07:00
Kyle Bayes 39896f8064 Restructure mjCMesh for caching.
PiperOrigin-RevId: 662496475
Change-Id: I4c3a58a63ef2c3b1196b3e6b30eb556b5528ff7f
2024-08-13 06:40:36 -07:00
Copybara-Service 4ebf381b4d Merge pull request #1899 from saran-t:saran-t-patch-5
PiperOrigin-RevId: 662454010
Change-Id: Ie3d6c59dd787aefa3c95869a91451387783b6057
2024-08-13 03:51:18 -07:00
Saran Tunyasuvunakool 1132632627 Fix for benign UBsan signed-integer-overflow complaints.
When counting nl and nc, the nnz is optionally also counted when in sparse mode. However, the functions mj_nl and mj_nc unconditionally counts nnz into a temporary accumulator, then only afterwards check whether the output nnz pointer is NULL.

When not in sparse mode, ten_J_rownnz does not get initialized by mj_tendon, however mj_nl and mj_nc are accumulating potentially spurious data from ten_J_rownnz into the temporary accumulator. While the spurious result eventually gets discarded, UBsan nevertheless detects an integer overflow in the temporary accumulator.

PiperOrigin-RevId: 662443910
Change-Id: I78a9a088d4db7f16be779c7d669167d6fb3e4401
2024-08-13 03:08:41 -07:00
Saran Tunyasuvunakool acab66d799 Remove superfluous break statements. 2024-08-13 10:46:35 +01:00