ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Javier

Unfortunately, I wasn't able to solve the problem and didn't even consider recompiling ROS. Because the way I was using my MATLAB code was pretty simple and I didn't have enough time to make things right, I ended up using the typical "hack" of making two programs: a standard C++ ROS node with no dependencies to the MATLAB code or MCR and another C++ program (not a ROS node) that linked to the MCR and the MATLAB shared library.

The C++ ROS node wrote the arguments needed for the MATLAB code as input files in a common folder and then called the C++ program that linked with the MCR. That same program then wrote the output to a common folder that was, at the end, read and parsed by the ROS node.

One final detail that I had to change is that the MCR installation was asking me to change my LD_LIBRARY_PATH, which was raising problems everywhere else in my system (OpenRAVE for example). Therefore, I wrote a simple bash script that just changed the LD_LIBRARY_PATH just before calling the program that linked to the MCR

echo Modifying LD_LIBRARY_PATH
old_lib_path=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/sys/java/jre/glnxa64/jre/lib/amd64:$LD_LIBRARY_PATH
export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v80/X11/app-defaults
echo LD_LIBRARY_PATH changed to $LD_LIBRARY_PATH

bin/PFTExpertNode
export LD_LIBRARY_PATH=$old_lib_path

As you can see, this is a really bad hack, but, because my application was simple enough, it was good enough for my needs.