@@ -117,11 +117,11 @@ public class MuJoCoLib extends org.mujoco.MuJoCoConfig {
117117
118118
119119// this is a C-API
120- // #if defined( __cplusplus)
120+ // #ifdef __cplusplus
121121// #endif
122122
123123// header version; should match the library version as returned by mj_version()
124- public static final int mjVERSION_HEADER = 311 ;
124+ public static final int mjVERSION_HEADER = 313 ;
125125
126126// needed to define size_t, fabs and log10
127127// #include <stdlib.h>
@@ -211,9 +211,9 @@ public static class Mju_user_free_Pointer extends FunctionPointer {
211211public static native int mj_addFileVFS (mjVFS vfs , @ Cast ("const char*" ) BytePointer directory , @ Cast ("const char*" ) BytePointer filename );
212212public static native int mj_addFileVFS (mjVFS vfs , String directory , String filename );
213213
214- // Make empty file in VFS, return 0: success, 1: full, 2: repeated name.
215- public static native int mj_makeEmptyFileVFS (mjVFS vfs , @ Cast ("const char*" ) BytePointer filename , int filesize );
216- public static native int mj_makeEmptyFileVFS (mjVFS vfs , String filename , int filesize );
214+ // Add file to VFS from buffer , return 0: success, 1: full, 2: repeated name, -1: failed to load .
215+ public static native int mj_addBufferVFS (mjVFS vfs , @ Cast ("const char*" ) BytePointer name , @ Const Pointer buffer , int nbuffer );
216+ public static native int mj_addBufferVFS (mjVFS vfs , String name , @ Const Pointer buffer , int nbuffer );
217217
218218// Return file index in VFS, or -1 if not found in VFS.
219219public static native int mj_findFileVFS (@ Const mjVFS vfs , @ Cast ("const char*" ) BytePointer filename );
@@ -226,6 +226,9 @@ public static class Mju_user_free_Pointer extends FunctionPointer {
226226// Delete all files from VFS.
227227public static native void mj_deleteVFS (mjVFS vfs );
228228
229+ // deprecated: use mj_copyBufferVFS.
230+ public static native int mj_makeEmptyFileVFS (mjVFS vfs , @ Cast ("const char*" ) BytePointer filename , int filesize );
231+ public static native int mj_makeEmptyFileVFS (mjVFS vfs , String filename , int filesize );
229232
230233//---------------------------------- Parse and compile ---------------------------------------------
231234
@@ -336,16 +339,20 @@ public static native int mj_printSchema(String filename, @Cast("char*") byte[] b
336339// Reset data to defaults, fill everything else with debug_value.
337340public static native void mj_resetDataDebug (@ Const mjModel m , mjData d , @ Cast ("unsigned char" ) byte debug_value );
338341
339- // Reset data, set fields from specified keyframe.
342+ // Reset data. If 0 <= key < nkey , set fields from specified keyframe.
340343public static native void mj_resetDataKeyframe (@ Const mjModel m , mjData d , int key );
341344
345+ // #ifndef ADDRESS_SANITIZER
346+
342347// Mark a new frame on the mjData stack.
343348public static native void mj_markStack (mjData d );
344349
345350// Free the current mjData stack frame. All pointers returned by mj_stackAlloc since the last call
346351// to mj_markStack must no longer be used afterwards.
347352public static native void mj_freeStack (mjData d );
348353
354+ // #endif // ADDRESS_SANITIZER
355+
349356// Allocate a number of bytes on mjData stack at a specific alignment.
350357// Call mju_error on stack overflow.
351358public static native Pointer mj_stackAllocByte (mjData d , @ Cast ("size_t" ) long bytes , @ Cast ("size_t" ) long alignment );
@@ -591,6 +598,9 @@ public static native void mj_jac(@Const mjModel m, @Const mjData d, @Cast("mjtNu
591598public static native void mj_jacPointAxis (@ Const mjModel m , mjData d , @ Cast ("mjtNum*" ) DoublePointer jacPoint , @ Cast ("mjtNum*" ) DoublePointer jacAxis ,
592599 @ Cast ("const mjtNum*" ) DoublePointer point , @ Cast ("const mjtNum*" ) DoublePointer axis , int body );
593600
601+ // Compute subtree angular momentum matrix.
602+ public static native void mj_angmomMat (@ Const mjModel m , mjData d , @ Cast ("mjtNum*" ) DoublePointer mat , int body );
603+
594604// Get id of object with the specified mjtObj type and name, returns -1 if id not found.
595605public static native int mj_name2id (@ Const mjModel m , int type , @ Cast ("const char*" ) BytePointer name );
596606public static native int mj_name2id (@ Const mjModel m , int type , String name );
@@ -1345,7 +1355,7 @@ public static native void mju_bandMulMatVec(@Cast("mjtNum*") DoublePointer res,
13451355// Address of diagonal element i in band-dense matrix representation.
13461356public static native int mju_bandDiag (int i , int ntotal , int nband , int ndense );
13471357
1348- // Eigenvalue decomposition of symmetric 3x3 matrix.
1358+ // Eigenvalue decomposition of symmetric 3x3 matrix, mat = eigvec * diag(eigval) * eigvec' .
13491359public static native int mju_eig3 (@ Cast ("mjtNum*" ) DoublePointer eigval , @ Cast ("mjtNum*" ) DoublePointer eigvec , @ Cast ("mjtNum*" ) DoublePointer quat , @ Cast ("const mjtNum*" ) DoublePointer mat );
13501360
13511361// minimize 0.5*x'*H*x + x'*g s.t. lower <= x <= upper, return rank or -1 if failed
@@ -1597,8 +1607,26 @@ public static native void mjd_quatIntegrate(@Cast("const mjtNum*") DoublePointer
15971607// Wait for a task to complete.
15981608public static native void mju_taskJoin (mjTask task );
15991609
1610+ //---------------------- Sanitizer instrumentation helpers -----------------------------------------
1611+ //
1612+ // Most MuJoCo users can ignore these functions, the following comments are aimed primarily at
1613+ // MuJoCo developers.
1614+ //
1615+ // When built and run under address sanitizer (asan), mj_markStack and mj_freeStack are instrumented
1616+ // to detect leakage of mjData stack frames. When the compiler inlines several callees that call
1617+ // into mark/free into the same function, this instrumentation requires that the compiler retains
1618+ // separate mark/free calls for each original callee. The memory-clobbered asm blocks act as a
1619+ // barrier to prevent mark/free calls from being combined under optimization.
16001620
1601- // #if defined(__cplusplus)
1621+ // #ifdef ADDRESS_SANITIZER
1622+
1623+
1624+
1625+
1626+
1627+ // #endif // ADDRESS_SANITIZER
1628+
1629+ // #ifdef __cplusplus
16021630// #endif
16031631
16041632// #endif // MUJOCO_MUJOCO_H_
@@ -1676,7 +1704,7 @@ public static native void mjd_quatIntegrate(@Cast("const mjtNum*") DoublePointer
16761704// #ifndef MUJOCO_INCLUDE_MJTHREAD_H_
16771705// #define MUJOCO_INCLUDE_MJTHREAD_H_
16781706
1679- public static final int mjMAXTHREADS = 128 ; // maximum number of threads in a thread pool
1707+ public static final int mjMAXTHREAD = 128 ; // maximum number of threads in a thread pool
16801708
16811709/** enum mjtTaskStatus */
16821710public static final int // status values for mjTask
@@ -1844,10 +1872,9 @@ public static class mjTask_ extends Pointer {
18441872
18451873 // breakdown of mj_collision
18461874 mjTIMER_COL_BROAD = 13 , // broadphase
1847- mjTIMER_COL_MID = 14 , // midphase
1848- mjTIMER_COL_NARROW = 15 , // narrowphase
1875+ mjTIMER_COL_NARROW = 14 , // narrowphase
18491876
1850- mjNTIMER = 16 ; // number of timers
1877+ mjNTIMER = 15 ; // number of timers
18511878
18521879
18531880//---------------------------------- mjContact -----------------------------------------------------
@@ -2044,7 +2071,7 @@ public static class mjData_ extends Pointer {
20442071 // memory utilization stats
20452072 public native @ Cast ("size_t" ) long maxuse_stack (); public native mjData_ maxuse_stack (long setter ); // maximum stack allocation in bytes
20462073 public native @ Cast ("size_t" ) long maxuse_threadstack (int i ); public native mjData_ maxuse_threadstack (int i , long setter );
2047- @ MemberGetter public native @ Cast ("size_t*" ) SizeTPointer maxuse_threadstack (); // maximum stack allocation per thread in bytes
2074+ @ MemberGetter public native @ Cast ("size_t*" ) SizeTPointer maxuse_threadstack (); // maximum stack allocation per thread in bytes
20482075 public native @ Cast ("size_t" ) long maxuse_arena (); public native mjData_ maxuse_arena (long setter ); // maximum arena allocation in bytes
20492076 public native int maxuse_con (); public native mjData_ maxuse_con (int setter ); // maximum number of contacts
20502077 public native int maxuse_efc (); public native mjData_ maxuse_efc (int setter ); // maximum number of scalar constraints
@@ -2350,6 +2377,7 @@ public static class mjData_ extends Pointer {
23502377// #define MUJOCO_MJMODEL_H_
23512378
23522379// #include <stddef.h>
2380+ // #include <stdint.h>
23532381
23542382
23552383// #include <mujoco/mjtnum.h>
@@ -2761,14 +2789,16 @@ public static class mjVFS_ extends Pointer {
27612789 @ Override public mjVFS_ getPointer (long i ) {
27622790 return new mjVFS_ ((Pointer )this ).offsetAddress (i );
27632791 }
2764- // virtual file system for loading from memory
2792+ // virtual file system for loading from memory
27652793 public native int nfile (); public native mjVFS_ nfile (int setter ); // number of files present
27662794 public native @ Cast ("char" ) byte filename (int i , int j ); public native mjVFS_ filename (int i , int j , byte setter );
27672795 @ MemberGetter public native @ Cast ("char*" ) BytePointer filename (); // file name without path
27682796 public native @ Cast ("size_t" ) long filesize (int i ); public native mjVFS_ filesize (int i , long setter );
27692797 @ MemberGetter public native @ Cast ("size_t*" ) SizeTPointer filesize (); // file size in bytes
27702798 public native Pointer filedata (int i ); public native mjVFS_ filedata (int i , Pointer setter );
27712799 @ MemberGetter public native @ Cast ("void**" ) PointerPointer filedata (); // buffer with file data
2800+ public native @ Cast ("uint64_t" ) long filestamp (int i ); public native mjVFS_ filestamp (int i , long setter );
2801+ @ MemberGetter public native @ Cast ("uint64_t*" ) LongPointer filestamp (); // checksum of the file data
27722802}
27732803@ Opaque public static class mjVFS extends Pointer {
27742804 /** Empty constructor. Calls {@code super((Pointer)null)}. */
@@ -2880,6 +2910,7 @@ public static class mjVisual_ extends Pointer {
28802910 @ Name ("global.offwidth" ) public native int global_offwidth (); public native mjVisual_ global_offwidth (int setter ); // width of offscreen buffer
28812911 @ Name ("global.offheight" ) public native int global_offheight (); public native mjVisual_ global_offheight (int setter ); // height of offscreen buffer
28822912 @ Name ("global.ellipsoidinertia" ) public native int global_ellipsoidinertia (); public native mjVisual_ global_ellipsoidinertia (int setter ); // geom for inertia visualization (0: box, 1: ellipsoid)
2913+ @ Name ("global.bvactive" ) public native int global_bvactive (); public native mjVisual_ global_bvactive (int setter ); // visualize active bounding volumes (0: no, 1: yes)
28832914 // rendering quality
28842915 @ Name ("quality.shadowsize" ) public native int quality_shadowsize (); public native mjVisual_ quality_shadowsize (int setter ); // size of shadowmap texture
28852916 @ Name ("quality.offsamples" ) public native int quality_offsamples (); public native mjVisual_ quality_offsamples (int setter ); // number of multisamples for offscreen rendering
@@ -2973,6 +3004,10 @@ public static class mjVisual_ extends Pointer {
29733004 @ Name ("rgba.crankbroken" ) @ MemberGetter public native FloatPointer rgba_crankbroken (); // used when crank must be stretched/broken
29743005 @ Name ("rgba.frustum" ) public native float rgba_frustum (int i ); public native mjVisual_ rgba_frustum (int i , float setter );
29753006 @ Name ("rgba.frustum" ) @ MemberGetter public native FloatPointer rgba_frustum (); // camera frustum
3007+ @ Name ("rgba.bv" ) public native float rgba_bv (int i ); public native mjVisual_ rgba_bv (int i , float setter );
3008+ @ Name ("rgba.bv" ) @ MemberGetter public native FloatPointer rgba_bv (); // bounding volume
3009+ @ Name ("rgba.bvactive" ) public native float rgba_bvactive (int i ); public native mjVisual_ rgba_bvactive (int i , float setter );
3010+ @ Name ("rgba.bvactive" ) @ MemberGetter public native FloatPointer rgba_bvactive (); // active bounding volume
29763011}
29773012@ Opaque public static class mjVisual extends Pointer {
29783013 /** Empty constructor. Calls {@code super((Pointer)null)}. */
@@ -3344,15 +3379,15 @@ public static class mjModel_ extends Pointer {
33443379 public native IntPointer mesh_texcoordadr (); public native mjModel_ mesh_texcoordadr (IntPointer setter ); // texcoord data address; -1: no texcoord (nmesh x 1)
33453380 public native IntPointer mesh_texcoordnum (); public native mjModel_ mesh_texcoordnum (IntPointer setter ); // number of texcoord (nmesh x 1)
33463381 public native IntPointer mesh_graphadr (); public native mjModel_ mesh_graphadr (IntPointer setter ); // graph data address; -1: no graph (nmesh x 1)
3347- public native @ Cast ("mjtNum*" ) DoublePointer mesh_pos (); public native mjModel_ mesh_pos (DoublePointer setter ); // translation applied to asset vertices (nmesh x 3)
3348- public native @ Cast ("mjtNum*" ) DoublePointer mesh_quat (); public native mjModel_ mesh_quat (DoublePointer setter ); // rotation applied to asset vertices (nmesh x 4)
33493382 public native FloatPointer mesh_vert (); public native mjModel_ mesh_vert (FloatPointer setter ); // vertex positions for all meshes (nmeshvert x 3)
33503383 public native FloatPointer mesh_normal (); public native mjModel_ mesh_normal (FloatPointer setter ); // normals for all meshes (nmeshnormal x 3)
33513384 public native FloatPointer mesh_texcoord (); public native mjModel_ mesh_texcoord (FloatPointer setter ); // vertex texcoords for all meshes (nmeshtexcoord x 2)
33523385 public native IntPointer mesh_face (); public native mjModel_ mesh_face (IntPointer setter ); // vertex face data (nmeshface x 3)
33533386 public native IntPointer mesh_facenormal (); public native mjModel_ mesh_facenormal (IntPointer setter ); // normal face data (nmeshface x 3)
33543387 public native IntPointer mesh_facetexcoord (); public native mjModel_ mesh_facetexcoord (IntPointer setter ); // texture face data (nmeshface x 3)
33553388 public native IntPointer mesh_graph (); public native mjModel_ mesh_graph (IntPointer setter ); // convex graph data (nmeshgraph x 1)
3389+ public native @ Cast ("mjtNum*" ) DoublePointer mesh_pos (); public native mjModel_ mesh_pos (DoublePointer setter ); // translation applied to asset vertices (nmesh x 3)
3390+ public native @ Cast ("mjtNum*" ) DoublePointer mesh_quat (); public native mjModel_ mesh_quat (DoublePointer setter ); // rotation applied to asset vertices (nmesh x 4)
33563391 public native IntPointer mesh_pathadr (); public native mjModel_ mesh_pathadr (IntPointer setter ); // address of asset path for mesh; -1: none (nmesh x 1)
33573392
33583393 // skins
@@ -5334,6 +5369,8 @@ public static class mjResource_ extends Pointer {
53345369
53355370 public native @ Cast ("char*" ) BytePointer name (); public native mjResource_ name (BytePointer setter ); // name of resource (filename, etc)
53365371 public native Pointer data (); public native mjResource_ data (Pointer setter ); // opaque data pointer
5372+ public native @ Cast ("char" ) byte timestamp (int i ); public native mjResource_ timestamp (int i , byte setter );
5373+ @ MemberGetter public native @ Cast ("char*" ) BytePointer timestamp (); // timestamp of the resource
53375374 public native @ Const mjpResourceProvider provider (); public native mjResource_ provider (mjpResourceProvider setter ); // pointer to the provider
53385375}
53395376@ Opaque public static class mjResource extends Pointer {
@@ -5343,7 +5380,7 @@ public static class mjResource_ extends Pointer {
53435380 public mjResource (Pointer p ) { super (p ); }
53445381}
53455382
5346- // callback for opeing a resource, returns zero on failure
5383+ // callback for opening a resource, returns zero on failure
53475384public static class mjfOpenResource extends FunctionPointer {
53485385 static { Loader .load (); }
53495386 /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
@@ -5385,16 +5422,18 @@ public static class mjfGetResourceDir extends FunctionPointer {
53855422 public native void call (mjResource resource , @ Cast ("const char**" ) PointerPointer dir , IntPointer ndir );
53865423}
53875424
5388- // callback for checking if a resource was modified since last read
5389- // returns > 0 if resource was modified since last open, 0 if resource was not
5390- // modified, and < 0 if inconclusive
5425+ // callback for checking if the current resource was modified from the time
5426+ // specified by the timestamp
5427+ // returns 0 if the resource's timestamp matches the provided timestamp
5428+ // returns > 0 if the the resource is younger than the given timestamp
5429+ // returns < 0 if the resource is older than the given timestamp
53915430public static class mjfResourceModified extends FunctionPointer {
53925431 static { Loader .load (); }
53935432 /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
53945433 public mjfResourceModified (Pointer p ) { super (p ); }
53955434 protected mjfResourceModified () { allocate (); }
53965435 private native void allocate ();
5397- public native int call (@ Const mjResource resource );
5436+ public native int call (@ Const mjResource resource , @ Cast ( "const char*" ) BytePointer timestamp );
53985437}
53995438
54005439// struct describing a single resource provider
0 commit comments