Educational materials
function [VelX, VelY] = computeVelocity (DutyX, DutyY)
% usage:    [XV, YV] = computeVelocity (DutyX, DutyY)
% purpose:   Compute the new velocity for the x (XV) and y (YV) 
%           aspects based on the x motor duty cycle (-100 to 100)  
%           and y motor duty cycle (-100 to 100).  

% Compute the velocity from Euler's on the noted acceleration

global gCurrentXVel;
global gCurrentYVel;

% Check X duty motor with a warning
if DutyX > 100
    disp('Warning: Duty cycle on the X motor is more than 100 percent');
elseif DutyX < -100
    disp('Warning: Duty cycle on the X motor is less than -100 percent');
end
        
if DutyY > 100
    disp('Warning: Duty cycle on the Y motor is more than 100 percent');
elseif DutyY < -100
    disp('Warning: Duty cycle on the Y motor is less than -100 percent');
end

% Compute acceleration (1 m/s^2)
xAccel = DutyX * 3.0 * 0.1;
yAccel = DutyY * 5.0 * 0.1;

gCurrentXVel = gCurrentXVel + xAccel;
gCurrentYVel = gCurrentYVel + yAccel;

VelX = gCurrentXVel;
VelY = gCurrentYVel;

end
r1 - 20 Aug 2008 - 17:33:35 - AaronStriegel
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Syndicate this site RSSATOM