Add mjv_camera2GLCamera to mujoco.h.

PiperOrigin-RevId: 956698065
Change-Id: I36856d7142bb5e798c5a90c19609288ddd7c4aac
This commit is contained in:
Haroon Qureshi
2026-07-30 13:15:50 -07:00
committed by Copybara-Service
parent a3425c72a7
commit 8b78378868
8 changed files with 69 additions and 3 deletions
+1
View File
@@ -854,6 +854,7 @@ PYBIND11_MODULE(_functions, pymodule, pybind11::mod_gil_not_used()) {
Def<traits::mjv_applyPerturbPose>(pymodule);
Def<traits::mjv_applyPerturbForce>(pymodule);
// Skipped: mjv_averageCamera (defined in structs.cc due to the return type)
// Skipped: mjv_camera2GLCamera (defined in structs.cc due to the return type)
Def<traits::mjv_select>(pymodule);
// Visualization
+26
View File
@@ -4972,6 +4972,32 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
),
doc='Return the average of two OpenGL cameras.',
)),
('mjv_camera2GLCamera',
FunctionDecl(
name='mjv_camera2GLCamera',
return_type=ValueType(name='mjvGLCamera'),
parameters=(
FunctionParameterDecl(
name='model',
type=PointerType(
inner_type=ValueType(name='mjModel', is_const=True),
),
),
FunctionParameterDecl(
name='data',
type=PointerType(
inner_type=ValueType(name='mjData', is_const=True),
),
),
FunctionParameterDecl(
name='mjv_camera',
type=PointerType(
inner_type=ValueType(name='mjvCamera', is_const=True),
),
),
),
doc='Converts a mjvCamera to a mjvGLCamera.',
)),
('mjv_select',
FunctionDecl(
name='mjv_select',
+17 -3
View File
@@ -1421,9 +1421,10 @@ This is useful for example when the MJB is not available as a file on disk.)"));
mjvFigure.def_readonly("linename", &MjvFigureWrapper::linename);
// mjv_averageCamera returns an mjvGLCamera and we need to call the wrapper's
// constructor on the return value. Defining the binding for this function
// in this file to avoid symbol dependency across modules.
// mjv_averageCamera and mjv_camera2GLCamera both return an mjvGLCamera.
// We need to call the wrapper's constructor on the return value. Defining the
// binding for these functions in this file to avoid symbol dependency across
// modules.
m.def(
"mjv_averageCamera",
[](const MjvGLCameraWrapper& cam1, const MjvGLCameraWrapper& cam2) {
@@ -1435,6 +1436,19 @@ This is useful for example when the MJB is not available as a file on disk.)"));
py::arg("cam1"), py::arg("cam2"),
py::doc(python_traits::mjv_averageCamera::doc));
m.def(
"mjv_camera2GLCamera",
[](const MjModelWrapper& m, const MjDataWrapper& d,
const MjvCameraWrapper& cam) {
return MjvGLCameraWrapper([&m, &d, &cam]() {
py::gil_scoped_release no_gil;
return InterceptMjErrors(mjv_camera2GLCamera)(m.get(), d.get(),
cam.get());
}());
},
py::arg("m"), py::arg("d"), py::arg("cam"),
py::doc(python_traits::mjv_camera2GLCamera::doc));
m.def("_recompile_spec_addr", [](uintptr_t spec_addr, const MjModelWrapper& m,
const MjDataWrapper& d) {
return RecompileSpec(reinterpret_cast<raw::MjSpec*>(spec_addr), m, d);