Cannot set message type in ROS Blank message block

3 ビュー (過去 30 日間)
Semion Kurochkin
Semion Kurochkin 2021 年 12 月 8 日
編集済み: Semion Kurochkin 2021 年 12 月 8 日
I have some problems with ROS Blank message block.
I use script to create blocks in MATLAB Simulink:
add_block('roslib/ROS/Blank Message', 'ROS_MSGS/cmd_msg');
set_param('ROS_MSGS/cmd_msg', "Position", [210 165 360 205])
set_param('ROS_MSGS/cmd_msg', 'messageType', 'nav_msgs/Odometry');
This script runs fine, but I ran into the following problem:
The third line of the script changes the type of the ROS Message (I use nav_msgs/Odometry), it executes without errors and indeed on the block you can see the desired message type (picture 1). If you open Parameters section (on the right), you will see that nothing has changed. If you click on the block, the message type became geometry_msgs/Point again.
If i change the type manually by clicking on the button 'Select' – it's working.
Summing up, I would like to ask a question: how to write the commands in the script correctly so that the message type changes correctly?

回答 (1 件)

Semion Kurochkin
Semion Kurochkin 2021 年 12 月 8 日
編集済み: Semion Kurochkin 2021 年 12 月 8 日
I found a solution: instead of
set_param('ROS_MSGS/cmd_msg', 'messageType', 'nav_msgs/Odometry');
I use
set_param('ROS_MSGS/cmd_msg', 'entityType', 'nav_msgs/Odometry');
and message type changes correctly, but I don't know why.

カテゴリ

Help Center および File ExchangeSpecialized Messages についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by