Robotics toolbox Custom map compile error
Show older comments
Hey there,
I am using MATLAB 2018a and i have robotics toolbox installed.
I am using it for path planning, the "exampleMaps.mat" map that is already there works just fine but when I make a custom maps it doesn't work.
It shows compile error:
""Undefined function or variable 'simpleMap'.
Error in Untitled12 (line 4)
map = robotics.OccupancyGrid(simpleMap,2);""
this error doesn't come when when i use "exampleMaps.mat"
this is my code
function b=map()
filePath = fullfile(fileparts(which('PathPlanningExample')),'data','exampleMaps.mat');
load(filePath)
map = robotics.OccupancyGrid(simpleMap,2);
prmSimple = robotics.PRM(map,50);
s=[2 2];
e=[10 2];
path=findpath(prmSimple,s,e)
show(prmSimple)
end
For your information let me tell you that my map is in same directory as "exampleMaps.mat"
Answers (1)
Cam Salzberger
on 8 Feb 2019
1 vote
Hello Divyanshu,
Does your MAT file have a variable in it called "simpleMap"? Because that is what the code is looking for - a variable called simpleMap that has been loaded into the function workspace. If your MAT file uses a different variable name for the map data, simply change "simpleMap" to reference that instead.
As an aside, I prefer to use the load('myMatFile.mat', varName1, varName2) syntax when calling load. That makes it obvious where the variables are coming from.
-Cam
Categories
Find more on Mapping and Localization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!