Can't publish message from Simulink to ROS

7 ビュー (過去 30 日間)
Ben Locke
Ben Locke 2021 年 7 月 5 日
コメント済み: Nupur 2024 年 3 月 18 日
I am having trouble sending a message from Simulink to a ROS. The ROS master is running on a separate laptop which runs ROS kinetic on Ubuntu 16.04. When I echo the ROS topic on this laptop the message appears empty. The simulink model and empty message is attached below. Any help is much appreciated.

採用された回答

Abhijeet Gadkari
Abhijeet Gadkari 2021 年 7 月 6 日
編集済み: Abhijeet Gadkari 2021 年 7 月 6 日
Hello Ben,
sensor_msgs/Joy is a ROS message that contains variable sized sub-messages.
As shown in the Modify maximum Size of Variable-length Array section of that example, you need to set the correct array-size of the Axes and Buttons fields for sensors_msgs/Joy.
Variable size sensor_msgs/Joy
In above snapshot, I've updated the Simulink model with 'Probe Width' blocks and assigned the width to CurrentLength field. In PuTTy window, echo of /joy topic shows message published from MATLAB.
-Abhijeet
  2 件のコメント
Ben Locke
Ben Locke 2021 年 7 月 7 日
Hi Abhijeet
Thank you for your response, the model now works.
Best regards
Ben
Nupur
Nupur 2024 年 3 月 18 日
Hi @Abhijeet Gadkari I want to publsih ros2 message trajectory_msgs/JointTrajectoryPoint with positions [x1...xn, y1....yn] at each time step for example at time(t1) publish [x1...xn,y1...yn], at time(t2) publish [x1...xn, y1...yn] and so on.
I tried your solution for my task however, as the positons with size [128*2] i am getting erros. I have attached the file. Thanks in advance.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by