Define mj_multiRay bindings explicitly.
Fixes #1184. PiperOrigin-RevId: 581956413 Change-Id: I6c611ac7537442a65e6961430ec724326ee6095a
This commit is contained in:
committed by
Copybara-Service
parent
d0cabcf7db
commit
9ae40e718e
@@ -24,6 +24,7 @@
|
||||
#include <Eigen/Core>
|
||||
#include <mujoco/mjxmacro.h>
|
||||
#include <mujoco/mujoco.h>
|
||||
#include "errors.h"
|
||||
#include "function_traits.h"
|
||||
#include "functions.h"
|
||||
#include "private.h"
|
||||
@@ -38,6 +39,7 @@ PYBIND11_MODULE(_functions, pymodule) {
|
||||
namespace py = ::pybind11;
|
||||
namespace traits = python_traits;
|
||||
|
||||
using EigenVectorI = Eigen::Vector<int, Eigen::Dynamic>;
|
||||
using EigenVectorX = Eigen::Vector<mjtNum, Eigen::Dynamic>;
|
||||
using EigenArrayXX = Eigen::Array<
|
||||
mjtNum, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
@@ -568,7 +570,25 @@ PYBIND11_MODULE(_functions, pymodule) {
|
||||
Def<traits::mj_versionString>(pymodule);
|
||||
|
||||
// Ray collision
|
||||
Def<traits::mj_multiRay>(pymodule);
|
||||
Def<traits::mj_multiRay>(
|
||||
pymodule,
|
||||
[](const raw::MjModel* m, raw::MjData* d, const mjtNum(*pnt)[3],
|
||||
Eigen::Ref<const EigenVectorX> vec,
|
||||
std::optional<Eigen::Ref<const Eigen::Vector<mjtByte, mjNGROUP>>>
|
||||
geomgroup,
|
||||
mjtByte flg_static, int bodyexclude, Eigen::Ref<EigenVectorI> geomid,
|
||||
Eigen::Ref<EigenVectorX> dist, int nray, mjtNum cutoff) {
|
||||
if (dist.size() != nray || geomid.size() != nray) {
|
||||
throw py::type_error("dist and geomid should be of size nray");
|
||||
}
|
||||
if (vec.size() != 3 * nray) {
|
||||
throw py::type_error("vec should be of size 3*nray");
|
||||
}
|
||||
InterceptMjErrors(::mj_multiRay)(
|
||||
m, d, &(*pnt)[0], vec.data(),
|
||||
geomgroup.has_value() ? geomgroup->data() : nullptr, flg_static,
|
||||
bodyexclude, geomid.data(), dist.data(), nray, cutoff);
|
||||
});
|
||||
Def<traits::mj_ray>(
|
||||
pymodule,
|
||||
[](const raw::MjModel* m, const raw::MjData* d, const mjtNum(*pnt)[3],
|
||||
|
||||
Reference in New Issue
Block a user