Skip to content

Commit

Permalink
Update MuJoCo to 3.2.2 and blender to 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
HoangGiang93 committed Aug 19, 2024
1 parent d3987c5 commit 95eab65
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 48 deletions.
93 changes: 56 additions & 37 deletions build_third_parties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ while [ -n "$1" ]; do
shift 1
if [ "$module" = "blender" ]; then
BUILD_BLENDER=OFF
elif [ "$module" = "usd" ]; then
BUILD_BLENDER=OFF
elif [ "$module" = "usd" ]; then
BUILD_USD=OFF
elif [ "$module" = "mujoco" ]; then
elif [ "$module" = "mujoco" ]; then
BUILD_MUJOCO=OFF
elif [ "$module" = "pybind11" ]; then
elif [ "$module" = "pybind11" ]; then
BUILD_PYBIND11=OFF
fi
done
Expand All @@ -62,50 +61,61 @@ done

if [ $BUILD_BLENDER = true ]; then
echo "Building Blender..."

# Build blender


FROM_SRC=false
BLENDER_BUILD_DIR=$BUILD_DIR/blender
BLENDER_EXT_DIR=$EXT_DIR/blender-git

git submodule update --init $BLENDER_EXT_DIR/blender


if [ ! -d "$BLENDER_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$BLENDER_BUILD_DIR"
echo "Folder created: $BLENDER_BUILD_DIR"
else
echo "Folder already exists: $BLENDER_BUILD_DIR"
fi

(cd $BLENDER_EXT_DIR/blender && make update && ./build_files/utils/make_update.py --use-linux-libraries)
(cd $BLENDER_BUILD_DIR && cmake -S ../../external/blender-git/blender -B . -Wno-deprecated -Wno-dev && make -j$(nproc) && make install)
(cd $BLENDER_BUILD_DIR/bin/4.1/python/bin;

if [ $FROM_SRC = true ]; then
# Build blender

BLENDER_EXT_DIR=$EXT_DIR/blender-git

git submodule update --init $BLENDER_EXT_DIR/blender

(cd $BLENDER_EXT_DIR/blender && make update && ./build_files/utils/make_update.py --use-linux-libraries)
(cd $BLENDER_BUILD_DIR && cmake -S ../../external/blender-git/blender -B . -Wno-deprecated -Wno-dev && make -j$(nproc) && make install)
else
# Download blender

BLENDER_TAR_FILE=blender-4.2.0-linux-x64.tar.xz
curl -o $EXT_DIR/$BLENDER_TAR_FILE https://download.blender.org/release/Blender4.2/$BLENDER_TAR_FILE
tar xf $EXT_DIR/$BLENDER_TAR_FILE -C $BLENDER_BUILD_DIR --strip-components=1
fi

(cd $BLENDER_BUILD_DIR/4.2/python/bin;
./python3.11 -m pip install --upgrade pip build --no-warn-script-location;
./python3.11 -m pip install bpy Pillow --no-warn-script-location) # For blender
ln -sf $BLENDER_BUILD_DIR/bin/blender $BIN_DIR
ln -sf $BLENDER_BUILD_DIR/bin/4.1/python/bin/python3.11 $BIN_DIR
./python3.11 -m pip install bpy Pillow --no-warn-script-location) # For blender
ln -sf $BLENDER_BUILD_DIR/blender $BIN_DIR
ln -sf $BLENDER_BUILD_DIR/4.2/python/bin/python3.11 $BIN_DIR
fi

if [ $BUILD_USD = true ]; then
echo "Building USD..."

# Build USD

USD_BUILD_DIR=$BUILD_DIR/USD
USD_EXT_DIR=$EXT_DIR/USD

git submodule update --init $USD_EXT_DIR

if [ ! -d "$USD_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$USD_BUILD_DIR"
echo "Folder created: $USD_BUILD_DIR"
else
echo "Folder already exists: $USD_BUILD_DIR"
fi

for virtualenvwrapper in /usr/local/bin/virtualenvwrapper.sh /home/$USER/.local/bin/virtualenvwrapper.sh; do
for virtualenvwrapper in $(which virtualenvwrapper.sh) /usr/share/virtualenvwrapper/virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh /home/$USER/.local/bin/virtualenvwrapper.sh; do
if [ -f $virtualenvwrapper ]; then
. $virtualenvwrapper
mkvirtualenv --system-site-packages multiverse
Expand All @@ -124,44 +134,53 @@ fi

if [ $BUILD_MUJOCO = true ]; then
echo "Building MuJoCo..."

# Build MuJoCo


FROM_SRC=false
MUJOCO_BUILD_DIR=$BUILD_DIR/mujoco
MUJOCO_EXT_DIR=$EXT_DIR/mujoco

git submodule update --init $MUJOCO_EXT_DIR


if [ ! -d "$MUJOCO_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$MUJOCO_BUILD_DIR"
echo "Folder created: $MUJOCO_BUILD_DIR"
else
echo "Folder already exists: $MUJOCO_BUILD_DIR"
fi

(cd $MUJOCO_BUILD_DIR && cmake $MUJOCO_EXT_DIR -DCMAKE_INSTALL_PREFIX=$MUJOCO_BUILD_DIR -Wno-deprecated -Wno-dev && cmake --build . && cmake --install .)

if [ $FROM_SRC = true ]; then
# Build MuJoCo

git submodule update --init $MUJOCO_EXT_DIR
(cd $MUJOCO_BUILD_DIR && cmake $MUJOCO_EXT_DIR -DCMAKE_INSTALL_PREFIX=$MUJOCO_BUILD_DIR -Wno-deprecated -Wno-dev && cmake --build . && cmake --install .)
else
# Download MuJoCo

MUJOCO_TAR_FILE=mujoco-3.2.2-linux-x86_64.tar.gz
curl -sL https://github.com/google-deepmind/mujoco/releases/download/3.2.2/$MUJOCO_TAR_FILE | tar zx -C $MUJOCO_BUILD_DIR --strip-components=1
fi

ln -sf $MUJOCO_BUILD_DIR/bin/simulate $BIN_DIR
fi

if [ $BUILD_PYBIND11 = true ]; then
echo "Building pybind11..."

# Build pybind11

PYBIND11_BUILD_DIR=$BUILD_DIR/pybind11
PYBIND11_EXT_DIR=$EXT_DIR/pybind11

git submodule update --init $PYBIND11_EXT_DIR

if [ ! -d "$PYBIND11_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$PYBIND11_BUILD_DIR"
echo "Folder created: $PYBIND11_BUILD_DIR"
else
echo "Folder already exists: $PYBIND11_BUILD_DIR"
fi

(cd $PYBIND11_BUILD_DIR && cmake $PYBIND11_EXT_DIR -DCMAKE_INSTALL_PREFIX=$PYBIND11_BUILD_DIR -Wno-deprecated -Wno-dev && cmake --build . && sudo cmake --install .)
fi

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ for virtualenvwrapper in $(which virtualenvwrapper.sh) /usr/share/virtualenvwrap
pip install urdf_parser_py

# Install MuJoCo
pip install mujoco==3.2.0
pip install mujoco==3.2.2

# Install additional packages for Jupyter Notebook
pip install panel jupyter-server bash_kernel
Expand Down
2 changes: 1 addition & 1 deletion multiverse/external/blender-git/blender
Submodule blender updated from 2c29fd to 396f54
2 changes: 1 addition & 1 deletion multiverse/external/mujoco
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ elseif (WIN32)
)
endif()

set(mujoco_DIR ${BUILD_DIR}/mujoco/lib/cmake/mujoco)
set(MUJOCO_SOURCE_DIR ${BUILD_DIR}/mujoco)
set(OpenGL_GL_PREFERENCE LEGACY)

find_package(mujoco REQUIRED)
find_package(Threads REQUIRED)

include_directories(
Expand All @@ -35,7 +34,8 @@ if(UNIX)
Threads::Threads
jsoncpp
boost_filesystem
mujoco::mujoco
${MUJOCO_SOURCE_DIR}/lib/libmujoco.so
tinyxml2
)
set_target_properties(mujoco_headless PROPERTIES INSTALL_RPATH "${BUILD_DIR}/mujoco/lib;${LIB_DIR}/libstdc++")
elseif(WIN32)
Expand Down Expand Up @@ -67,7 +67,8 @@ if(UNIX)
Threads::Threads
jsoncpp
boost_filesystem
mujoco::mujoco
${MUJOCO_SOURCE_DIR}/lib/libmujoco.so
tinyxml2
)
set_target_properties(mujoco PROPERTIES INSTALL_RPATH "${BUILD_DIR}/mujoco/lib;${LIB_DIR}/libstdc++")
elseif(WIN32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def export_stl(out_stl: str) -> str:
if len([vertex for obj in bpy.data.objects for vertex in obj.data.vertices]) > 1000:
selected_object.modifiers.new("Weld", "WELD")
bpy.ops.object.modifier_apply(modifier="Weld")
bpy.ops.export_mesh.stl(filepath='{out_stl}',
use_selection=False,
axis_forward="Y",
axis_up="Z")
bpy.ops.wm.stl_export(filepath='{out_stl}',
export_selected_objects=False,
forward_axis="Y",
up_axis="Z")
"""


Expand Down

0 comments on commit 95eab65

Please sign in to comment.