Improve warmstarting if island structure exists.

PiperOrigin-RevId: 752901506
Change-Id: I062d14df7da7d9dc1a2c1c30a16d0db7215af336
This commit is contained in:
Yuval Tassa
2025-04-29 15:17:13 -07:00
committed by Copybara-Service
parent 4c92c60988
commit 1766a388cc
3 changed files with 127 additions and 46 deletions
+18 -7
View File
@@ -45,24 +45,35 @@ TEST_F(PipelineTest, SparseDenseEquivalent) {
mjtNum tol = 1e-11;
for (mjtSolver solver : {mjSOL_NEWTON, mjSOL_PGS, mjSOL_CG}) {
model->opt.solver = solver;
const char* sname[4] = {"NEWTON", "PGS", "CG", "NOSLIP"};
mjtSolver solver[4] = {mjSOL_NEWTON, mjSOL_PGS, mjSOL_CG, mjSOL_NEWTON};
// set dense jacobian, call mj_forward, save accelerations
for (int i : {0, 1, 2, 3}) {
model->opt.solver = solver[i];
if (i == 3) {
model->opt.noslip_iterations = 2;
}
// set dense jacobian, call mj_step, save qacc and new qpos
model->opt.jacobian = mjJAC_DENSE;
mj_resetDataKeyframe(model, data, 0);
mj_forward(model, data);
mj_step(model, data);
std::vector<mjtNum> qacc_dense = AsVector(data->qacc, model->nv);
std::vector<mjtNum> qpos_dense = AsVector(data->qpos, model->nq);
// set sparse jacobian, call mj_forward, save accelerations
// set sparse jacobian, call mj_step, save qacc and new qpos
model->opt.jacobian = mjJAC_SPARSE;
mj_resetDataKeyframe(model, data, 0);
mj_forward(model, data);
mj_step(model, data);
std::vector<mjtNum> qacc_sparse = AsVector(data->qacc, model->nv);
std::vector<mjtNum> qpos_sparse = AsVector(data->qpos, model->nq);
// expect accelerations to be insignificantly different
EXPECT_THAT(qacc_dense, Pointwise(DoubleNear(tol), qacc_sparse))
<< "failed equivalence for solver=" << solver;
<< "failed qacc equivalence for solver=" << sname[i];
// expect positions to be insignificantly different
EXPECT_THAT(qpos_dense, Pointwise(DoubleNear(tol), qpos_sparse))
<< "failed qpos equivalence for solver=" << sname[i];
}
mj_deleteData(data);