필터 지우기
필터 지우기

ROS2 unable to use "Write Image" block = error in WriteImageFcnBlock.m

조회 수: 5 (최근 30일)
Dylan
Dylan 2024년 4월 18일
댓글: Dylan 2024년 4월 19일
Hi everyone - I am trying out the ROS2 toolbox for Simulink, and can't successfully use the ROS2 Write Image block. I have loaded a demo image to the workspace using testImg = imread("free-images.jpg"), and it is loading as a 800x1200x3 uint8 variable. I have loaded it into Simulink using "Image From Workspace", and sent it into the ROS2 Write Image block with rgb8 encoding. Unfortunately I get the error below, and other encoding options also don't work. Any help? I have attached the error and setup below.
An error occurred during simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 129 exceeds valid range [1-128].
Error in WriteImageFcnBlock.m (line 25)
Data(1:DataLength) = Data1(1:DataLength);
Error in 'aprilTagTest/Write Image/MATLAB Function' (line 30)

채택된 답변

Jagadeesh Konakalla
Jagadeesh Konakalla 2024년 4월 19일
Hi Dylan,
Please follow the example on how to access variable length array ROS messages in Simulink. You need to set the Maximum Size of a Variable-length Array in your Simulink model.
Thanks and regards,
Jagadeesh K
  댓글 수: 2
Dylan
Dylan 2024년 4월 19일
Thank you so much! That is the solution.
Dylan
Dylan 2024년 4월 19일
Out of curiosity, is there a way to dynamically set the size of the relevant variable-length array based on a variable from the workspace?

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by