-
Notifications
You must be signed in to change notification settings - Fork 0
/
DriveAckerman.m
66 lines (62 loc) · 2.18 KB
/
DriveAckerman.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
% DriveAckerman(Robot,Speed,FrontSteer,Normalized,Flip,RearSteer,Light)
% Drive Robot By Ackerman method
% Amirkabir University of Tehran (Tehran Polytechnic)
% Summer 2011
% http://www.mechatronics3d.com
function DriveAckerman(Robot,Speed,FrontSteer,Normalized,Flip,RearSteer,Light)
if nargin > 7
error('Too many input arguments');
elseif nargin < 1
error('Too few input arguments');
elseif nargin == 7
Normalized=CheckInput(Normalized);
Light=CheckInput(Light);
Flip=CheckInput(Flip);
Msg=['DRIVE {Speed ' num2str(Speed) '} ' ...
'{FrontSteer ' num2str(FrontSteer) '} '...
'{RearSteer ' num2str(RearSteer) '} '...
'{Normalized ' Normalized '} '...
'{Light ' Light '} {Flip ' Flip '}'];
elseif nargin == 6
Normalized=CheckInput(Normalized);
Flip=CheckInput(Flip);
Msg=['DRIVE {Speed ' num2str(Speed) '} ' ...
'{FrontSteer ' num2str(FrontSteer) '} '...
'{RearSteer ' num2str(RearSteer) '} '...
'{Normalized ' Normalized '} '...
'{Flip ' Flip '}'];
elseif nargin == 5
Normalized=CheckInput(Normalized);
Flip=CheckInput(Flip);
Msg=['DRIVE {Speed ' num2str(Speed) '} ' ...
'{FrontSteer ' num2str(FrontSteer) '} '...
'{Normalized ' Normalized '} '...
'{Flip ' Flip '}'];
elseif nargin == 4
Normalized=CheckInput(Normalized);
Msg=['DRIVE {Speed ' num2str(Speed) '} ' ...
'{FrontSteer ' num2str(FrontSteer) '} '...
'{Normalized ' Normalized '}'];
elseif nargin == 3
Msg=['DRIVE {Speed ' num2str(Speed) '} ' ...
'{FrontSteer ' num2str(FrontSteer) '}'];
elseif nargin == 2
Msg=['DRIVE {Speed ' num2str(Speed) '}'];
elseif nargin == 1
Msg='DRIVE {Speed 0.0}';
end
fprintf(Robot.Connection,Msg);
function Out=CheckInput(In)
if ischar(In)
if ~(strcmp(In,'True')||strcmp(In,'False'))
Out='False';
end
else
if In
Out='True';
else
Out='False';
end
end
end
end