From 62e2842116dbdc0629dab1ca1e90014d27ef6e29 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 27 Jun 2024 05:04:57 -0700 Subject: [PATCH] Skip deprecated `mju_rotVecMat` and `mju_rotVecMatT` in Python bindings. PiperOrigin-RevId: 647275284 Change-Id: I371236182b22eb399041959901085bb82af3f670 --- doc/changelog.rst | 27 +++++++++++++++------------ python/mujoco/functions.cc | 16 ++++++++-------- src/engine/engine_collision_box.c | 12 ++++++------ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 7a4bfdd2..79d4db8d 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -12,12 +12,17 @@ General 1. Removed deprecated ``mj_makeEmptyFileVFS`` and ``mj_findFileVFS`` functions. - **Migration:** Use ``mj_addBufferVFS`` to copy a buffer into a VFS file directly. + **Migration:** Use:ref:`mj_addBufferVFS` to copy a buffer into a VFS file directly. - 2. Calls to ``mj_defaultVFS`` may allocate memory inside VFS, and the corresponding - ``mj_deleteVFS`` must be called to deallocate any internal allocated memory. + 2. Calls to:ref:`mj_defaultVFS` may allocate memory inside VFS, and the corresponding + :ref:`mj_deleteVFS` must be called to deallocate any internal allocated memory. -3. Added a new API for :doc:`procedural model manipulation`. Fixes :github:issue:`364`. + 3. Deprecated :ref:`mju_rotVecMat` and :ref:`mju_rotVecMatT` in favor of :ref:`mju_mulMatVec3` and + :ref:`mju_mulMatTVec3`. These function names and argument order are more consistent with the rest of the API. + The older functions have been removed from the Python bindings and will be removed from the C API in the next + release. + +4. Added a new API for :doc:`procedural model manipulation`. Fixes :github:issue:`364`. Still missing: - Detailed documentation. @@ -27,14 +32,12 @@ General :align: right :width: 240px -4. Added support for orthographic cameras. This is available for both fixed cameras and the free camera, using the +5. Added support for orthographic cameras. This is available for both fixed cameras and the free camera, using the :ref:`camera/orthographic` and :ref:`global/orthographic` attributes, respectively. -5. Added :ref:`maxhullvert`, the maximum number of vertices in a mesh's convex hull. -6. Added :ref:`mj_setKeyframe` for saving the current state into a model keyframe. -7. Added support for ``ball`` joints in the URDF parser ("spherical" in URDF). -8. Deprecated :ref:`mju_rotVecMat` and :ref:`mju_rotVecMatT` in favor of :ref:`mju_mulMatVec3` and - :ref:`mju_mulMatTVec3`. These functions names and argument ordering are more consistent with the rest of the API. +6. Added :ref:`maxhullvert`, the maximum number of vertices in a mesh's convex hull. +7. Added :ref:`mj_setKeyframe` for saving the current state into a model keyframe. +8. Added support for ``ball`` joints in the URDF parser ("spherical" in URDF). 9. Replaced ``mjUSEDOUBLE`` which was previously hard-coded in `mjtnum.h `__ with the build-time flag ``mjUSESINGLE``. If this symbol is not defined, MuJoCo will use double-precision floating @@ -231,10 +234,10 @@ General :at:`ctrlrange` or :at:`actrange` (respectively), according to the range of the transmission target (joint or tendon). See :ref:`position/inheritrange` for details. -2. Deprecated :ref:`mj_makeEmptyFileVFS` in favor of :ref:`mj_addBufferVFS`. :ref:`mjVFS` now computes checksums of +2. Deprecated ``mj_makeEmptyFileVFS`` in favor of :ref:`mj_addBufferVFS`. :ref:`mjVFS` now computes checksums of its internal file buffers. :ref:`mj_addBufferVFS` allocates an empty buffer with a given name in an mjVFS and copies the data buffer into it, combining and replacing the deprecated two-step process of calling - :ref:`mj_makeEmptyFileVFS` followed by a direct copy into the given mjVFS internal file buffer. + ``mj_makeEmptyFileVFS`` followed by a direct copy into the given mjVFS internal file buffer. 3. Added :ref:`mj_angmomMat` which computes the ``3 x nv`` angular momentum matrix :math:`H(q)`, providing the linear mapping from generalized velocities to subtree angular momentum :math:`h = H \dot q`. Contribution by :github:user:`v-r-a`. diff --git a/python/mujoco/functions.cc b/python/mujoco/functions.cc index 7582ac70..86beb5cd 100644 --- a/python/mujoco/functions.cc +++ b/python/mujoco/functions.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -29,6 +28,7 @@ #include "functions.h" #include "private.h" #include "raw.h" +#include "structs.h" #include #include #include @@ -108,9 +108,10 @@ PYBIND11_MODULE(_functions, pymodule) { // Skipped: mj_copyModel (have MjModel.__copy__, memory managed by MjModel) pymodule.def( "mj_saveModel", - [](const MjModelWrapper& m, const std::optional& filename = std::nullopt, - std::optional< - Eigen::Ref>> buffer = std::nullopt) { + [](const MjModelWrapper& m, + const std::optional& filename = std::nullopt, + std::optional>> + buffer = std::nullopt) { void* buffer_ptr = nullptr; int buffer_sz = 0; if (buffer.has_value()) { @@ -122,8 +123,7 @@ PYBIND11_MODULE(_functions, pymodule) { buffer_ptr, buffer_sz); }, py::arg("m"), py::arg_v("filename", std::nullopt), - py::arg_v("buffer", std::nullopt), - py::doc(traits::mj_saveModel::doc), + py::arg_v("buffer", std::nullopt), py::doc(traits::mj_saveModel::doc), py::call_guard()); // Skipped: mj_loadModel (have MjModel.from_binary_path) // Skipped: mj_deleteModel (have MjModel.__del__) @@ -700,8 +700,8 @@ PYBIND11_MODULE(_functions, pymodule) { Def(pymodule); Def(pymodule); Def(pymodule); - Def(pymodule); - Def(pymodule); + // skipped: mju_rotVecMat + // skipped: mju_rotVecMatT Def(pymodule); Def(pymodule); Def(pymodule); diff --git a/src/engine/engine_collision_box.c b/src/engine/engine_collision_box.c index 51471332..17bbecbe 100644 --- a/src/engine/engine_collision_box.c +++ b/src/engine/engine_collision_box.c @@ -806,8 +806,8 @@ int mjc_BoxBox(const mjModel* M, const mjData* D, mjContact* con, int g1, int g2 if (q2) { mju_mulMatMatT3(r, rotmore, rot); - // mju_rotVecMat(p,pos12,rotmore); - // mju_rotVecMat(tmp1,size2,rotmore); + // mju_mulMatVec3(p,rotmore,pos12); + // mju_mulMatVec3(tmp1,rotmore,size2); rotaxis(p, pos12); rotaxis(tmp1, size2); @@ -818,8 +818,8 @@ int mjc_BoxBox(const mjModel* M, const mjData* D, mjContact* con, int g1, int g2 rotmatx(r, rot); - // mju_rotVecMat(p,pos21,rotmore); - // mju_rotVecMat(tmp1,size1,rotmore); + // mju_mulMatVec3(p,rotmore,pos21); + // mju_mulMatVec3(tmp1,rotmore,size1); rotaxis(p, pos21); rotaxis(tmp1, size1); @@ -1074,8 +1074,8 @@ edgeedge: f2 = -1; } - // mju_rotVecMat(p,pos21,rotmore); - // mju_rotVecMat(rnorm,clnorm,rotmore); + // mju_mulMatVec3(p,rotmore,pos21); + // mju_mulMatVec3(rnorm,rotmore,clnorm); rotaxis(p, pos21); rotaxis(rnorm, clnorm);