-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrawRobot.m
79 lines (65 loc) · 2.1 KB
/
DrawRobot.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
73
74
75
76
77
function DrawRobot(robot, listofbody, option)
%
%
% function DrawRobot(robot, flag)
%
% Draw the robot in 3D
%
% Inputs:
% robot : data structure of the robot
% option : 1 --> draw the joint and the frame
% 2 --> draw the joint
% otherwise : don't draw the joint
%
if isempty(listofbody),
return;
end
[n,m]=size(listofbody);
fflag=0;
s=0.05;
for i=1:n,
id_body=GetBodyFromName(robot, listofbody(i,:));
id_father=GetBodyFromName(robot, robot.body(id_body).father(1,:));
p0=robot.body(id_father).Tabs(1:3,4);
% Draw the chest
if ((isempty(robot.body(id_father).father) ==1) && (fflag ==0)),
DrawFrame(robot.body(id_father).Tabs,s, 1.0);
p=p0+robot.body(id_father).Tabs(1:3,3)*0.2;
xx(1)=p0(1);yy(1)=p0(2);zz(1)=p0(3);
xx(2)=p(1);yy(2)=p(2);zz(2)=p(3);
plot3(xx, yy, zz,'b', 'LineWidth',2.0);
fflag=1;
end
% Draw the joint
switch option,
case 1,
DrawRJoint(robot.body(id_body).Tabs, robot.body(id_body).a, 1, s);
case 2,
DrawRJoint(robot.body(id_body).Tabs, robot.body(id_body).a, 0, s);
otherwise,
end
% Draw the segment associated with the body
p=robot.body(id_body).Tabs(1:3,4);
xx(1)=p0(1);yy(1)=p0(2);zz(1)=p0(3);
xx(2)=p(1);yy(2)=p(2);zz(2)=p(3);
plot3(xx, yy, zz,'b', 'LineWidth',2.0);
if strcmp(robot.body(id_body).name, 'R_FOOT'),
T=robot.body(id_body).Tabs;
p0=T(1:3,4);
xx(1)=p0(1);yy(1)=p0(2);zz(1)=p0(3);
xx(2)=robot.r_zmp(1);yy(2)=robot.r_zmp(2);zz(2)=robot.r_zmp(3);
plot3(xx, yy, zz,'b', 'LineWidth',2.0);
T(1:3,4)=robot.r_zmp;
DrawFoot(T);
end
if strcmp(robot.body(id_body).name, 'L_FOOT'),
T=robot.body(id_body).Tabs;
p0=T(1:3,4);
xx(1)=p0(1);yy(1)=p0(2);zz(1)=p0(3);
xx(2)=robot.l_zmp(1);yy(2)=robot.l_zmp(2);zz(2)=robot.l_zmp(3);
plot3(xx, yy, zz,'b', 'LineWidth',2.0);
T(1:3,4)=robot.l_zmp;
DrawFoot(T);
end
DrawRobot(robot, robot.body(id_body).child, option);
end