{"id":15716458,"url":"https://github.com/mathworks-robotics/mujoco-simulink-blockset","last_synced_at":"2025-04-30T15:50:39.837Z","repository":{"id":160011960,"uuid":"625422930","full_name":"mathworks-robotics/mujoco-simulink-blockset","owner":"mathworks-robotics","description":"Blocks for accessing MuJoCo physics engine within Simulink","archived":false,"fork":false,"pushed_at":"2024-03-05T09:40:25.000Z","size":225,"stargazers_count":56,"open_issues_count":8,"forks_count":7,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-30T17:44:42.637Z","etag":null,"topics":["biomimetics","computer-vision","control-systems","matlab","mujoco","physics-simulation","robotics","robotics-control","robotics-simulation","simulink"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks-robotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-09T03:58:20.000Z","updated_at":"2025-03-28T17:42:41.000Z","dependencies_parsed_at":"2023-11-19T20:27:32.824Z","dependency_job_id":"d68e1a63-ac3a-4249-bbb8-aaa4400d9ee4","html_url":"https://github.com/mathworks-robotics/mujoco-simulink-blockset","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.04166666666666663,"last_synced_commit":"8bb749f0d77692d934b2489ab1d1fffa97eab2e4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-robotics%2Fmujoco-simulink-blockset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-robotics%2Fmujoco-simulink-blockset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-robotics%2Fmujoco-simulink-blockset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks-robotics%2Fmujoco-simulink-blockset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks-robotics","download_url":"https://codeload.github.com/mathworks-robotics/mujoco-simulink-blockset/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251734546,"owners_count":21635155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biomimetics","computer-vision","control-systems","matlab","mujoco","physics-simulation","robotics","robotics-control","robotics-simulation","simulink"],"created_at":"2024-10-03T21:45:41.147Z","updated_at":"2025-04-30T15:50:39.794Z","avatar_url":"https://github.com/mathworks-robotics.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simulink Blockset for MuJoCo Simulator \n\nThis repository provides a Simulink\u0026reg; C-MEX S-Function block interface to the [MuJoCo\u0026trade; physics engine](https://mujoco.org/).\n\n[![View \u003cFile Exchange Title\u003e on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/128028-mujoco-simulink-blockset)\n\nUseful for,\n1. Robot simulation (mobile, biomimetics, grippers, robotic arm)\n2. Development of autonomous algorithms\n3. Camera (RGB, Depth) rendering\n\n## Installation Instructions\n\n### MathWorks\u0026reg; Products (https://www.mathworks.com)\n\n- MATLAB\u0026reg; (required)\n- Simulink\u0026reg; (required)\n- Computer Vision Toolbox\u0026trade; (optional)\n- Robotics System Toolbox\u0026trade; (optional)\n- Control System Toolbox\u0026trade; (optional)\n- Simulink\u0026reg; Coder\u0026trade; (optional)\n\nMATLAB R2022b or newer is recommended. Install MATLAB with the above products and then proceed to set up MuJoCo blocks.\n\n*Note - You may need to rebuild the S-Function if you are using an older release of MATLAB*.\n\n### Simulink Blockset for MuJoCo\n    \n- (Linux users) Install GLFW library from Ubuntu terminal\n    \n    `sudo apt update \u0026\u0026 sudo apt install libglfw3 libglfw3-dev`\n- Download the latest release of this repository (MATLAB Toolbox - MLTBX file)\n- Open MATLAB R2022b or higher and install the downloaded MATLAB Toolbox file\n- Run the setup function packaged in the toolbox. MuJoCo (and GLFW for Windows users) library is downloaded and added to MATLAB path.\n    \n    `\u003e\u003emujoco_interface_setup`\n- (Linux users) The default pathdef.m is likely not saveable in Linux. Save pathdef.m to new location as given in this [MATLAB answer](https://www.mathworks.com/matlabcentral/answers/1653435-how-to-use-savepath-for-adding-path-to-pathdef-m-in-linux).\n    `savepath ~/Documents/MATLAB/pathdef.m`\n    \n## Usage\n`\u003e\u003emj_gettingStarted`\n    \nOpen the example model and run it in normal simulation mode.\n\nIf the installation is successful, you should see a pendulum model running in a separate window and camera streams displayed by Video Viewer blocks (Computer Vision Toolbox).\n\n*A dedicated graphics card is recommended for the best performance. Disable Video Viewer blocks if the model runs slow*\n\n*(Linux users) - In case MATLAB crashes, it may be due to a glibc bug. Please follow this [bug report](https://www.mathworks.com/support/bugreports/2632298) for a workaround!*\n\n### Blocks\n\u003cimg width=\"400\" alt=\"mjLib\" src=\"https://user-images.githubusercontent.com/8917581/230754094-908a0a52-2c5d-4e8e-bd82-d2dcc553a846.png\"\u003e\n\nMuJoCo Plant block steps MuJoCo engine, renders visualization window \u0026 camera, sets actuator data, and outputs sensor readings\n\nIt takes an XML (MJCF) as the main block parameter. It auto-detects the inputs, sensors, and cameras from XML to configure the block ports and sample time.\n\nInputs can either be a Simulink Bus or a vector.\n\nSensors are output as a Simulink Bus.\n\nRGB and Depth buffers from cameras are output as vectors. These can be decoded to Simulink image/matrix using the RGB and Depth Parser blocks.\n\n\nhttps://user-images.githubusercontent.com/8917581/230754110-e98b0ed6-05af-416c-9f39-7e5abf562b25.mp4\n\nhttps://user-images.githubusercontent.com/8917581/230754121-8486a61f-a2db-452c-a943-8682172b4f46.mp4\n\n\n## Build Instructions (optional)\n\nSteps 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.\n\n### Windows:\n\n- Install one of the following C++ Compiler\n  - Microsoft\u0026reg; Visual Studio\u0026reg; 2022 or higher (recommended)\n  - (or) [MinGW (GCC 12.2.0 or higher)](https://community.chocolatey.org/packages/mingw)\n- Clone this repository\n    \n    `$ git clone git@github.com:mathworks-robotics/mujoco-simulink-blockset.git`\n- Launch MATLAB and open the repository folder\n    - `\u003e\u003e install`\n- Open tools/ \n    - Open setupBuild.m. In case you are using MinGW compiler, edit the file and set selectedCompilerWin to \"MINGW\".\n    - `\u003e\u003e setupBuild`\n    - `\u003e\u003e mex -setup c++`\n    - `\u003e\u003e build`\n\n### Ubuntu\n\n- Install the tools required for compiling the S-Function\n\n    `$ sudo apt update \u0026\u0026 sudo apt install build-essential git libglfw3 libglfw3-dev `\n- Clone this repository\n\n    `$ git clone git@github.com:mathworks-robotics/mujoco-simulink-blockset.git`\n- Launch MATLAB and open the repository folder. Run the install.m script.\n    - `\u003e\u003e install`\n- Open tools/ and run the following commands in MATLAB command Windows\n    - `\u003e\u003e setupBuild`\n    - `\u003e\u003e mex -setup c++`\n    - `\u003e\u003e build`\n\n## Tips and Tricks\n- ***Code generation*** - The MuJoCo Plant block supports code generation (Simulink Coder) and monitor and tune for host target. Refer to mj_monitorTune.slx for more info.\n- ***Performance improvement*** - In case you want to reduce the mask initialization overhead, you can directly use the underlying S-Function. Select the MuJoCo Plant block and Ctrl+U to look under the subsystem mask. Make sure to call the initialization functions (whenever the MJCF XML model changes).\n\n## Limitations:\n\nLinux Compatibility:\n\nThis blockset is only tested in Ubuntu 22.04 and Ubuntu 20.04. Other Ubuntu versions and distros are not supported.\n\n### Software OpenGL:\n\nThis blockset does not work with software OpenGL. You can check whether MATLAB is using hardware GL with \u003e\u003eopengl info command.\n\nIn case you face graphics related issues, please try updating GLFW following the instructions given below!\n\n## Bugs/Workarounds\n\n### Rebuild GLFW From Source \n\nIn case MATLAB crashes while running getting started model and you see the following lines in stack trace,\n\n`#10 0x00007fdaf8619f40 in glfwCreateWindow () at /lib/x86_64-linux-gnu/libglfw.so.3`\n\n`#11 0x00007fdaf8675c4d in MujocoGUI::initInThread(offscreenSize*, bool)`,\n\nUpdating glfw could fix the issue.\n\nBuilding glfw from source ([glfw main - commit id](https://github.com/glfw/glfw/tree/46cebb5081820418f2a20f3e90b07f9b1bd44b42)) and installing fixed this issue for me,\n- sudo apt remove libglfw3 libglfw3-dev # Remove existing glfw\n- mkdir ~/glfwupdated\n- cd ~/gflwupdated\n- git clone git@github.com:glfw/glfw.git\n- sudo apt install cmake-qt-gui\n- cmake-gui\n- Set the source directory to the root of cloned repo\n- mkdir build in the cloned repo\n- Set the build directory\n- In Cmake Gui settings - Select \"BUILD_SHARED_LIBS\" as well\n- Configure and then generate\n- Open a terminal in the build directory and run $make in terminal\n- Once build goes through without any error, run $sudo make install in terminal\n- sudo ldconfig (to refresh linker cache)\n- Follow the build instructions for mujoco-simulink-blockset\n\n## License\n\nThe license is available in the license.txt file within this repository.\n\n## Acknowledgments\nCite this work as,\n\nManoj Velmurugan.  Simulink Blockset for MuJoCo Simulator (https://github.com/mathworks-robotics/mujoco-simulink-blockset), GitHub. Retrieved date. \n\n\nRefer to the [MuJoCo repository](https://github.com/deepmind/mujoco) for guidelines on citing the MuJoCo physics engine.\n\nThe 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.\n\nMuJoCo and GLFW libraries are dynamically linked against the S-Function and are required for running this blockset.\n\nUR5e MJCF XML from [MuJoCo Menagerie](https://github.com/deepmind/mujoco_menagerie/tree/main/universal_robots_ur5e) was used for creating demo videos.\n\n## Community Support\n\n\u003c!--- You can post your queries on the [MATLAB\u0026reg; Central\u0026trade; File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/####-file-exchange-title) page. ---\u003e\n\nYou can post your queries in the discussions section.\n\nCopyright 2023 The MathWorks, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-robotics%2Fmujoco-simulink-blockset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks-robotics%2Fmujoco-simulink-blockset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks-robotics%2Fmujoco-simulink-blockset/lists"}