資源簡介
采用柵格對機器人的工作空間進行劃分,再利用優化算法對機器人路徑優化,是采用智能算法求最優路徑的一個經典問題。目前,采用蟻群算法在柵格地圖上進行路徑優化取得比較好的效果,而利用遺傳算法在柵格地圖上進行路徑優化在算法顯得更加難以實現。
利用遺傳算法處理柵格地圖的機器人路徑規劃的難點主要包括:1保證路徑不間斷,2保證路徑不穿過障礙。
用遺傳算法解決優化問題時的步驟是固定的,就是種群初始化,選擇,交叉,變異,適應度計算這樣,那么下面我就說一下遺傳算法求柵格地圖中機器人路徑規劃在每個步驟的問題、難點以及解決辦法。
利用遺傳算法處理柵格地圖的機器人路徑規劃的難點主要包括:1保證路徑不間斷,2保證路徑不穿過障礙。
用遺傳算法解決優化問題時的步驟是固定的,就是種群初始化,選擇,交叉,變異,適應度計算這樣,那么下面我就說一下遺傳算法求柵格地圖中機器人路徑規劃在每個步驟的問題、難點以及解決辦法。

代碼片段和文件信息
%?計算路徑平滑度函數
function?[path_smooth]?=?cal_path_smooth(pop?x)
[n?~]?=?size(pop);
path_smooth?=?zeros(1?n);
for?i?=?1?:?n
????single_pop?=?pop{i?1};
????[~?m]?=?size(single_pop);
????for?j?=?1?:?m?-?2
????????%?點i所在列(從左到右編號1.2.3...)
????????x_now?=?mod(single_pop(1?j)?x)?+?1;?
????????%?點i所在行(從上到下編號行1.2.3...)
????????y_now?=?fix(single_pop(1?j)?/?x)?+?1;
????????%?點i+1所在列、行
????????x_next1?=?mod(single_pop(1?j?+?1)?x)?+?1;
????????y_next1?=?fix(single_pop(1?j?+?1)?/?x)?+?1;
????????%?點i+2所在列、行
????????x_next2?=?mod(single_pop(1?j?+?2)?x)?+?1;
????????y_next2?=?fix(single_pop(1?j?+?2)?/?x)?+?1;
????????%path_smooth(1?i)?=?path_smooth(1?i)?+?abs(atan(abs(x_now?-?x_next1)/abs(y_now?-?y_next1))-atan(abs(x_next2?-?x_next1)/abs(y_next2?-?y_next1)));
????????%a2?=?(x_now?-?x_next1)^2?+?(y_now?-?y_next1)^2;
????????%b2?=?(x_next2?-?x_next1)^2?+?(y_next2?-?y_next1)^2;
????????c2?=?(x_now?-?x_next2)^2?+?(y_now?-?y_next2)^2;
????????%angle?=?(a2?+?c2?-?b2)?/?(2?*?sqrt(a2)?*??sqrt(c2));
????????if?c2?8?&&?c2?>?4
????????????path_smooth(1?i)?=?path_smooth(1?i)?+?5;
????????elseif?c2?<=?4?&&?c2?>?1
????????????path_smooth(1?i)?=?path_smooth(1?i)?+?30;
????????elseif????c2?<=?1
????????????path_smooth(1?i)?=?path_smooth(1?i)?+?5000;
????????end
????end
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1361??2019-01-10?14:20??GAforPathPlaning\cal_path_smooth.m
?????文件????????749??2018-12-17?20:33??GAforPathPlaning\cal_path_value.m
?????文件???????1014??2019-01-10?16:10??GAforPathPlaning\crossover.m
?????文件????????335??2019-01-10?16:08??GAforPathPlaning\DrawMap.m
?????文件???????3632??2018-12-17?21:20??GAforPathPlaning\generate_continuous_path.m
?????文件???????4401??2019-01-10?14:18??GAforPathPlaning\main.m
?????文件???????1257??2018-12-17?21:34??GAforPathPlaning\mutation.m
?????文件????????566??2018-12-17?15:23??GAforPathPlaning\selection.m
?????目錄??????????0??2019-01-12?10:53??GAforPathPlaning
-----------?---------??----------?-----??----
????????????????13315????????????????????9
評論
共有 條評論