Questions when Work with ROS2 Messages Using MATLAB Function Block

조회 수: 6 (최근 30일)
Hello!
I have a question with the matlab functions while dealing with the ros2 messages.
Following the intructions I run successfully with the ros1 blank message, but when I changed to the ros2 blank like the screenshot, the matlab has no response after typing ros.createSimulinkBus(gcs).
Do you konw why this is no use with the ROS2 blank messages?
The link is: https://de.mathworks.com/help/ros/ug/work-with-ros-messages-in-simulink.html
Thanks!

채택된 답변

Abhijeet Gadkari
Abhijeet Gadkari 2022년 2월 23일
편집: Abhijeet Gadkari 2022년 2월 23일
Hello Xiaochen,
The function, ros.createSimulinkBus(modelName), is not intended for use with a Simulink model containing ROS 2 blocks. This function only works (searches) for the ROS blocks in the Simulink model.
For ROS 2 blocks, use ros.ros2.createSimulinkBus(modelName) function instead.
This function will create the buses, if the OpenFcn callback of the model has not done so already, and return the name of the buses as a cell-array.
-Abhijeet
  댓글 수: 3
Abhijeet Gadkari
Abhijeet Gadkari 2022년 2월 24일
편집: Abhijeet Gadkari 2022년 2월 24일
Hello Xiaochen,
For ROS 2, buses are not saved in the base workspace anymore; this is currently a limitation of ROS 2 blocks. The buses are saved in an internal Simulink dictionary workspace that is not visible.
However, you can still use the names of the buses returned by ros.ros2.createSimulinkBus(modelName) function to access bus in Simulink.
For instance, copy the name of the bus and set the input/output data-type values of the MATLAB function block as shown below:
Set Bus data-types in MATLAB Function block
-Abhijeet
Xiaochen Gao
Xiaochen Gao 2022년 2월 24일
Thanks! I just did it successfully.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ROS Network Access in Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by