Fix normal only for libccd during hfield collisions.

PiperOrigin-RevId: 833933161
Change-Id: I3a4ff044276d9c7305154da09b440168f0f22305
This commit is contained in:
Yuval Tassa
2025-11-18 12:55:04 -08:00
committed by Copybara-Service
parent 7569ac960d
commit e18e35f967
2 changed files with 8 additions and 5 deletions
+5 -3
View File
@@ -1342,9 +1342,11 @@ int mjc_ConvexHField(const mjModel* m, const mjData* d,
mju_copy(mat2, savemat2, 9);
mju_copy3(pos2, savepos2);
// fix contact normals
for (int i=0; i < cnt; i++) {
mjc_fixNormal(m, d, con+i, g1, g2);
if (mjDISABLED(mjDSBL_NATIVECCD)) {
// fix contact normals
for (int i=0; i < cnt; i++) {
mjc_fixNormal(m, d, con+i, g1, g2);
}
}
return cnt;
+3 -2
View File
@@ -46,6 +46,7 @@ TEST_F(SolverTest, IslandsEquivalent) {
model->opt.jacobian = mjJAC_SPARSE; // use sparse
model->opt.tolerance = 0; // set tolerance to 0
model->opt.ls_tolerance = 0; // set ls_tolerance to 0
model->opt.ccd_tolerance = 0; // set ccd_tolerance to 0
int nv = model->nv;
@@ -56,7 +57,7 @@ TEST_F(SolverTest, IslandsEquivalent) {
mjData* data_noisland = mj_makeData(model);
// Below are 3 tolerances associated with 3 different iteration counts,
// they are only moderately tight, 2x higher than x86-64 failure on Linux,
// they are only moderately tight, 10x higher than x86-64 failure on Linux,
// i.e. in that case the test fails with rtol smaller than {5e-3, 5e-4, 5e-5}.
// The point of this test is to show that CG convergence is actually not very
// precise, simply changing whether islands are used changes the solution by
@@ -64,7 +65,7 @@ TEST_F(SolverTest, IslandsEquivalent) {
// Increasing the iteration count higher than 60 does not improve convergence.
constexpr int kNumTol = 3;
mjtNum maxiter[kNumTol] = {30, 40, 60};
mjtNum rtol[kNumTol] = {1e-2, 1e-3, 1e-4};
mjtNum rtol[kNumTol] = {5e-2, 5e-3, 5e-4};
for (int i = 0; i < kNumTol; ++i) {
model->opt.iterations = maxiter[i];