Remove mjData.qLDiagSqrtInv, add corresponding argument to mj_solveM2.

- `qLDiagSqrtInv` is only required for the dual solvers. It is now computed as-needed rather than unconditionally.
- `mj_solveM2` now requires a new input array `sqrtInvD` which contains the square root of the inverse diagonal D (formerly saved in `qLDiagSqrtInv`).

PiperOrigin-RevId: 710805133
Change-Id: I0622d6a8da3882916824e9c10bad9223c122c321
This commit is contained in:
Yuval Tassa
2024-12-30 15:23:41 -08:00
committed by Copybara-Service
parent ec322641b7
commit 69c9ac074a
19 changed files with 53 additions and 44 deletions
+6 -2
View File
@@ -234,7 +234,7 @@ PYBIND11_MODULE(_functions, pymodule) {
DEF_WITH_OMITTED_PY_ARGS(traits::mj_solveM2, "n")(
pymodule,
[](const raw::MjModel* m, raw::MjData* d, Eigen::Ref<EigenArrayXX> x,
Eigen::Ref<const EigenArrayXX> y) {
Eigen::Ref<const EigenArrayXX> y, Eigen::Ref<const EigenArrayXX> sqrtInvD) {
if (x.rows() != y.rows()) {
throw py::type_error(
"the first dimension of x and y should be of the same size");
@@ -247,8 +247,12 @@ PYBIND11_MODULE(_functions, pymodule) {
throw py::type_error(
"the last dimension of y should be of size nv");
}
if (sqrtInvD.size() != m->nv) {
throw py::type_error(
"the size of sqrtInvD should be nv");
}
return InterceptMjErrors(::mj_solveM2)(
m, d, x.data(), y.data(), y.rows());
m, d, x.data(), y.data(), sqrtInvD.data(), y.rows());
});
Def<traits::mj_comVel>(pymodule);
Def<traits::mj_passive>(pymodule);
-1
View File
@@ -379,7 +379,6 @@
X( mjtNum, , xaxis, njnt, 3 ) \
X( mjtNum, , cdof, nv, 6 ) \
X( mjtNum, , qLDiagInv, nv, 1 ) \
X( mjtNum, , qLDiagSqrtInv, nv, 1 ) \
X( mjtNum, , cdof_dot, nv, 6 ) \
X( mjtNum, , qfrc_bias, nv, 1 ) \
X( mjtNum, , qfrc_passive, nv, 1 ) \