Skip to content

Commit 0e5a7b8

Browse files
authored
Merge pull request #324 from thowell/installation
Improve installation instructions
2 parents c82f6a6 + edd169b commit 0e5a7b8

File tree

2 files changed

+91
-26
lines changed

2 files changed

+91
-26
lines changed

README.md

+89-24
Original file line numberDiff line numberDiff line change
@@ -66,48 +66,110 @@ Humanoid motion-capture tracking:
6666

6767
[![Tracking](http://img.youtube.com/vi/tEBVK-MO1Sw/hqdefault.jpg)](https://www.youtube.com/watch?v=tEBVK-MO1Sw)
6868

69-
7069
## Graphical User Interface
7170

7271
For a detailed dive of the graphical user interface, see the
7372
[MJPC GUI](docs/GUI.md) documentation.
7473

7574
## Installation
75+
MJPC is tested with [Ubuntu 20.04](https://releases.ubuntu.com/focal/) and [macOS-12](https://www.apple.com/by/macos/monterey/). In principle, other versions and Windows operating system should work with MJPC, but these are not tested.
76+
77+
### Prerequisites
78+
Operating system specific dependencies:
79+
80+
#### macOS
81+
Install [Xcode](https://developer.apple.com/xcode/).
82+
83+
Install `ninja` and `zlib`:
84+
```sh
85+
brew install ninja zlib
86+
```
87+
88+
#### Ubuntu 20.04
89+
```sh
90+
sudo apt-get update && sudo apt-get install cmake libgl1-mesa-dev libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev ninja-build zlib1g-dev clang-12
91+
```
92+
93+
### Clone MuJoCo MPC
94+
```sh
95+
git clone https://github.com/google-deepmind/mujoco_mpc
96+
```
97+
98+
### Build and Run MJPC GUI application
99+
1. Change directory:
100+
```sh
101+
cd mujoco_mpc
102+
```
103+
104+
2. Create and change to build directory:
105+
```sh
106+
mkdir build
107+
cd build
108+
```
109+
110+
3. Configure:
111+
112+
#### macOS-12
113+
```sh
114+
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja -DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
115+
```
116+
117+
#### Ubuntu 20.04
118+
```sh
119+
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -G Ninja -DCMAKE_C_COMPILER:STRING=clang-12 -DCMAKE_CXX_COMPILER:STRING=clang++-12 -DMJPC_BUILD_GRPC_SERVICE:BOOL=ON
120+
```
121+
**Note: gRPC is a large dependency and can take 10-20 minutes to initially download.**
122+
123+
4. Build
124+
```sh
125+
cmake --build . --config=Release
126+
```
127+
128+
6. Run GUI application
129+
```sh
130+
cd bin
131+
./mjpc
132+
```
76133

77-
You will need [CMake](https://cmake.org/) and a working C++20 compiler to build
78-
MJPC. We recommend using [VSCode](https://code.visualstudio.com/) and 2 of its
134+
### Build and Run MJPC GUI application using VSCode
135+
We recommend using [VSCode](https://code.visualstudio.com/) and 2 of its
79136
extensions ([CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools)
80137
and [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools))
81138
to simplify the build process.
82139

83-
1. Clone the repository: `git clone https://github.com/google-deepmind/mujoco_mpc.git`
140+
1. Open the cloned directory `mujoco_mpc`.
84141
2. Configure the project with CMake (a pop-up should appear in VSCode)
85-
3. Build and run the `mjpc` target in "release" mode (VSCode defaults to
142+
3. Set compiler to `clang-12`.
143+
4. Build and run the `mjpc` target in "release" mode (VSCode defaults to
86144
"debug"). This will open and run the graphical user interface.
87145

88-
### macOS
89-
Additionally, install [Xcode](https://developer.apple.com/xcode/).
90-
91-
### Ubuntu
92-
Additionally, install:
93-
```shell
94-
sudo apt-get install libgl1-mesa-dev libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev ninja-build
95-
```
96-
97146
### Build Issues
98147
If you encounter build issues, please see the
99148
[Github Actions configuration](https://github.com/google-deepmind/mujoco_mpc/blob/main/.github/workflows/build.yml).
100-
This provides the exact setup we use for building MJPC for testing.
101-
102-
We recommend building with `clang` and not `gcc`.
149+
This provides the exact setup we use for building MJPC for testing with Ubuntu 20.04 and macOS-12.
103150

104151
# Python API
152+
We provide a simple Python API for MJPC. This API is still experimental and expects some more experience from its users. For example, the correct usage requires that the model (defined in Python) and the MJPC task (i.e., the residual and transition functions defined in C++) are compatible with each other. Currently, the Python API does not provide any particular error handling for verifying this compatibility and may be difficult to debug without more in-depth knowledge about MuJoCo and MJPC.
105153

106-
We provide a simple Python API for MJPC. This API is still experimental and expects some more experience from its users. For example, the correct usage requires that the model (defined in Python) and the MJPC task (i.e., the residual and transition functions defined in C++) are compatible with each other. Currently, the Python API does not provide any particular error handling for verifying this compatibility and may be difficult to debug without more in-depth knowledge about mujoco and MJPC.
154+
## Installation
155+
156+
### Prerequisites
157+
1. Build MJPC (see instructions above).
158+
159+
2. Python 3.10
107160

108-
## Installing via Pip
109-
First, build MJPC (see above).
161+
3. (Optionally) Create a conda environment with **Python 3.10**:
162+
```sh
163+
conda create -n mjpc python=3.10
164+
conda activate mjpc
165+
```
110166

167+
4. Install MuJoCo
168+
```sh
169+
pip install mujoco
170+
```
171+
172+
### Install API
111173
Next, change to the python directory:
112174
```sh
113175
cd python
@@ -123,11 +185,14 @@ Test that installation was successful:
123185
python "mujoco_mpc/agent_test.py"
124186
```
125187

126-
Additionally, the [Python version of MuJoCo](https://pypi.org/project/mujoco/#history) should match the MJPC version (this information can be found in the terminal while the application is running).
127-
188+
Example scripts are found in `python/mujoco_mpc/demos`. For example from `python/`:
189+
```sh
190+
python mujoco_mpc/demos/agent/cartpole_gui.py
191+
```
192+
will run the MJPC GUI application using MuJoCo's passive viewer via Python.
128193

129-
## Example Usage
130-
See [cartpole.py](python/mujoco_mpc/demos/agent/cartpole.py) for example usage for planning.
194+
### Python API Installation Issues
195+
If your installation fails or is terminated prematurely, we recommend deleting the MJPC build directory and starting from scratch as the build will likely be corrupted. Additionally, delete the files generated during the installation process from the `python/` directory.
131196

132197
## Predictive Control
133198

python/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def run(self):
208208
def _configure_and_build_agent_server(self):
209209
"""Check for CMake."""
210210
cmake_command = "cmake"
211-
build_cfg = "Debug"
211+
build_cfg = "Release"
212212
mujoco_mpc_root = Path(__file__).parent.parent
213213
mujoco_mpc_build_dir = mujoco_mpc_root / "build"
214214
cmake_configure_args = [
@@ -278,7 +278,7 @@ def _configure_and_build_agent_server(self):
278278
"Topic :: Scientific/Engineering",
279279
],
280280
packages=setuptools.find_packages(),
281-
python_requires=">=3.8",
281+
python_requires=">=3.10",
282282
setup_requires=[
283283
"grpcio-tools",
284284
"grpcio",

0 commit comments

Comments
 (0)