Fix bug where EPA horizon returns zero edges due to numerical inaccuracies in float32.

PiperOrigin-RevId: 717825833
Change-Id: I9fa440816765d4c3eaa0c6c26ec0bd90c774fa01
This commit is contained in:
Kyle Bayes
2025-01-21 02:50:05 -08:00
committed by Copybara-Service
parent 2624d524ba
commit bd1bbfe401
+9
View File
@@ -1347,6 +1347,15 @@ static Face* epa(mjCCDStatus* status, Polytope* pt, mjCCDObj* obj1, mjCCDObj* ob
h.w = w;
horizon(&h, face);
// unrecoverable numerical issue; at least one face was deleted so nedges is 3 or more
if (h.nedges < 3) {
mj_freeStack(d);
status->epa_iterations = k;
status->nx = 0;
status->dist = 0;
return NULL;
}
// insert w as new vertex and attach faces along the horizon
int wi = newVertex(pt, w1, w2), nfaces = pt->nfaces, nedges = h.nedges;