Filter löschen
Filter löschen

Robot Path Planning using grid

5 Ansichten (letzte 30 Tage)
Ken
Ken am 22 Okt. 2016
Kommentiert: Walter Roberson am 30 Nov. 2016
Trying to plot a path for a robot from start to goal. I get error in the 2 "for" for x,ystatements. Get error "Subscript indices must either be real positive integers or logicals". Program is:
SearchSolution=[1.0000 0.9705 0.9513 0.9471 0.9557 0.9661 0.9770 0.9883;...
1.0000 0.9629 0.9403 0.9418 0.9629 0.9744 0.9833 0.9916;...
1.0000 0.9581 0.9350 0.9451 1.0000 1.0000 1.0000 1.0000;...
1.0000 0.9534 0.9219 0.9271 1.0000 1.0000 1.0000 1.0000;...
1.0000 0.9487 0.8997 0.8593 0.8349 0.8100 0.8635 0.9331;...
1.0000 0.9574 0.8886 0.8000 0.6815 0.5499 0.7154 0.8711;...
1.0000 1.0000 0.9171 0.7871 0.5575 0 0.5830 0.8391];
OptimalPath=[2,7];
CurrentPos=[2,7];
min=99;
SearchGoal=[7,6];
while not(isequal(CurrentPos,SearchGoal))
for x=SearchSolution(OptimalPath(end,1)-1:OptimalPath(end,1)+1),
for y=SearchSolution(OptimalPath(end,2)-1:OptimalPath(end,2)+1),
[r,c] = find(min == min(SearchSolution(:)));
end
end
CurrentPos=[r,c];
OptimalPath=[OptimalPath;CurrentPos];
end
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Okt. 2016
You are using min as a variable, but you are also trying to use min as a function call. As soon as you assigned a value to min, min stops being a function call, so instead of being a function call on a set of floating point values, it is an attempt to index the variable at those floating point values.
  30 Kommentare
Ken
Ken am 30 Nov. 2016
I am now trying to backtrack i.e. find the solution path from goal to start (as opposed to start to goal done previously). Any help appreciated.
% extract solution path from goal to start. Also check, whether % the search actually found a solution (check for "Inf" values) OptimalPath = ...;
Walter Roberson
Walter Roberson am 30 Nov. 2016
Backtracking is the same search code as going forward except exchanging the two goals. The results can be different because your code picks one of the routes when there are two possibilities of equivalent weight. That can end up leading to very different paths.
If you were doing actual dijkstra planning then there would not be a lot of point in doing backtracking, ad you would simply get one of the routes of exactly equivalent cost. But because your route finding is not optimal, backtracking might happen to find a less expensive route that could then be reversed. Or not: it might find a more expensive route instead.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by