Commit db895687 authored by Larkin Heintzman's avatar Larkin Heintzman

Upload New File

parent c227b249
Pipeline #24 canceled with stages
function [x_pts, y_pts] = generateObstacles(env, threshold, dx, init_conf, final_conf, safe_radius)
xdim = env(2) - env(1);
ydim = env(4) - env(3);
im = zeros(xdim/dx, ydim/dx);
im = perlin_noise(im);
obs_points = im;
obs_points = obs_points + abs(min(min(obs_points))); % make it positive
obs_points = obs_points/max(max(obs_points)); % make it normal
obs_points = smoothdata(obs_points,1,'movmean',10);
obs_points = smoothdata(obs_points,2,'movmean',10);
[x_pts, y_pts] = find(obs_points <= threshold);
x_pts = x_pts.*dx;
y_pts = y_pts.*dx;
% iterate through to get rid of points interferring with starting and
% ending points
% but do it for all points in initial and final configurations
for i=1:size(init_conf,1)
init_d = sqrt((init_conf(i,1) - x_pts).^2 + (init_conf(i,2) - y_pts).^2);
x_pts = x_pts(init_d >= safe_radius);
y_pts = y_pts(init_d >= safe_radius);
end
for i=1:size(final_conf,1)
final_d = sqrt((final_conf(i,1) - x_pts).^2 + (final_conf(i,2) - y_pts).^2);
x_pts = x_pts(final_d >= safe_radius);
y_pts = y_pts(final_d >= safe_radius);
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment