---
# System prepended metadata

title: Replan setup

---

## Preparation

```shell
conda create --name replan python=3.10
conda activate replan
```


```shell
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
pip install grpcio-tools pillow mujoco mujoco-python-viewer opencv-python ffmpeg joblib openai timeout-decorator
```

```shell
wget https://raw.githubusercontent.com/QwenLM/Qwen-VL/master/requirements.txt
pip install -r requirements.txt
```

```shell
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
```

```shell
sudo apt-get install libgl1-mesa-dev libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev ninja-build libsystemd-dev zlib1g-dev libstdc++-12-dev
```

## `furniture_sim`

```shell!
git clone git@github.com:JaLnYn/furniture_sim.git
cd furniture_sim
git checkout jalnyn/dev
export FURNITURE_SIM_DIR=`pwd`
cd ..
```


## `mujoco_mpc`

```shell!
git clone git@github.com:footoredo/mujoco_mpc.git
cd mujoco_mpc
git checkout replan2-rebuttal
export MUJOCO_MPC_DIR=`pwd`
ln -s ${FURNITURE_SIM_DIR} ./mjpc/tasks/panda
```

Either
```shell
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja -DCMAKE_C_COMPILER:STRING=clang-14 -DCMAKE_CXX_COMPILER:STRING=clang++-14 -DCMAKE_CXX_FLAGS:STRING=-stdlib=libc++ -DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
```
Or
```shell
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja -DCMAKE_C_COMPILER:STRING=clang-14 -DCMAKE_CXX_COMPILER:STRING=clang++-14 -DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
```

```shell
cmake --build . --config Release --target mjpc
./bin/mjpc
cd ..
```

### Python bind
```shell
cd python
pip install .
```

```shell
export SITE_PACKAGE_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`
rm -rf ${SITE_PACKAGE_DIR}/mujoco_mpc/mjpc/tasks

ln -s ${MUJOCO_MPC_DIR}/build/mjpc/tasks ${SITE_PACKAGE_DIR}/mujoco_mpc/mjpc/
```


## Main

```shell
git clone git@github.com:martaskrt/adaptivereplanning.git
cd adaptivereplanning
git checkout zihan-rebuttal-reformat
```

- Change the `LLM_WORKDIR` and `MPC_WORKDIR` variable in `planner.py` to `adaptivereplanning` path and `mujoco_mpc` path.


```shell
python planner.py --env ${env_name} --step_limit 8 --run_name ${run_name}
```

- `env_name`: `cabinet` / `kitchen` / `locklock` / `blocks`
- `step_limit`: maximum number of mpc calls

To run multiple instances:
```shell
./run.sh ${num_runs} ${env_name} ${run_name} --step_limit 8
```


## How to set up a new env

- `mjpc/tasks/CMakeLists.txt`
- `mjpc/tasks/tasks.cc`
- `mjpc/CMakeLists.txt`