simuling to ros array publish

14 ビュー (過去 30 日間)
Emre Gür
Emre Gür 2020 年 7 月 21 日
コメント済み: Emre Gür 2020 年 7 月 24 日
Hi I have a question. I need to publish this array from simuling to my ros network: "data: [50, -50, 50, -50]"
From terminal I can give this command and it works fine:
rostopic pub -1 /****/joint_motor_controller/command std_msgs/Float64MultiArray "data: [50, -50, 50, -50]"
But I want to achieve this from simulink as well however I couldnt achieve it. I set my publisher like the picture as well and my connection to my ros network is established successfully. I tried summing variables from MUX and BUS but it did not work. Thus how can I send a data array like the one above to my ros network?

採用された回答

Cam Salzberger
Cam Salzberger 2020 年 7 月 21 日
Hello Emre,
In order to send a ROS message through the Publish block, you first need to create a Blank Message to have the appropriate bus structure. Then you can assign data to the fields of the message using a Bus Assignment block, and pass the output of that into the Publish block. See here for a basic example.
Now using std_msgs/Float64MultiArray gets a little trickier because it has a variable-sized array as one of its message fields. If you have any trouble using, take a look at this page dedicated to the topic.
-Cam
  1 件のコメント
Emre Gür
Emre Gür 2020 年 7 月 24 日
Thank you so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeROS 2 Network Access in Simulink についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by