C++ ROS Node with ert.tlc succeeds but C++ executable with grt.tlc gives slros_initialize.h error
10 views (last 30 days)
I am using ROS Melodic and Matlab 2020b on Ubuntu 18.04. I have a simulink model for publishing Joint Trajectories from Simulink to ROS enabled model in Gazebo (I am using ROS toolbox publisher and subscriber blocks) .
When I generate C++ ROS Node with ert.tlc. build is success and I can run the node successfuly from ROS terminal. But I need a C++ .exe file from this in realtime. So based on my requirement when I set system target file as grt.tlc.
Toolchain: Automatically locate an installed toolchain (it finds GNU gcc/g++ | gmake (64-bit Linux) on my system)
In Hardware Implementation I have set Device Type to x86-64 (Linix 64)
Solver has Type Fixed Step and Solver is auto
Fixed-step Size is 1.0
Build is not successful rest works fine and I get the following error
/home/has/simulink_models/makearmcommand_grt_rtw/makearmcommand.h:29:10: fatal error: slros_initialize.h: No such file or directory
gmake: *** [makearmcommand.o] Error 1
Build procedure for makearmcommand aborted due to an error.
I also looked for this header file in /usr/local/MATLAB/R2020b/simulink/include and I could not find it as well. But why it then gets generated during ert.tlc case (C++ ROS Node) is I dont understand.
Please advice. I am unable to understand how to fix it. Awaiting kind response.
NOTE: Generate Code only option is unchecked in my configuration options and after lookiong at various Matlab questions asked, I also tried by checking the Package Code and Artifiacts option and building but even using packngo option, it did not help me.
Abhijeet Gadkari on 3 May 2021
You must use "Robot Operating System (ROS)" as your hardware board setting (which automatically sets ert.tlc system target file) to generate a ROS node (especially when using ROS Simulink blocks) or ROS project from Simulink model. This hardware board setting auto selects all the required options including the required toolchain, Cakin, as mentioned by Jagadeesh in the comment. Changing the system target file to grt.tlc will reset all the settings done by hardware board and the generated code will not contain ROS related headers / sources and other ROS package dependencies as you observed.
You can deploy the standalone executable on your robot directly from Simulink model with this hardware board setting. If automatic deployment of standalone node generation does not meet your requirement, you can use the manual deployment steps. Manual deployement steps should allow you to make any necessary changes to the ROS package artifacts.
Please contact technical support if you need further assistance (especially real-time execution requirement).