Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(Threads REQUIRED)

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Attempt to find an install of mujoco, either the library itself, from the environment, or
# as a last resort download the required tar file manually and unzip it into the workspace.
find_package(mujoco QUIET)
if(mujoco_FOUND)
message(STATUS "Mujoco build from source has been found")
# Attempt to link MuJoCo via the vendor package, if available
find_package(mujoco_vendor QUIET)
if(mujoco_vendor_FOUND)
set(MUJOCO_LIB mujoco::mujoco)
set(MUJOCO_INCLUDE_DIR ${MUJOCO_INCLUDE_DIR})
set(MUJOCO_INCLUDE_DIR ${mujoco_vendor_INCLUDE_DIRS})
set(MUJOCO_SIMULATE_DIR ${MUJOCO_INCLUDE_DIR}/../simulate)
# If the user has specified a MuJoCo install location use it
elseif(DEFINED ENV{MUJOCO_INSTALL_DIR})
message(STATUS "Mujoco build from source has not been found. Attempting to find the binary in $ENV{MUJOCO_INSTALL_DIR} instead.")
set(MUJOCO_DIR $ENV{MUJOCO_INSTALL_DIR})
Expand All @@ -36,9 +33,9 @@ elseif(DEFINED ENV{MUJOCO_INSTALL_DIR})
endif()
set(MUJOCO_INCLUDE_DIR $ENV{MUJOCO_DIR}/include)
set(MUJOCO_SIMULATE_DIR $ENV{MUJOCO_DIR}/simulate)
# Otherwise we fallback and download the required tarfile and install it manually
else()
include(FetchContent)

# Detect architecture
set(MUJOCO_VERSION "3.3.4")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
Expand Down Expand Up @@ -77,6 +74,9 @@ else()
message(STATUS "MuJoCo library found: ${MUJOCO_LIB}")
endif()


set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Fetch lodepng dependency.
if(NOT TARGET lodepng)
include(FetchContent)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ This interface has only been tested against ROS 2 jazzy and MuJoCo `3.3.4`.
It should also be compatible with kilted and rolling, but we do not actively maintain those.
We assume all required ROS dependencies have been installed either manually or with `rosdep`.

For configuring MuJoCo, the included [CMakeLists.txt](./CMakeLists.txt) will download and install the tarfile automatically.
As long as users have a good network connection there should not be an issue.

However, a local install of MuJoCo can be used to build the application by setting the following environment variables,
For configuring MuJoCo, the included [CMakeLists.txt](./CMakeLists.txt) will first attempt to use the [mujoco_vendor](https://github.com/pal-robotics/mujoco_vendor) package if it is installed in your workspace.
If it is not found, a local install of MuJoCo can be used to build the application by setting the following environment variables,

```bash
# The tested version
Expand All @@ -26,6 +24,8 @@ MUJOCO_VERSION=3.3.4
# Wherever it was installed and extracted on your machine
MUJOCO_INSTALL_DIR=/opt/mujoco/mujoco-3.3.4
```
If neither is available, the script will automatically download and install the MuJoCo tarfile.
As long as users have a stable network connection, this process should complete without issues.

From there the library can be compiled with `colcon build ...`, as normal.

Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>sensor_msgs</depend>
<depend>mujoco_vendor</depend>

<test_depend>joint_state_broadcaster</test_depend>
<test_depend>position_controllers</test_depend>
Expand Down
Loading