C++ ROS Node with ert.tlc succeeds but C++ executable with grt.tlc gives slros_initialize.h error

2 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.
Language: C++
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
#include "slros_initialize.h"
compilation terminated.
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.
Ehtisham ul Hasan
Ehtisham ul Hasan on 30 Apr 2021
Thank you for the response. If ROS Toolbox supports only Catkin toolchain then ert.tlc should work for me but I do not find the simulation running in real time when I launch the C++ ROS node for my model in Gazebo. I think this because the real time factor was between 0.7 to 0.8 and not close to 1.
Also I will be using the final controller on a real hardware and as per my understanding I will have to build it using grt.tlc and only then it will be processed by a realtime kernel to finally run the C++ executable on a ROS enabled real robot.
Please correct me if I am wrong and suggest suitable workflow if possible.
Thank you
Nicolas TESTARD on 30 Jun 2021
Did you set the hardware board to ROS in the hardware implementation section of the configuration parameters?

Sign in to comment.

Answers (1)

Abhijeet Gadkari
Abhijeet Gadkari on 3 May 2021
Hello Hasan,
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).
  1 Comment
Ehtisham ul Hasan
Ehtisham ul Hasan on 4 May 2021
Thank you for the kind and detailed response. I will try this thing in parallel as due to time constraint I have started to write controller in C++ directly. This is indeed giving me tough time as I never wanted to adopt this pipeline but I remain curios and will explore further what you suggested soon.
Thank you for the support

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!