From dc8e4382b83a073c0c3da56e657c35e175fdd9d0 Mon Sep 17 00:00:00 2001 From: Jose Enrique Chen Date: Tue, 24 Oct 2023 04:58:48 -0700 Subject: [PATCH] Internal change. PiperOrigin-RevId: 576102148 Change-Id: I75fadec5f4323682c599a8582be5ecfc7ea5ad84 --- cpp/controllers_py/pybind_utils.cc | 2 +- cpp/mujoco/include/dm_robotics/mujoco/mjlib.h | 10 +++++----- cpp/mujoco/src/mjlib.cc | 8 ++++---- cpp/mujoco/src/test_with_mjlib.cc | 4 +++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cpp/controllers_py/pybind_utils.cc b/cpp/controllers_py/pybind_utils.cc index 5be767f..ae21f2a 100644 --- a/cpp/controllers_py/pybind_utils.cc +++ b/cpp/controllers_py/pybind_utils.cc @@ -112,7 +112,7 @@ const MjLib* LoadMjLibFromDmControlDynamically() { const MjLib* LoadMjLibFromDmControl() { py::gil_scoped_acquire gil; - return LoadMjLibFromDmControlDynamically(); + return LoadMjLibFromDmControlStatically(); // Copybara changes to dynamic. } // Helper function for getting an mjModel object from a py::handle. diff --git a/cpp/mujoco/include/dm_robotics/mujoco/mjlib.h b/cpp/mujoco/include/dm_robotics/mujoco/mjlib.h index 70e8045..e0e49cd 100644 --- a/cpp/mujoco/include/dm_robotics/mujoco/mjlib.h +++ b/cpp/mujoco/include/dm_robotics/mujoco/mjlib.h @@ -19,11 +19,11 @@ #include // MuJoCo headers must be included in the same order as "mujoco.h". -#include "mujoco/mjdata.h" //NOLINT -#include "mujoco/mjmodel.h" //NOLINT -#include "mujoco/mjrender.h" //NOLINT -#include "mujoco/mjui.h" //NOLINT -#include "mujoco/mjvisualize.h" //NOLINT +#include //NOLINT +#include //NOLINT +#include //NOLINT +#include //NOLINT +#include //NOLINT namespace dm_robotics { diff --git a/cpp/mujoco/src/mjlib.cc b/cpp/mujoco/src/mjlib.cc index a627762..8677483 100644 --- a/cpp/mujoco/src/mjlib.cc +++ b/cpp/mujoco/src/mjlib.cc @@ -34,7 +34,7 @@ using LibMujocoHandle = std::unique_ptr; LibMujocoHandle OpenImpl(const char *path, int dlopen_flags) { dlerror(); // Clear error state before calling dlopen. void* handle = dlopen(path, dlopen_flags); - CHECK(handle != nullptr) << "dlopen '" << path << "' failed: " << dlerror(); + CHECK_NE(handle, nullptr) << "dlopen '" << path << "' failed: " << dlerror(); // Ensure we close the library with dlclose: LibMujocoHandle handle_with_close(handle); @@ -49,7 +49,7 @@ LibMujocoHandle OpenImpl(const char *path, int dlopen_flags) { } LibMujocoHandle DlOpen(const std::string& path, int dlopen_flags) { - return OpenImpl(path.c_str(), dlopen_flags); + return OpenImpl(nullptr, RTLD_NOW); // Changed by Copybara. } } // namespace @@ -63,14 +63,14 @@ struct MjLib::Impl { // We terminate the program if any of the symbol handles are null. #define INIT_WITH_DLSYM(name) \ name(decltype(name)( \ - DieIfNull(dlsym(pimpl_->libmujoco_handle.get(), #name)))) + ABSL_DIE_IF_NULL(dlsym(pimpl_->libmujoco_handle.get(), #name)))) #define INIT_WITH_DLSYM_NULLABLE(name) \ name(decltype(name)(dlsym(pimpl_->libmujoco_handle.get(), #name))) #define INIT_CALLBACK_WITH_DLSYM(name) \ name(*(decltype(&name))( \ - DieIfNull(dlsym(pimpl_->libmujoco_handle.get(), #name)))) + ABSL_DIE_IF_NULL(dlsym(pimpl_->libmujoco_handle.get(), #name)))) MjLib::MjLib(const std::string& libmujoco_path, int dlopen_flags) : pimpl_(absl::make_unique(libmujoco_path, dlopen_flags)), diff --git a/cpp/mujoco/src/test_with_mjlib.cc b/cpp/mujoco/src/test_with_mjlib.cc index ca1a99c..e843c89 100644 --- a/cpp/mujoco/src/test_with_mjlib.cc +++ b/cpp/mujoco/src/test_with_mjlib.cc @@ -32,7 +32,9 @@ namespace dm_robotics::testing { MjLib* TestWithMjLib::mjlib_ = nullptr; void TestWithMjLib::SetUpTestSuite() { - mjlib_ = new MjLib(kMujocoLibNoGlPath, RTLD_NOW); // Load MuJoCo. + mjlib_ = new MjLib( + file::JoinPath(absl::GetFlag(FLAGS_test_srcdir), kMujocoLibNoGlPath), + RTLD_NOW); } void TestWithMjLib::TearDownTestSuite() {