{"id":25871891,"url":"https://github.com/lagadic/matlab_ros_bridge","last_synced_at":"2025-03-02T07:34:56.329Z","repository":{"id":24200217,"uuid":"27591571","full_name":"lagadic/matlab_ros_bridge","owner":"lagadic","description":"Set of simulink s-functions to communicate with ROS","archived":false,"fork":false,"pushed_at":"2020-10-15T09:29:56.000Z","size":370,"stargazers_count":22,"open_issues_count":3,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-03-26T05:44:52.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lagadic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-05T12:56:59.000Z","updated_at":"2024-01-02T12:13:04.000Z","dependencies_parsed_at":"2022-08-22T14:30:18.004Z","dependency_job_id":null,"html_url":"https://github.com/lagadic/matlab_ros_bridge","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lagadic%2Fmatlab_ros_bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lagadic%2Fmatlab_ros_bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lagadic%2Fmatlab_ros_bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lagadic%2Fmatlab_ros_bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lagadic","download_url":"https://codeload.github.com/lagadic/matlab_ros_bridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241476352,"owners_count":19968902,"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":[],"created_at":"2025-03-02T07:34:51.626Z","updated_at":"2025-03-02T07:34:56.336Z","avatar_url":"https://github.com/lagadic.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# matlab_ros_bridge\r\n\r\nThis page contains the source code of a set of Matlab C++ S-functions that can be used to:\r\n\r\n* synchronize simulink with the system clock, thus obtaining a soft-real-time execution;\r\n* interface simulink blocks with other ROS nodes using ROS messages.\r\n\r\nThis project is based on a work started by Martin Riedel and Riccardo Spica at the Max Plank Institute for Biological Cybernetics in Tuebingen (Germany).\r\nThis fork is currently supported by [Riccardo Spica](mailto:riccardo.spica@irisa.fr) and [Giovanni Claudio](mailto:giovanni.claudio@irisa.fr) at the Inria Istitute in Rennes (France).\r\n\r\nThe software is released under the BSD license. See the LICENSE file in this repository for more information.\r\n\r\nSince the compiling procedure is quite involved, please read the entire instructions carefully at least once **before** attempting to compile.\r\n\r\n## Configuring Matlab\r\n\r\nBefore proceeding with the next steps you need to configure Matlab mex compiler.\r\n \r\nFor Matlab 2014b and older, run matlab and type the following command in the command window:\r\n```matlab\r\nmex -setup\r\n```\r\nWhen you get the following message:\r\n\r\n    Enter the number of the compiler (0-1):\r\n    \r\nEnter 1 to select the first option. This should create a mex option file in ~/.matlab/R2014a/mexopts.sh.\r\nOpen this file and make sure that the correct version of the gnu compiler is used.\r\n\r\nFor Matlab 2015a and newer, run matlab and type the following commands in the command window\r\n```matlab\r\nmex -setup\r\nmex -setup C++\r\n```\r\nThis should create two files in ~/.matlab/\u003cmatlab_version\u003e/ named mex_C_glnxa64.xml and mex_C++_glnxa64.xml.\r\nOpen mex_C++_glnxa64.xml and substitute all instances of \"g++\" and \"$GCC\" with \"g++-4.7\" (or 4.4 for older versions of Matlab).\r\nOpen mex_C_glnxa64.xml and substitute all instances of \"gcc\" and \"$GCC\" with \"gcc-4.7\" (or 4.4 for older versions of Matlab).\r\n\r\n## Compiling the bridge\r\n\r\nThe process of compiling the matlab_ros_bridge is not straightforward. The main problem is that MATLAB doesn't use the system distribution of boost but instead comes with its ows shipped version, which can be found in, e.g. 'matlabroot/bin/glnxa64/'.\r\nSince the mex files that we generate will run inside matlab it is important that they are linked against the same version of boost that is used in MATLAB. Moreover, since the mex files will also be linked to ROS libraries, we also need to recompile ROS and link it to the same version of boost.\r\nFinally we also need to compile everyting (boost, ros and our mex files) using a c/c++ compiler officially supported by the MATLAB distribution that we are using.\r\n\r\n### Compiling boost\r\n\r\nThis section will guide you through the process of compiling the required version of boost with the compiler supported by your Matlab version. Before doing this you should try using one of the precompiled boost distributions available in the download section of this repository. Check the version correspondance table below in this page to find the correct download link.\r\nIf you cannot find a precompiled boost download link for you setup then keep reading, otherwise skip to the following section.\r\n\r\n1. Download the correct version of boost from [here](http://www.boost.org/users/history/) in a folder of your choice (later referred to as \u003cboost_dir\u003e). To know which version you need you can type, in a matlab command window, the following command: \r\n\r\n    ```matlab\r\n    ls([matlabroot '/bin/glnxa64/libboost_date_time*'])\r\n    ```\r\n2. Open a new terminal and navigate to \u003cboost_dir\u003e and give the following command: \r\n\r\n    ```bash\r\n    $ ./bootstrap.sh --prefix=path/to/boost/installation/prefix\r\n    ```\r\n3. Edit the file \u003cboost_dir\u003e/project-config.jam with your favourite tool and substitute: \r\n\r\n    \u003eusing gcc;\r\n    \r\n    with (e.g.) \r\n    \r\n    \u003eusing gcc : 4.4 : g++-4.4 : \u003ccxxflags\u003e-std=c++0x ;\r\n    \r\n    The exact version of gcc/g++ that you need to use depends on the matlab release (check it on [Matlab](http://www.mathworks.it/support/sysreq/previous_releases.html) website).\r\n\r\n4. Build boost by doing:\r\n\r\n    ```bash\r\n    $ ./bjam link=shared -j8 install\r\n    ```\r\nNote: while building Boost you might encounter [this pseudo-bug](https://svn.boost.org/trac/boost/ticket/6940) due to an incompatibility between older versions of Boost and the new C11 standard. To solve this you can either substitute all occurrences of `TIME_UTC` in all Boost headers with `TIME_UTC_` (as done in more recent versions of Boost). For istance, in version 1.49.0, you need to modify \u003cboost_dir\u003e/boost/thread/xtime.hpp and \u003cboost_dir\u003e/libs/thread/src/pthread/timeconv.inl.\r\n\r\nIn some cases you might be able to solve this issue by modifying \u003cboost_dir\u003e/project-config.jam so as to change\r\n\r\n\u003eusing gcc : 4.4 : g++-4.4 ;\r\n\r\nto\r\n\r\n\u003eusing gcc : 4.4 : g++-4.4 : \u003ccxxflags\u003e-U_GNU_SOURCE ;\r\n\r\nIf you are building boost on a x64 system you might also encounter [this bug](https://svn.boost.org/trac/boost/ticket/6851). In this case just apply the proposed fix.\r\n\r\n### Compiling ROS\r\n\r\n5. Follow the instructions for your ROS distribution on `http://wiki.ros.org/\u003cdistro\u003e/Installation/Source` (e.g. for [Indigo](http://wiki.ros.org/indigo/Installation/Source)), to install ROS-Comm in the \"wet\" version until you need to compile. DO NOT COMPILE NOW (i.e. do not run catkin_make or catkin_make_isolated). To reduce the number of ros packages to compile, you can also initialize your workspace with\r\n\r\n    ```bash\r\n    $ rosinstall_generator roscpp geometry_msgs std_msgs sensor_msgs shape_msgs --rosdistro indigo --deps --wet-only --tar \u003e mrb.rosinstall\r\n    $ wstool init -j8 src mrb.rosinstall\r\n    ```\r\nTo disable unnecessary message generators you can also run ``export ROS_LANG_DISABLE=\"genlisp;genpy;geneus;gennodejs\"``.\r\n6. In a terminal navigate to the src directory of the catkin workspace created in the previous step and do:\r\n\r\n    ```bash\r\n    $ wstool set matlab_ros_bridge --git https://github.com/lagadic/matlab_ros_bridge.git\r\n    $ wstool update matlab_ros_bridge\r\n    ```\r\n7. Before compiling you might also need to modify the file src/roscpp/src/libros/param.cpp as described [here](https://github.com/ros/ros_comm/commit/0a589a52f5296bb3002a2f97912989715f064630).\r\n\r\n8. Compile ros and the bridge with:\r\n\r\n    ```bash\r\n    $ src/catkin/bin/catkin_make --cmake-args -DBOOST_ROOT=path/to/boost/installation/prefix -DBoost_NO_SYSTEM_PATHS=ON -DCMAKE_C_COMPILER=/usr/bin/gcc-4.7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.7 -DMATLAB_DIR=/usr/local/MATLAB/R2015b\r\n    ```\r\n    note that you might need to change this command according to your \u003cboost_dir\u003e, Matlab path and compiler version.\r\n    Add `install` at the end or run `catkin_make install` if desired.\r\n    For old versions of ROS (before Indigo) you may need to use the command `catkin_make_isolated` instead of `catkin_make`.\r\n    Note: the incompatibility issue discussed in the previous section might cause `rosbag` (and possibly other packages) to fail building. If this is the case, either substitute all occurrences of `TIME_UTC` in all rosbag source files with `TIME_UTC_` or add `-DCMAKE_CXX_FLAGS=-U_GNU_SOURCE` to your `catkin_make` command above.\r\n\r\n9. Make sure you have \"sourced\" your workspace by running:\r\n\r\n    ```bash\r\n    $ source /path/to/your/catkin_ws/devel/setup.bash\r\n    ````\r\n    \r\n    Navigate to the build directory of the package `matlab_ros_bridge`. It should be  `catkin_ws/build/` or `catkin_ws/build_isolated/matlab_ros_bridge` if you used `catkin_make_isolated`. Now generate the simulink block library by running:\r\n\r\n    ```bash\r\n    $ cmake .\r\n    $ make generate_library\r\n    ```\r\n\r\n### Compiling procedure with ROS kinetic and Matlab 2017a\r\n\r\nWhen using this combination, a special procedure needs to be followed because of some compiling issues that are still being investigated. \r\n\r\n1. Follow the above procedure until step 4.\r\n\r\n5. Initialize your workspace with\r\n\r\n    ```bash\r\n    $ rosinstall_generator roscpp geometry_msgs std_msgs sensor_msgs shape_msgs --rosdistro kinetic --deps --wet-only --tar --exclude rospack geneus genlisp gennodejs genpy \u003e mrb.rosinstall\r\n    $ wstool init -j8 src mrb.rosinstall\r\n    ```\r\n\r\n6. Clone the console_bridge package and build it using gcc-4.9\r\n    ```bash\r\n    $ git clone git@github.com:ros/console_bridge.git\r\n    $ mkdir console_bridge/build\r\n    $ cd console_bridge/build\r\n    $ cmake -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9 -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_CXX_FLAGS=\"-Wl,--rpath=/usr/local/MATLAB/R2017a/sys/os/glnxa64\" ..\r\n    $ make install\r\n\r\n7. Follow steps 6 and 7 of the standard procedure.\r\n\r\n8. Compile ros and the bridge with:\r\n\r\n    ```bash\r\n    $ src/catkin/bin/catkin_make --cmake-args -DBOOST_ROOT=path/to/boost/installation/prefix -DBoost_NO_SYSTEM_PATHS=ON -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9 -DMATLAB_DIR=/usr/local/MATLAB/R2017a -DROSCONSOLE_BACKEND=print -DCMAKE_CXX_FLAGS=\"-Wl,-rpath,/usr/local/MATLAB/R2017a/sys/os/glnxa64\" -Dconsole_bridge_DIR=path/to/console_bridge/build\r\n    ```\r\n\r\n9. Follow step 9 of the standard procedure.\r\n\r\n### Running MATLAB\r\n\r\n10. In your [MATLAB Startup File](http://www.mathworks.it/it/help/matlab/matlab_env/startup-options.html) add the following lines:\r\n\r\n    ```matlab\r\n    run(fullfile('path','to','your','catkin_ws','devel_isolated','matlab_ros_bridge','share','matlab_ros_bridge','setup.m'));\r\n    ```\r\n11. To run matlab open a terminal and type the following:\r\n\r\n    ```matlab\r\n    $ source /path/to/your/catkin_ws/devel/setup.bash\r\n    $ matlab\r\n    ```\r\n\r\n### Testing that everything works\r\n\r\n12. In your matlab command window navigate to the folder `/path/to/your/catkin_ws/src/matlab_ros_bridge/matlab_ros_bridge/models` and type\r\n\r\n    ```matlab\r\n    Tsim = 2e-5;\r\n    ```\r\n    \r\n    Now open the model `test.slx` and try to run it in all different running mode.\r\n\r\n## Note\r\n\r\nIt might be possible (but it has never been tested) to avoid compiling boost and try to link ros and the mex files against the boost libraries contained in the MATLAB installation directory.\r\n\r\n\r\n## Matlab boost and cpp version correspondances and download link\r\n\r\nMatlab version  | gcc supported version | shipped boost vesion | compiled boost download | Matlab compiled version\r\n------------- | -------------- | ------------- | ------------- | ------------- |\r\n2012a  | GNU gcc/g++ 4.4.x | [1.44.0](http://sourceforge.net/projects/boost/files/boost/1.44.0/boost_1_44_0.tar.gz/download) | [boost_1_44_0_gcc_4_4.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_44_0_gcc_4_4.tar.bz2) | [boost_R2012a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2012a_x64.tar.gz)\r\n2012b  | GNU gcc/g++ 4.4.x | [1.44.0](http://sourceforge.net/projects/boost/files/boost/1.44.0/boost_1_44_0.tar.gz/download) | [boost_1_44_0_gcc_4_4.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_44_0_gcc_4_4.tar.bz2) | [boost_R2012b_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2012b_x64.tar.gz)\r\n2013a  | GNU gcc/g++ 4.4.x | [1.49.0](http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download) | [boost_1_49_0_gcc_4_4.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_49_0_gcc_4_4.tar.bz2) | [boost_R2013a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2013a_x64.tar.gz)\r\n2013b  | GNU gcc/g++ 4.7.x | [1.49.0](http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download) | [boost_1_49_0_gcc_4_7.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_49_0_gcc_4_7.tar.bz2) | [boost_R2013b_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2013b_x64.tar.gz)\r\n2014a  | GNU gcc/g++ 4.7.x | [1.49.0](http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download) | [boost_1_49_0_gcc_4_7.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_49_0_gcc_4_7.tar.bz2) | [boost_R2014a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2014a_x64.tar.gz)\r\n2015a  | GNU gcc/g++ 4.7.x | [1.49.0](http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download) | [boost_1_49_0_gcc_4_7.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_49_0_gcc_4_7.tar.bz2) | [boost_R2014a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2015a_x64.tar.gz)\r\n2015b  | GNU gcc/g++ 4.7.x | [1.49.0](http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download) | [boost_1_49_0_gcc_4_7.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_49_0_gcc_4_7.tar.bz2) | [boost_R2014a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2015b_x64.tar.gz)\r\n2016a  | GNU gcc/g++ 4.7.x | [1.56.0](http://sourceforge.net/projects/boost/files/boost/1.56.0/boost_1_56_0.tar.gz/download) | [boost_1_56_0_gcc_4_7.tar.bz2](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_1_56_0_gcc_4_7.tar.bz2) | [boost_R2016a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2016a_x64.tar.gz)\r\n2017a  | GNU gcc/g++ 4.9.x | [1.56.0](http://sourceforge.net/projects/boost/files/boost/1.56.0/boost_1_56_0.tar.gz/download) | N/A | [boost_R2017a_x64.tar.gz](https://github.com/lagadic/matlab_ros_bridge/releases/download/v0.1/boost_R2017a_x64.tar.gz)\r\n\r\n## Ros/Matlab combinatios that have already been tested:\r\n\r\nRos\\Matlab  | __2013b__ | __2014a__ | __2014b__ | __2015a__ | __2015b__ | __2016a__ | __2017a__ |\r\n----------- | --------- | --------- | --------- | --------- | --------- | --------- | --------- |\r\n__Hydro__ | working | working | never tested | never tested | never tested | never tested | never tested |\r\n__Indigo__ | never tested | working | working | working | working | working | never tested |\r\n__Kinetic__ | never tested | never tested | never tested | never tested | never tested | never tested | not working |\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flagadic%2Fmatlab_ros_bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flagadic%2Fmatlab_ros_bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flagadic%2Fmatlab_ros_bridge/lists"}