Improve bindings for mjd_subQuat.

- Accept `None` for optional arguments.
- Accept 3x3 matrices for matrix arguments.

PiperOrigin-RevId: 611000820
Change-Id: Id28cdb2ae574f372ff251f94ab4557d9d2eaa80b
This commit is contained in:
Yuval Tassa
2024-02-27 23:54:20 -08:00
committed by Copybara-Service
parent a5ea87b0e6
commit 982760a63b
2 changed files with 29 additions and 2 deletions
+22 -1
View File
@@ -1353,7 +1353,28 @@ PYBIND11_MODULE(_functions, pymodule) {
DsDa.has_value() ? DsDa->data() : nullptr,
DmDq.has_value() ? DmDq->data() : nullptr);
});
Def<traits::mjd_subQuat>(pymodule);
Def<traits::mjd_subQuat>(
pymodule,
[](Eigen::Ref<const EigenVectorX> qa, Eigen::Ref<const EigenVectorX> qb,
std::optional<Eigen::Ref<EigenArrayXX>> Da,
std::optional<Eigen::Ref<EigenArrayXX>> Db) {
if (qa.size() != 4) {
throw py::type_error("qa must have size 4");
}
if (qb.size() != 4) {
throw py::type_error("qb must have size 4");
}
if (Da.has_value() && Da->size() != 9) {
throw py::type_error("Da must have size 9");
}
if (Db.has_value() && Db->size() != 9) {
throw py::type_error("Db must have size 9");
}
return InterceptMjErrors(::mjd_subQuat)(
qa.data(), qb.data(),
Da.has_value() ? Da->data() : nullptr,
Db.has_value() ? Db->data() : nullptr);
});
Def<traits::mjd_quatIntegrate>(pymodule);
pymodule.def(