Skip to content

Commit e364e33

Browse files
committed
Improve base orientation task test in centroidalID
1 parent 489f4fb commit e364e33

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/inverse-dynamics/centroidal.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(CentroidalID_postureTask)
131131
feet_vel_vec.push_back(pinocchio::Motion::Zero());
132132
}
133133
test.solver.setTarget(
134-
Eigen::VectorXd::Zero(3), Eigen::VectorXd::Zero(3), feet_pose_vec, feet_vel_vec, {false, false, false, false}, {});
134+
Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero(), feet_pose_vec, feet_vel_vec, {false, false, false, false}, {});
135135

136136
// Change initial state
137137
test.q = solo_q_start(model_handler);
@@ -264,27 +264,30 @@ BOOST_AUTO_TEST_CASE(CentroidalID_baseTask)
264264
const RobotModelHandler & model_handler = test.model_handler;
265265
const size_t nq = model_handler.getModel().nq;
266266

267-
// No need to set target as CentroidalID sets it by default to reference state
267+
// CentroidalID sets posture task by default to reference state
268268
const Eigen::VectorXd q_target = model_handler.getReferenceState().head(nq);
269269

270270
// Change initial state
271271
test.q = solo_q_start(model_handler);
272+
test.q.segment<4>(3) << 0.0025, 0.05, 0.05, 0.998; // small orientation perturbation (~6° on pitch and yaw)
273+
test.q.segment<4>(3) /= test.q.segment<4>(3).norm();
272274

273-
const int N_STEP = 10000;
275+
const int N_STEP = 5000;
274276
for (int i = 0; i < N_STEP; i++)
275277
{
276278
// Solve
277279
test.step();
278280

279281
// Compute error
280-
const Eigen::VectorXd delta_pose = pinocchio::difference(model_handler.getModel(), test.q, q_target).head<6>();
281-
const double error = delta_pose.norm();
282+
const Eigen::VectorXd delta_orientation =
283+
pinocchio::difference(model_handler.getModel(), test.q, q_target).segment<3>(3);
284+
const double error = delta_orientation.norm();
282285

283286
// Checks
284-
if (error > 2e-2) // If haven't converged yet, should be strictly decreasing
285-
BOOST_CHECK(test.is_error_decreasing("base", error));
287+
if (error > 1e-3) // If haven't converged yet, should be strictly decreasing
288+
BOOST_CHECK(test.is_error_decreasing("base_orientation", error));
286289
if (i > 9 * N_STEP / 10) // Should have converged by now
287-
BOOST_CHECK(error < 2e-2);
290+
BOOST_CHECK(error < 1e-3);
288291
}
289292
}
290293

0 commit comments

Comments
 (0)