-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflymod_BodyOnly.m
More file actions
executable file
·95 lines (75 loc) · 2.77 KB
/
flymod_BodyOnly.m
File metadata and controls
executable file
·95 lines (75 loc) · 2.77 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function [x,y,z] = flymod_BodyOnly(p,params,PAR)
% function [x,y,z] = flymod_BodyOnly(p,params,PAR)
%
% x,y,z are [1 1] cells that contain the body/head points,
%
% Twist notation is taken from Murray Book "Robotic Manipulation"
%
% p is the fly state denoted as
% p = [ xi - global screw motion of the fly model xi = [v ; w]
%
% params is a structure that has all of the model parameters that encode
% the shape.
persistent xorg yorg zorg
x = cell(1,1);
y = x;
z = x;
p = p(:);
% the posture transformations
bodyscrew = p(1:6);
Gbody = screw2homo(bodyscrew);
Tbody = Gbody(1:3,4);
Rbody = Gbody(1:3,1:3);
if isempty(xorg)
%If these points don't exist from a previous function call, create them
%=========================================================
%BODY
%=========================================================
%Instead of using the bent fly model from W. Dickson, let's just assume
%that the body axis is a straight line. Look inside 'flybodymod' for
%manipulation.
[xbody,ybody,zbody,s,th,X,Frenet] = flybodymod(params.bodyctr,params.bodyrad,params.bodylen,PAR);
%=========================================================
%HEAD
%=========================================================
%Transformation to the neck;
%headtilt = -18*(pi/180);
headtilt = 0;
Ry = [cos(headtilt) 0 sin(headtilt)
0 1 0
-sin(headtilt) 0 cos(headtilt)];
Rneck = Ry*[Frenet.T(end,:)' Frenet.N(end,:)' Frenet.B(end,:)'];
%Tneck = X(end,:) + [-0.020 0 0]; %Shift head back a little
Tneck = X(end,:);
%Transformation to put reference frame at bottom of head and shift
% Thead = [params.headlen/2 0 -0.1];
Thead = [params.headlen/2 0 0];
[xhead,yhead,zhead] = flyheadmod(params.headrad,params.headlen,PAR);
%Translate reference frame at bottom of head
[xhead,yhead,zhead] = xform_surf(xhead,yhead,zhead,Thead);
%Transform to neck of body
[xhead,yhead,zhead] = xform_surf(xhead,yhead,zhead,Tneck,Rneck);
%Put head and body points together.
x{1} = [xbody ; xhead];
y{1} = [ybody ; yhead];
z{1} = [zbody ; zhead];
xorg = x;
yorg = y;
zorg = z;
else
% these points already exist, so just assign them to the appropriate
% variables
x = xorg;
y = yorg;
z = zorg;
end
%=========================================================
%=========================================================
% global transformation for all body parts (and scaling!)
for k = 1:length(x)
if k == 1 %body
[x{k},y{k},z{k}] = xform_surf(x{k},y{k},z{k},Tbody,Rbody,params.bodyscale);
else %wings
[x{k},y{k},z{k}] = xform_surf(x{k},y{k},z{k},Tbody,Rbody);
end
end