Skip to content

Commit

Permalink
Use colnorm, part of rvctools/common rather than norm2.
Browse files Browse the repository at this point in the history
  • Loading branch information
petercorke committed Feb 22, 2012
1 parent ec03bbe commit 2c3a11d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Bug2.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function navigate_init(bug, robot)
if bug.step == 1
% Step 1. Move along the M-line toward the goal

if norm2(bug.goal - robot) == 0 % are we there yet?
if colnorm(bug.goal - robot) == 0 % are we there yet?
return
end

Expand All @@ -137,7 +137,7 @@ function navigate_init(bug, robot)
if bug.step == 2
% Step 2. Move around the obstacle until we reach a point
% on the M-line closer than when we started.
if norm2(bug.goal-robot) == 0 % are we there yet?
if colnorm(bug.goal-robot) == 0 % are we there yet?
return
end

Expand All @@ -154,7 +154,7 @@ function navigate_init(bug, robot)
if abs( [robot' 1]*bug.mline') <= 0.5
bug.message('(%d,%d) moving along the M-line', n);
% are closer than when we encountered the obstacle?
if norm2(robot-bug.goal) < norm2(bug.H(bug.j,:)'-bug.goal)
if colnorm(robot-bug.goal) < colnorm(bug.H(bug.j,:)'-bug.goal)
% back to moving along the M-line
bug.j = bug.j + 1;
bug.step = 1;
Expand Down
2 changes: 1 addition & 1 deletion RandomPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function setgoal(driver)
steer = d_heading;

% if nearly at goal point, choose the next one
d = norm2(driver.veh.x(1:2) - driver.goal);
d = colnorm(driver.veh.x(1:2) - driver.goal);
if d < driver.closeenough
driver.setgoal();
elseif d > driver.d_prev
Expand Down
14 changes: 12 additions & 2 deletions Vehicle.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function add_driver(veh, driver)
veh.x(1) = veh.x(1) + u(1)*veh.T*cos(veh.x(3));
veh.x(2) = veh.x(2) + u(1)*veh.T*sin(veh.x(3));
veh.x(3) = veh.x(3) + u(1)*veh.T/veh.L * u(2);
odo = [norm2(veh.x(1:2)-xp(1:2)) veh.x(3)-xp(3)];
odo = [colnorm(veh.x(1:2)-xp(1:2)) veh.x(3)-xp(3)];
veh.odometry = odo;

veh.x_hist = [veh.x_hist; veh.x']; % maintain history
Expand Down Expand Up @@ -258,7 +258,7 @@ function add_driver(veh, driver)

function odo = gstep(veh, varargin)
odo = veh.step(varargin{:});
veh.showrobot();
veh.plot();
drawnow
end

Expand Down Expand Up @@ -313,7 +313,11 @@ function add_driver(veh, driver)
end
veh.visualize();
for i=1:nsteps
if nargout > 0
veh.step();
else
veh.gstep();
end
end
p = veh.x_hist;
end
Expand Down Expand Up @@ -415,4 +419,10 @@ function display(nav)

end % method

methods(Static)
function plot_vehicle(x,y,th)
disp('static plot method');
end
end

end % classdef
2 changes: 1 addition & 1 deletion makemap.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
drawnow
hold off

r = round(norm2(point1-point2));
r = round(colnorm(point1-point2));
c = kcircle(r);

world_prev = world;
Expand Down

0 comments on commit 2c3a11d

Please sign in to comment.