-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddRobotProfile.m
72 lines (66 loc) · 2.19 KB
/
AddRobotProfile.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
67
68
69
70
71
72
% Not complete Yet!
%
% Robot= Robot that made from InitializRobot
% Exampel1 Robot=AddRobotProfile(Robot)
% Exampel2 Robot=AddRobotProfile(Robot,'C:\UT2004\System')
%
% Amirkabir University of Tehran (Tehran Polytechnic)
% Summer 2011
% http://www.mechatronics3d.com
function Robot=AddRobotProfile(Robot,path)
if nargin > 2
error('Too many input arguments');
elseif nargin == 1
path='C:\UT2004';
elseif nargin < 0
error('Too few input arguments');
end
% clc
% path='C:\USARBot.ini';
% Robot.Class='TeleMax';
path=[path '\System\USARBot.ini'];
fid=fopen(path);
RobotClass=['[USARBot.' Robot.Class ']'];
Line=1;
while isempty(strfind(Line ,RobotClass))&(isempty(Line)|(Line~=-1))%#ok<AND2,OR2>
Line=fgetl(fid);
end
% fprintf([Line '\n']);
if (Line==-1)
error('Can`t Find the Robot !!!');
end
Line=fgetl(fid);
Robot.NMisPkg=0;
Robot.MisPkg={};
Robot.NJoints=0;
Robot.Joints={};
Robot.NSensor=0;
Robot.Sensor={};
Robot.NEffect=0;
Robot.Effect={};
Robot.NHLight=0;
Robot.HLight={};
while isempty(strfind(Line ,'[USARBot.'))&(isempty(Line)|(Line~=-1)) %#ok<AND2,OR2>
if strfind(Line ,'JointParts=')
Robot.NJoints=Robot.NJoints+1;
index=strfind(Line ,'"');
Robot.Joints{Robot.NJoints}=Line(index(1)+1:index(2)-1);
elseif strfind(Line ,'Sensors')
Robot.NSensor=Robot.NSensor+1;
index=strfind(Line ,'"');
Robot.Sensor{Robot.NSensor}=Line(index(1)+1:index(2)-1);
elseif strfind(Line ,'MisPkgs=')
Robot.NMisPkg=Robot.NMisPkg+1;
index=strfind(Line ,'"');
Robot.MisPkg{Robot.NMisPkg}=Line(index(1)+1:index(2)-1);
elseif strfind(Line ,'Effecters=')
Robot.NEffect=Robot.NEffect+1;
index=strfind(Line ,'"');
Robot.Effect{Robot.NEffect}=Line(index(1)+1:index(2)-1);
elseif strfind(Line ,'HeadLights=')
Robot.NHLight=Robot.NHLight+1;
index=strfind(Line ,'"');
Robot.HLight{Robot.NHLight}=Line(index(1)+1:index(2)-1);
end
Line=fgetl(fid);
end