How do I use add_block for adding ROS library content like Blank Messages, Publish and Subscribe block programatically using Simulink? (Using MATLAB R2019a)

조회 수: 1 (최근 30일)
This is how my code looks :
clc;clear all;close all;
open_system(new_system('Test'));
system_name = 'Test';
load_system('Robotics System Toolbox')
add_block('Robotics System Toolbox/ROS/Blank Message','Test/msg_1')
I get the following error when I run the above code :
Error using load_system (line 21)
'Robotics System Toolbox' is not a valid model name because it is not a valid MATLAB function name.
Error in test (line 6)
load_system('Robotics System Toolbox') - Show complete stack trace
If I do not include the load_system function :
clc;clear all;close all;
open_system(new_system('Test'));
system_name = 'Test';
%load_system('Robotics System Toolbox')
add_block('Robotics System Toolbox/ROS/Blank Message','Test/msg_1')
, I get a similar error :
Error using test (line 7)
Error due to multiple causes.
Caused by:
Error using test (line 7)
'Robotics System Toolbox' is not a valid model name because it is not a valid MATLAB function name.
Error using test (line 7)
There is no block named 'Robotics System Toolbox/ROS/Blank Message'
Any suggestions on how to fix this?
  댓글 수: 1
AKSHAY SARVESH
AKSHAY SARVESH 2020년 7월 26일
After adding escape characters to the code,
clc;clear all;close all;
open_system(new_system('Test'));
system_name = 'Test';
%load_system('Robotics System Toolbox')
add_block('Robotics\ System\ Toolbox/ROS/Blank\ Message','Test/msg_1')
the error still persists
Error using test (line 7)
Error due to multiple causes.
Caused by:
Error using test (line 7)
'Robotics\ System\ Toolbox' is not a valid model name because it is not a valid MATLAB function name.
Error using test (line 7)
There is no block named 'Robotics\ System\ Toolbox/ROS/Blank\ Message'

댓글을 달려면 로그인하십시오.

채택된 답변

Cam Salzberger
Cam Salzberger 2020년 7월 27일
Hey Akshay,
I haven't tested this, but I believe that you should use (or at least can use) the library name that contains the block rather than the toolbox name. Try:
add_block('robotlib/Subscribe')
-Cam
  댓글 수: 3
Cam Salzberger
Cam Salzberger 2020년 7월 28일
If you hover over the block in the Library Browser, it should show the "path" to the block (lib/sublib/block).
-Cam

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Network Connection and Exploration에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by