Skip to content

Commit

Permalink
Remove MjLib in favor of using the MuJoCo cpp library directly.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 677840274
Change-Id: I67d8d21a8cac041e4ad79aa9009beb74795f7c68
  • Loading branch information
rachelsterneck authored and copybara-github committed Sep 23, 2024
1 parent f9b0652 commit ac79c52
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 949 deletions.
6 changes: 2 additions & 4 deletions cpp/controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ information.
#include "absl/container/btree_set.h"
#include "absl/types/span.h"
#include "dm_robotics/controllers/lsqp/cartesian_6d_to_joint_velocity_mapper.h"
#include "dm_robotics/mujoco/mjlib.h"
#include "third_party/mujoco/include/mujoco.h"
#include "dm_robotics/mujoco/types.h"

namespace dmr = ::dm_robotics;
Expand All @@ -41,15 +41,13 @@ int main(int argc, char** argv) {
// Initialize MuJoCo simulation. Assumes velocity controlled robot.
// data->ctrl is an array of size 7 that corresponds to the commanded
// velocities of the joints with IDs 7, 8, 9, 10, 12, 13, 14.
dmr::MjLib mjlib = GetMujocoLib();
std::unique_ptr<mjModel, void (*)(mjModel*)> model = GetModel();
std::unique_ptr<mjData, void (*)(mjData*)> data = GetData();

// Create parameters.
dmr::Cartesian6dToJointVelocityMapper::Parameters params;
//
// Set model parameters.
params.lib = mjlib;
params.model = model.get();
params.joint_ids = absl::btree_set<int>{7, 8, 9, 10, 12, 13, 14};
params.object_type = mjtObj::mjOBJ_SITE;
Expand Down Expand Up @@ -117,7 +115,7 @@ int main(int argc, char** argv) {
absl::Span<const double> solution,
mapper.ComputeJointVelocities(*data, target_velocity, nullspace_bias).value();
std::copy(solution.begin(), solution.end(), data->ctrl);
mjlib.mj_step(model.get(), data.get());
mj_step(model.get(), data.get());
}
}
```
2 changes: 1 addition & 1 deletion cpp/controllers_py/pybind_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "dm_robotics/support/logging.h"
#include "absl/strings/substitute.h"
#include "dm_robotics/mujoco/mjlib.h"
#include "mujoco/mujoco.h"
#include "pybind11/pybind11.h" // pybind

namespace dm_robotics::internal {
Expand Down
2 changes: 1 addition & 1 deletion cpp/controllers_py/pybind_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define DM_ROBOTICS_PY_CONTROLLERS_PYBIND_UTILS_H_

#include "absl/strings/string_view.h"
#include "dm_robotics/mujoco/mjlib.h"
#include "mujoco/mujoco.h"
#include "pybind11/pytypes.h" // pybind

namespace dm_robotics::internal {
Expand Down
16 changes: 0 additions & 16 deletions cpp/mujoco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/defs.h.in

# Library
set(SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/mjlib.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cc
)
set(HDRS
${CMAKE_CURRENT_SOURCE_DIR}/include/dm_robotics/mujoco/mjlib.h
${CMAKE_CURRENT_SOURCE_DIR}/include/dm_robotics/mujoco/types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/dm_robotics/mujoco/utils.h
${CMAKE_CURRENT_BINARY_DIR}/include/dm_robotics/mujoco/defs.h
Expand Down Expand Up @@ -90,20 +88,6 @@ if(DM_ROBOTICS_BUILD_TESTS)
dmr_mujoco
)

# mjlib_test
add_executable(dmr_mujoco_mjlib_test
${CMAKE_CURRENT_SOURCE_DIR}/tests/mjlib_test.cc
)
target_link_libraries(dmr_mujoco_mjlib_test
gtest
gmock
gtest_main
dmr_support
dmr_mujoco
dmr_mujoco_testing
)
gtest_discover_tests(dmr_mujoco_mjlib_test)

# test_with_mujoco_model_test
add_executable(dmr_mujoco_test_with_mujoco_model_test
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_with_mujoco_model_test.cc
Expand Down
Loading

0 comments on commit ac79c52

Please sign in to comment.