ROS compilation fails because 'slros_initialize.h' is missing.

The ROS example for Simulink
>> robotExROSGetStartedExample
runs fine, but compiling it for real-time execution fails, because the 'slros_initialize.h' is missing. The file should be automatically generated by the files listed in 'MATLAB/R2015a/toolbox/robotics/robotsimulink/robotslros/+robotics/+slros/+internal/+cgen'. The files should generate and save C++ code for creating a ROS node, and for creating C++ subscribers and publishers corresponding to Subscribe and Publish blocks in the model. However, they don't. The file 'slros_initialize.h' is not generated in the build folder or anywhere else on the system.
How can this issue be resolved?
Diagnostic output:
### Generasting code into build folder: /home/username/Desktop/Foldername/ROS_Example_prt
### Invoking Target Language Compiler on ROS_Example.rtw
### Using System Target File: /usr/local/MATLAB/R2015a/rtw/c/prt/prt.tlc
### Loading TLC function libraries
............
### Building ROS_Example: /usr/local/MATLAB/R2015a/bin/glnxa64/gmake -f ROS_Example.mk MAT_FILE=1 ISPROTECTINGMODEL=NOTPROTECTING OPTS="-DON_TARGET_WAIT_FOR_START=0"
.gcc -c -std=gnu99 -pedantic -fwrapv -fPIC -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DUSE_RTMODEL -O2 -D_GNU_SOURCE -DMODEL=ROS_Example -DRT -DNUMST=2 -DTID01EQ=1 -DNCSTATES=0 -DUNIX -DMT=0 -DHAVESTDIO -I. -I.. -I/usr/local/MATLAB/R2015a/simulink/include -I/usr/local/MATLAB/R2015a/extern/include -I/usr/local/MATLAB/R2015a/rtw/c/src -I/usr/local/MATLAB/R2015a/rtw/c/src/ext_mode/common -I/home/username/Desktop/Foldername/ROS_Example_prt -I/home/username/Desktop/Foldername -I/usr/local/MATLAB/R2015a/toolbox/coder/rtiostream/src/utils "ROS_Example_data.c"
In file included from ROS_Example_data.c:21:0:
ROS_Example.h:35:30: fatal error: slros_initialize.h: No such file or directory
#include "slros_initialize.h"
^
compilation terminated.
gmake: *** [ROS_Example_data.o] Error 1

3 件のコメント

James Wiken
James Wiken 2015 年 8 月 19 日
Could you attach the "ROS_Example.h" file referenced at the end of the Diagnostic output? I built the example, and the '#include "slros_initialize.h"' line that is causing the error you are seeing is located on a different line than in the file I generated. I would like to see what is causing the difference.
Tobias Blume
Tobias Blume 2016 年 4 月 22 日
I solved this problem by setting: code--> c/c++-Code --> Code Generation Options --> Hardware Implementation --> Hardware board
set this parameter to ROS.
also see tutorial
Rahul Bhadani
Rahul Bhadani 2016 年 5 月 16 日
Also, make sure roscore is running while doing code generation.

サインインしてコメントする。

回答 (1 件)

Josh Chen
Josh Chen 2023 年 4 月 17 日

0 投票

Hello Markus,
As Tobias suggested, please change the hardware board seeting to 'Robot Operating System (ROS)'. This is required to ensure the code generation process pick up all required predefined codes.
Thanks,
Josh

カテゴリ

質問済み:

2015 年 8 月 17 日

回答済み:

2023 年 4 月 17 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by