diff --git a/doc/changelog.rst b/doc/changelog.rst index 1f97f21f..33230ae5 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -9,17 +9,20 @@ General ^^^^^^^ 1. Improved the :ref:discardvisual compiler flag, which now discards all visual-only assets. See :ref:discardvisual for details. +2. Removed the :ref:`timer` for midphase colllision detection, it is now folded in with the narrowphase + timer. This is because timing the two phases seperately required fine-grained timers inside the collision + functions; these functions are so small and fast that the timer itself was incurring a measurable cost. MJX ^^^ -2. Added :ref:`dyntype` ``filterexact``. -3. Added :at:`site` transmission. -4. Updated MJX colab tutorial with more stable quadruped environment. -5. Added ``mjx.ray`` which mirrors :ref:`mj_ray` for planes, spheres, capsules, boxes, and meshes. +3. Added :ref:`dyntype` ``filterexact``. +4. Added :at:`site` transmission. +5. Updated MJX colab tutorial with more stable quadruped environment. +6. Added ``mjx.ray`` which mirrors :ref:`mj_ray` for planes, spheres, capsules, boxes, and meshes. Bug fixes ^^^^^^^^^ -6. Fixed a bug that prevented the use of pins with plugins if flexes are not in the worldbody. Fixes +7. Fixed a bug that prevented the use of pins with plugins if flexes are not in the worldbody. Fixes :github:issue:`1270`. 7. Fixed a bug in the :ref:`muscle model` that led to non-zero values outside the lower bound of the length range. Fixes :github:issue:`1342`. diff --git a/doc/includes/references.h b/doc/includes/references.h index cfee19fb..01504204 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -75,7 +75,6 @@ typedef enum mjtTimer_ { // internal timers // breakdown of mj_collision mjTIMER_COL_BROAD, // broadphase - mjTIMER_COL_MID, // midphase mjTIMER_COL_NARROW, // narrowphase mjNTIMER // number of timers diff --git a/include/mujoco/mjdata.h b/include/mujoco/mjdata.h index 53a42498..65886b38 100644 --- a/include/mujoco/mjdata.h +++ b/include/mujoco/mjdata.h @@ -87,7 +87,6 @@ typedef enum mjtTimer_ { // internal timers // breakdown of mj_collision mjTIMER_COL_BROAD, // broadphase - mjTIMER_COL_MID, // midphase mjTIMER_COL_NARROW, // narrowphase mjNTIMER // number of timers diff --git a/introspect/enums.py b/introspect/enums.py index 8502dbdb..180c157b 100644 --- a/introspect/enums.py +++ b/introspect/enums.py @@ -458,9 +458,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([ ('mjTIMER_POS_MAKE', 11), ('mjTIMER_POS_PROJECT', 12), ('mjTIMER_COL_BROAD', 13), - ('mjTIMER_COL_MID', 14), - ('mjTIMER_COL_NARROW', 15), - ('mjNTIMER', 16), + ('mjTIMER_COL_NARROW', 14), + ('mjNTIMER', 15), ]), )), ('mjtCatBit', diff --git a/introspect/structs.py b/introspect/structs.py index 43e7cdc9..02e92c7f 100644 --- a/introspect/structs.py +++ b/introspect/structs.py @@ -4154,7 +4154,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([ name='timer', type=ArrayType( inner_type=ValueType(name='mjTimerStat'), - extents=(16,), + extents=(15,), ), doc='timer statistics', ), diff --git a/sample/testspeed.cc b/sample/testspeed.cc index 03d67d15..66dabf3a 100644 --- a/sample/testspeed.cc +++ b/sample/testspeed.cc @@ -278,7 +278,7 @@ int main(int argc, char** argv) { // components of mjTIMER_POS_COLLISION if (i == mjTIMER_POS_COLLISION) { - for (int j : {mjTIMER_COL_BROAD, mjTIMER_COL_MID, mjTIMER_COL_NARROW}) { + for (int j : {mjTIMER_COL_BROAD, mjTIMER_COL_NARROW}) { int number = d[0]->timer[j].number; mjtNum jstep = number ? d[0]->timer[j].duration/number : 0.0; mjtNum percent = number ? 100*jstep/tstep : 0.0; diff --git a/src/engine/engine_collision_driver.c b/src/engine/engine_collision_driver.c index f6132b74..b8a8a7d0 100644 --- a/src/engine/engine_collision_driver.c +++ b/src/engine/engine_collision_driver.c @@ -291,12 +291,9 @@ void mj_collision(const mjModel* m, mjData* d) { unsigned int last_signature = -1; TM_END(mjTIMER_COL_BROAD); - // midphase collision detector + // narrowphase and midphase collision detector TM_RESTART; - // save current narrowphase duration - mjtNum tmNarrow = d->timer[mjTIMER_COL_NARROW].duration; - // process bodyflex pairs returned by broadphase, merge with predefined geom pairs int pairadr = 0; for (int i=0; i < nbfpair; i++) { @@ -471,14 +468,8 @@ void mj_collision(const mjModel* m, mjData* d) { } } - // end midphase timer - TM_END(mjTIMER_COL_MID); - - // subtract nested narrowphase timing from midphase timer - d->timer[mjTIMER_COL_MID].duration -= (d->timer[mjTIMER_COL_NARROW].duration - tmNarrow); - - // increment narrowphase counter - d->timer[mjTIMER_COL_NARROW].number++; + // end narrowphase and midphase timer + TM_END(mjTIMER_COL_NARROW); mj_freeStack(d); TM_END1(mjTIMER_POS_COLLISION); @@ -1444,8 +1435,6 @@ static void mj_makeCapsule(const mjModel* m, mjData* d, int f, const int vid[2], // test two geoms for collision, apply filters, add to contact list void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) { - TM_START; - int num, type1, type2, condim; mjtNum margin, gap, friction[5], solref[mjNREF], solimp[mjNIMP]; mjtNum solreffriction[mjNREF] = {0}; @@ -1635,9 +1624,6 @@ void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) { // move arena pointer back to the end of the contact array resetArena(d); - - // add duration without incrementing counter - TM_ADD(mjTIMER_COL_NARROW); } @@ -1850,8 +1836,6 @@ void mj_collideFlexSAP(const mjModel* m, mjData* d, int f) { // test a geom and an elem for collision, add to contact list void mj_collideGeomElem(const mjModel* m, mjData* d, int g, int f, int e) { - TM_START; - mjtNum margin = mj_assignMargin(m, mju_max(m->geom_margin[g], m->flex_margin[f])); int dim = m->flex_dim[f], type = m->geom_type[g]; int num; @@ -1965,17 +1949,12 @@ void mj_collideGeomElem(const mjModel* m, mjData* d, int g, int f, int e) { // move arena pointer back to the end of the contact array resetArena(d); - - // add duration without incrementing counter - TM_ADD(mjTIMER_COL_NARROW); } // test two elems for collision, add to contact list void mj_collideElems(const mjModel* m, mjData* d, int f1, int e1, int f2, int e2) { - TM_START; - mjtNum margin = mj_assignMargin(m, mju_max(m->flex_margin[f1], m->flex_margin[f2])); int dim1 = m->flex_dim[f1], dim2 = m->flex_dim[f2]; int num; @@ -2070,9 +2049,6 @@ void mj_collideElems(const mjModel* m, mjData* d, int f1, int e1, int f2, int e2 // move arena pointer back to the end of the contact array resetArena(d); - - // add duration without incrementing counter - TM_ADD(mjTIMER_COL_NARROW); } diff --git a/src/engine/engine_support.c b/src/engine/engine_support.c index dfa91d0a..f44baaf7 100644 --- a/src/engine/engine_support.c +++ b/src/engine/engine_support.c @@ -89,7 +89,6 @@ const char* mjTIMERSTRING[mjNTIMER]= { "pos_make", "pos_project", "col_broadphase", - "col_midphase", "col_narrowphase" }; diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index 1aeb7a12..ad6bc8b9 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -138,9 +138,8 @@ public enum mjtTimer : int{ mjTIMER_POS_MAKE = 11, mjTIMER_POS_PROJECT = 12, mjTIMER_COL_BROAD = 13, - mjTIMER_COL_MID = 14, - mjTIMER_COL_NARROW = 15, - mjNTIMER = 16, + mjTIMER_COL_NARROW = 14, + mjNTIMER = 15, } public enum mjtDisableBit : int{ mjDSBL_CONSTRAINT = 1, @@ -769,7 +768,6 @@ public unsafe struct mjData_ { public mjTimerStat_ timer12; public mjTimerStat_ timer13; public mjTimerStat_ timer14; - public mjTimerStat_ timer15; public mjSolverStat_ solver0; public mjSolverStat_ solver1; public mjSolverStat_ solver2;