フィルターのクリア

rosgenmsg(folderpath) from custom ros msgs add on causes Index exceeds the number of array elements (0).

3 ビュー (過去 30 日間)
Hello,
I'm trying to get Matlab to be able to use some custom ROS msgs from a ROS package that follows the required structure has worked in other environments. I've followed the instructions at https://www.mathworks.com/help/ros/ug/create-custom-messages-from-ros-package.html but will get a 'Index exceeds the number of array elements (0).' Error on the rosgenmsg(folderpath)
Any one run into this issue before or is this a bug.
  2 件のコメント
Dhananjay Kumar
Dhananjay Kumar 2020 年 3 月 30 日
Hey daniel, Can you write the complete error message you see or attach a snip?
Daniel Levy
Daniel Levy 2020 年 3 月 30 日
The code I used was straight from the instructions at https://www.mathworks.com/help/ros/ug/create-custom-messages-from-ros-package.html I also made sure that folder exists.
examplePackages = fullfile(fileparts(which('rosgenmsg')), 'examples', 'packages');
userFolder = 'C:\MATLAB\CustomMessages\';
copyfile(examplePackages, userFolder)
folderpath = userFolder;
rosgenmsg(folderpath)
Error message is below, breaks at rosgenmsg(folderpath)
Error using ROSScratchPad (line 8)
Index exceeds the number of array elements (0).
Thanks,

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

採用された回答

Cam Salzberger
Cam Salzberger 2020 年 3 月 30 日
Daniel,
This kind of error message generally comes up (in any MATLAB product) when you are trying to call a function but have shadowed the function name with a variable name. For example, if you do this:
rosgenmsg = 1;
myPath = 'C:\ros';
rosgenmsg(myPath)
MATLAB is trying to index into the variable "rosgenmsg" using the character values in "myPath" as index values. Since 'C' is valued at a larger index than the length of "rosgenmsg", you see this error.
Run this command to see if you have "rosgenmsg" shadowed by a variable name:
which -all rosgenmsg
-Cam
  7 件のコメント
Cam Salzberger
Cam Salzberger 2020 年 3 月 31 日
That's good to know, and hopefully anyone else running into the same issue can find it now. Thanks for posting the answer!
RIKUTO OSHITA
RIKUTO OSHITA 2024 年 5 月 26 日
Hi,Cam,
I encountered the same error when trying to create a custom message for xarm_ros.
What do you think this error cause?
error is follows.
'Index exceeds the number of array elements. Index must not exceed 1.
error: ros.internal.MessageParser/getUpdatedMessageFileContents (行 557)
value = currentLine{2};
If you have a solution, I would appreciate hearing from you.
thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecialized Messages についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by