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

조회 수: 1 (최근 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
  댓글 수: 6
Daniel Levy
Daniel Levy 2020년 3월 31일
Cam,
So, I found the error, there was a +ros folder that got copied into another folder and was creating the duplications of functions within rosgenmsg. It wasn't getting deleted/rehashed because it was saved in the windows environment and I had to restart the computer to get rid of it.
It wasn't actually rosgenmsg that was the problem but the generate custom Jar files and some others that was throwing the error. So your original intuition was correct, I must have bungled something that copied over that +ros folder. When I was using the custom messages example's 'copyfile(examplePackages, userFolder)' command.
Thanks for the help/effort,
-Dan
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!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Publishers and Subscribers에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by