Skip to content

Commit

Permalink
#1 minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matteodv99tn committed Jan 2, 2023
1 parent fd2f44a commit 765a177
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Classes/Laserscan.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function plot(obj)

plot(obj.cartesian(:, 1), obj.cartesian(:, 2), '.k', ...
'DisplayName', 'point cloud');
axis equal;
hold on;
grid on;

for i = 1:size(obj.features, 2)
feat = obj.features(i, 1:2);
Expand Down Expand Up @@ -212,6 +215,13 @@ function plot(obj)
is_line = false;
return
end

P_curr = obj.cartesian(k, :);
P_pred = predict_point(line, obj.polar(k, 2));
if point_point_distance(P_curr, P_pred) > 0.12
is_line = false;
return
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion Functions/point_point_distance.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function d = point_point_distance(p1, p2)

d = sqrt(sumsqr(p1 - p2));
dx = p1(1) - p2(1);
dy = p1(2) - p2(2);
d = sqrt(dx.^2 + dy.^2);

end
3 changes: 2 additions & 1 deletion Functions/predict_point.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
b = line(2);
c = line(3);
den = a*cos(theta) + b*sin(theta);
t = - c / den;

pred_point = -c .* [cos(theta); sin(theta)] / den;
pred_point = t * [cos(theta); sin(theta)];

end

0 comments on commit 765a177

Please sign in to comment.