MATLAB: Matlab 2020b rosgenmsg can’t find CMake

cmakeROS Toolboxros1rosgenmsg

Hello,
I used rosgenmsg for ROS1 with Matlab 2020a on Ubuntu 18.04 and it worked fine. Now I'm trying the same command on Matlab 2020b on Ubuntu 20.04. It seems there's a whole new build system using Python and a C++ compiler in the backend instead of Java. I now get an error about CMake not found:
Validating message files in folder '/home/anton/catkin_ws/src/crtk'..Done.
[0/1] Generating MATLAB interfaces for custom message packages... 0%Error using ros.internal.utilities.getCMakeBinaryPath (line 24)
Could not find CMake in your system. Please install CMake version 3.15.5 or higher and rerun the command.
Error in ros.internal.CatkinBuilder.getCMakePath (line 82)
[aPath, aVersion] =
ros.internal.utilities.getCMakeBinaryPath(ros.internal.CatkinBuilder.CMAKEMINVERSION);
Meawhile, CMake is installed (using apt):
~$ cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
~$ which cmake
/usr/bin/cmake
Any advice on how to proceed to fix this issue? Also, I'm interested in ROS 1 messages (Noetic), not ROS 2.

Best Answer

Hello Anton,
R2020b involved a large replacement of the ROS functionality in MATLAB. As you have found, it supports rosgenmsg natively in the toolbox (no support package required), but does have new dependencies on Python and CMake.
In order to ensure that CMake is available in MATLAB, ensure that it is on the system PATH environment variable. Based on your terminal commands, it seems like it should be. Just to make sure, can you run these from within MATLAB:
!which cmake
!cmake --version
It's possible that the PATH in your terminal and the PATH in the MATLAB environment is different for some reason.
For other requirements (Python, compiler), see the ROS Toolbox System Requirements page.
-Cam
Related Question