- copy message (service, action if you have) files to the computer that runs MATLAB/Simulink
- navigate to that folder and use ros2genmsg to generate custom messages from ROS 2 definitions
- use the following command to check whether they are available:
ROS2 with simulink
조회 수: 1 (최근 30일)
이전 댓글 표시
Suppose I am creating a custom message type from my ROS device and publishing it under one topic(This topic might be a dictionary with different data types). Now on simulink on a different computer, can I subscribe to this topic with this custom message? Does simulink automatically understand the different data types? Or do I have to do something else?
PS. I am using ROS2
댓글 수: 0
답변 (1개)
Josh Chen
2023년 4월 24일
Hello Rahul,
In order for Simulink to subscribe to the topic and receive custom messages, you need to provide message definition and build the ROS 2 package same as what you need to do with a rclcpp ROS 2 node on a different computer.
To begin with, you can refer to the function ros2genmsg, the example in this page shows you how to use ros2genmsg to build a ROS 2 package containing definition of messages.
In your use case, you can:
>> ros2 msg list
4. Create a ROS 2 Subscribe block and select the topic, message type you would like to subscribe
Hope this helps,
Thanks,
Josh
댓글 수: 6
Josh Chen
2023년 4월 26일
you still need to define message type on MATLAB. There are some dynamic library files need to be generated with ros2genmsg so that Simulink can refer to.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!