Remove fine-grained timing from narrow-phase collision functions, delete mjTIMER_COL_MID.
PiperOrigin-RevId: 599225419 Change-Id: Ieca166753c20a0abf660e2821b2844dda8758951
This commit is contained in:
committed by
Copybara-Service
parent
edc254b213
commit
2feefbc5d2
+8
-5
@@ -9,17 +9,20 @@ General
|
|||||||
^^^^^^^
|
^^^^^^^
|
||||||
1. Improved the :ref:discardvisual<compiler-discardvisual> compiler flag, which now discards all visual-only assets. See
|
1. Improved the :ref:discardvisual<compiler-discardvisual> compiler flag, which now discards all visual-only assets. See
|
||||||
:ref:discardvisual<compiler-discardvisual> for details.
|
:ref:discardvisual<compiler-discardvisual> for details.
|
||||||
|
2. Removed the :ref:`timer<mjtTimer>` 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
|
MJX
|
||||||
^^^
|
^^^
|
||||||
2. Added :ref:`dyntype<actuator-general-dyntype>` ``filterexact``.
|
3. Added :ref:`dyntype<actuator-general-dyntype>` ``filterexact``.
|
||||||
3. Added :at:`site` transmission.
|
4. Added :at:`site` transmission.
|
||||||
4. Updated MJX colab tutorial with more stable quadruped environment.
|
5. 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.
|
6. Added ``mjx.ray`` which mirrors :ref:`mj_ray` for planes, spheres, capsules, boxes, and meshes.
|
||||||
|
|
||||||
Bug fixes
|
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`.
|
:github:issue:`1270`.
|
||||||
7. Fixed a bug in the :ref:`muscle model<CMuscle>` that led to non-zero values outside the lower
|
7. Fixed a bug in the :ref:`muscle model<CMuscle>` that led to non-zero values outside the lower
|
||||||
bound of the length range. Fixes :github:issue:`1342`.
|
bound of the length range. Fixes :github:issue:`1342`.
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ typedef enum mjtTimer_ { // internal timers
|
|||||||
|
|
||||||
// breakdown of mj_collision
|
// breakdown of mj_collision
|
||||||
mjTIMER_COL_BROAD, // broadphase
|
mjTIMER_COL_BROAD, // broadphase
|
||||||
mjTIMER_COL_MID, // midphase
|
|
||||||
mjTIMER_COL_NARROW, // narrowphase
|
mjTIMER_COL_NARROW, // narrowphase
|
||||||
|
|
||||||
mjNTIMER // number of timers
|
mjNTIMER // number of timers
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ typedef enum mjtTimer_ { // internal timers
|
|||||||
|
|
||||||
// breakdown of mj_collision
|
// breakdown of mj_collision
|
||||||
mjTIMER_COL_BROAD, // broadphase
|
mjTIMER_COL_BROAD, // broadphase
|
||||||
mjTIMER_COL_MID, // midphase
|
|
||||||
mjTIMER_COL_NARROW, // narrowphase
|
mjTIMER_COL_NARROW, // narrowphase
|
||||||
|
|
||||||
mjNTIMER // number of timers
|
mjNTIMER // number of timers
|
||||||
|
|||||||
+2
-3
@@ -458,9 +458,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
|||||||
('mjTIMER_POS_MAKE', 11),
|
('mjTIMER_POS_MAKE', 11),
|
||||||
('mjTIMER_POS_PROJECT', 12),
|
('mjTIMER_POS_PROJECT', 12),
|
||||||
('mjTIMER_COL_BROAD', 13),
|
('mjTIMER_COL_BROAD', 13),
|
||||||
('mjTIMER_COL_MID', 14),
|
('mjTIMER_COL_NARROW', 14),
|
||||||
('mjTIMER_COL_NARROW', 15),
|
('mjNTIMER', 15),
|
||||||
('mjNTIMER', 16),
|
|
||||||
]),
|
]),
|
||||||
)),
|
)),
|
||||||
('mjtCatBit',
|
('mjtCatBit',
|
||||||
|
|||||||
@@ -4154,7 +4154,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
name='timer',
|
name='timer',
|
||||||
type=ArrayType(
|
type=ArrayType(
|
||||||
inner_type=ValueType(name='mjTimerStat'),
|
inner_type=ValueType(name='mjTimerStat'),
|
||||||
extents=(16,),
|
extents=(15,),
|
||||||
),
|
),
|
||||||
doc='timer statistics',
|
doc='timer statistics',
|
||||||
),
|
),
|
||||||
|
|||||||
+1
-1
@@ -278,7 +278,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// components of mjTIMER_POS_COLLISION
|
// components of mjTIMER_POS_COLLISION
|
||||||
if (i == 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;
|
int number = d[0]->timer[j].number;
|
||||||
mjtNum jstep = number ? d[0]->timer[j].duration/number : 0.0;
|
mjtNum jstep = number ? d[0]->timer[j].duration/number : 0.0;
|
||||||
mjtNum percent = number ? 100*jstep/tstep : 0.0;
|
mjtNum percent = number ? 100*jstep/tstep : 0.0;
|
||||||
|
|||||||
@@ -291,12 +291,9 @@ void mj_collision(const mjModel* m, mjData* d) {
|
|||||||
unsigned int last_signature = -1;
|
unsigned int last_signature = -1;
|
||||||
TM_END(mjTIMER_COL_BROAD);
|
TM_END(mjTIMER_COL_BROAD);
|
||||||
|
|
||||||
// midphase collision detector
|
// narrowphase and midphase collision detector
|
||||||
TM_RESTART;
|
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
|
// process bodyflex pairs returned by broadphase, merge with predefined geom pairs
|
||||||
int pairadr = 0;
|
int pairadr = 0;
|
||||||
for (int i=0; i < nbfpair; i++) {
|
for (int i=0; i < nbfpair; i++) {
|
||||||
@@ -471,14 +468,8 @@ void mj_collision(const mjModel* m, mjData* d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end midphase timer
|
// end narrowphase and midphase timer
|
||||||
TM_END(mjTIMER_COL_MID);
|
TM_END(mjTIMER_COL_NARROW);
|
||||||
|
|
||||||
// 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++;
|
|
||||||
|
|
||||||
mj_freeStack(d);
|
mj_freeStack(d);
|
||||||
TM_END1(mjTIMER_POS_COLLISION);
|
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
|
// test two geoms for collision, apply filters, add to contact list
|
||||||
void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) {
|
void mj_collideGeoms(const mjModel* m, mjData* d, int g1, int g2) {
|
||||||
TM_START;
|
|
||||||
|
|
||||||
int num, type1, type2, condim;
|
int num, type1, type2, condim;
|
||||||
mjtNum margin, gap, friction[5], solref[mjNREF], solimp[mjNIMP];
|
mjtNum margin, gap, friction[5], solref[mjNREF], solimp[mjNIMP];
|
||||||
mjtNum solreffriction[mjNREF] = {0};
|
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
|
// move arena pointer back to the end of the contact array
|
||||||
resetArena(d);
|
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
|
// 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) {
|
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]));
|
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 dim = m->flex_dim[f], type = m->geom_type[g];
|
||||||
int num;
|
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
|
// move arena pointer back to the end of the contact array
|
||||||
resetArena(d);
|
resetArena(d);
|
||||||
|
|
||||||
// add duration without incrementing counter
|
|
||||||
TM_ADD(mjTIMER_COL_NARROW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// test two elems for collision, add to contact list
|
// 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) {
|
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]));
|
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 dim1 = m->flex_dim[f1], dim2 = m->flex_dim[f2];
|
||||||
int num;
|
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
|
// move arena pointer back to the end of the contact array
|
||||||
resetArena(d);
|
resetArena(d);
|
||||||
|
|
||||||
// add duration without incrementing counter
|
|
||||||
TM_ADD(mjTIMER_COL_NARROW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ const char* mjTIMERSTRING[mjNTIMER]= {
|
|||||||
"pos_make",
|
"pos_make",
|
||||||
"pos_project",
|
"pos_project",
|
||||||
"col_broadphase",
|
"col_broadphase",
|
||||||
"col_midphase",
|
|
||||||
"col_narrowphase"
|
"col_narrowphase"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -138,9 +138,8 @@ public enum mjtTimer : int{
|
|||||||
mjTIMER_POS_MAKE = 11,
|
mjTIMER_POS_MAKE = 11,
|
||||||
mjTIMER_POS_PROJECT = 12,
|
mjTIMER_POS_PROJECT = 12,
|
||||||
mjTIMER_COL_BROAD = 13,
|
mjTIMER_COL_BROAD = 13,
|
||||||
mjTIMER_COL_MID = 14,
|
mjTIMER_COL_NARROW = 14,
|
||||||
mjTIMER_COL_NARROW = 15,
|
mjNTIMER = 15,
|
||||||
mjNTIMER = 16,
|
|
||||||
}
|
}
|
||||||
public enum mjtDisableBit : int{
|
public enum mjtDisableBit : int{
|
||||||
mjDSBL_CONSTRAINT = 1,
|
mjDSBL_CONSTRAINT = 1,
|
||||||
@@ -769,7 +768,6 @@ public unsafe struct mjData_ {
|
|||||||
public mjTimerStat_ timer12;
|
public mjTimerStat_ timer12;
|
||||||
public mjTimerStat_ timer13;
|
public mjTimerStat_ timer13;
|
||||||
public mjTimerStat_ timer14;
|
public mjTimerStat_ timer14;
|
||||||
public mjTimerStat_ timer15;
|
|
||||||
public mjSolverStat_ solver0;
|
public mjSolverStat_ solver0;
|
||||||
public mjSolverStat_ solver1;
|
public mjSolverStat_ solver1;
|
||||||
public mjSolverStat_ solver2;
|
public mjSolverStat_ solver2;
|
||||||
|
|||||||
Reference in New Issue
Block a user