You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository provides a Simulink® C-MEX S-Function block interface to [MuJoCo™ physics engine](https://mujoco.org/).
4
+
5
+
[](https://www.mathworks.com/matlabcentral/fileexchange/####-file-exchange-title)
MATLAB R2022b or newer recommended. Install MATLAB with the above products and then proceed to setting up MuJoCo blocks.
24
+
25
+
*Note - You may need to rebuild the S-Function if you are using an older release of MATLAB*.
26
+
27
+
### Simulink Blockset for MuJoCo
28
+
29
+
#### Windows®:
30
+
31
+
- Download the latest release of this repository
32
+
- Open MATLAB R2022b. In case you are using a older MATLAB release, please follow the build instructions below to rebuild for a particular MATLAB release
33
+
- Run install.m in MATLAB command window. MuJoCo and GLFW libraries will be downloaded and added to MATLAB Path.
34
+
35
+
#### Ubuntu®:
36
+
37
+
- Download the latest release of this repository
38
+
- Download and install GLFW library from Ubuntu terminal
- Open MATLAB R2022b. In case you are using a older MATLAB release, please follow the build instructions below to rebuild for a particular MATLAB release
42
+
- Run install.m in MATLAB command window. MuJoCo library will be downloaded and added to MATLAB Path.
43
+
44
+
## Usage
45
+
Open examples/gettingStarted.slx model and click run
46
+
47
+
If the installation is successful, you should see a pendulum model running in a separate window and camera stream displayed by Video Viewer block (Computer Vision Toolbox)
48
+
49
+
### Blocks
50
+
51
+
{height=250px}
52
+
53
+
MuJoCo Plant block steps MuJoCo engine, renders visualization window & camera, sets actuator data and outputs sensor readings
54
+
55
+
It takes an XML (MJCF) as the main block parameter. It auto detects the inputs, sensors, cameras from XML and sets the ports, sample time and other internal configuration.
56
+
57
+
Inputs can either be a Simulink Bus or vector.
58
+
59
+
Sensors are output as a Simulink Bus.
60
+
61
+
RGB and Depth buffers from camera are output as vectors. These can be decoded to Simulink image/matrix using the RGB and Depth Parser blocks.
62
+
63
+

64
+

65
+
66
+
## Build Instructions (optional)
67
+
68
+
Steps for building/rebuilding the C-MEX S-Function code. These instructions are only required if you are cloning the repository instead of downloading the release.
69
+
70
+
### Windows:
71
+
72
+
- Install one of the following C++ Compiler
73
+
- Microsoft® Visual Studio® 2022 or higher (recommended)
74
+
- (or) [MinGW (GCC 12.2.0 or higher)](https://community.chocolatey.org/packages/mingw)
75
+
- Clone this repository
76
+
- Launch MATLAB and open the repository folder
77
+
-`>> install`
78
+
- Open tools/
79
+
- Open setupBuild.m. In case you are using MinGW compiler, edit the file and set selectedCompilerWin to "MINGW".
80
+
-`>> setupBuild`
81
+
-`>> mex -setup c++`
82
+
-`>> build`
83
+
84
+
### Ubuntu
85
+
86
+
- Install the tools required for compiling the S-Function
- Launch MATLAB and open the repository folder. Run the install.m script.
93
+
-`>> install`
94
+
- Open tools/ and run the following commands in MATLAB command Windows
95
+
-`>> setupBuild`
96
+
-`>> mex -setup c++`
97
+
-`>> build`
98
+
99
+
100
+
## License
101
+
102
+
The license is available in the license.txt file within this repository.
103
+
104
+
## Acknowledgements
105
+
Cite this work as,
106
+
107
+
Manoj Velmurugan. Simulink Blockset for MuJoCo Simulator (https://github.com/mathworks-robotics/mujoco-simulink-blockset), GitHub. Retrieved March 27, 2023.
108
+
109
+
110
+
Refer to [MuJoCo repository](https://github.com/deepmind/mujoco) for guidelines on citing MuJoCo physics engine.
111
+
112
+
The sample codes and API documentation provided for [MuJoCo](https://mujoco.readthedocs.io/en/latest/overview.html) and [GLFW](https://www.glfw.org/documentation) were used as reference material during development.
113
+
114
+
MuJoCo and GLFW libraries are dynamically linked against the S-Function and are required for running this blockset.
115
+
116
+
UR5e MJCF XML from [MuJoCo Menagerie](https://github.com/deepmind/mujoco_menagerie/tree/main/universal_robots_ur5e) was used for creating demo videos.
117
+
118
+
## Community Support
119
+
120
+
You can post your queries on the [MATLAB® Central™ File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/####-file-exchange-title) page.
0 commit comments