forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangularvel2quatdotMatrix.m
42 lines (37 loc) · 1.06 KB
/
angularvel2quatdotMatrix.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
function [M, dM] = angularvel2quatdotMatrix(q)
% Computes matrix that maps angular velocity in world-fixed frame to
% quaternion derivative
%
% From Schwab, Arend L. "Quaternions, finite rotation and euler
% parameters." (self-published)
% http://bicycle.tudelft.nl/schwab/Publications/quaternion.pdf
% @param q is a quaternion
compute_gradient = nargout > 1;
% NOTE: enabling normalization causes testForwardKinV to fail.
% if compute_gradient
% [qtilde, dqtildedq] = normalizeVec(q);
% else
% qtilde = normalizeVec(q);
% end
qtilde = q;
qs = qtilde(1);
qv = qtilde(2 : 4);
M = 1/2 * ...
[-qv';
qs * eye(3) - vectorToSkewSymmetric(qv)];
if compute_gradient
dM = [...
0 -0.5 0 0;
0.5 0 0 0;
0 0 0 -0.5;
0 0 0.5 0;
0 0 -0.5 0;
0 0 0 0.5;
0.5 0 0 0;
0 -0.5 0 0;
0 0 0 -0.5;
0 0 -0.5 0;
0 0.5 0 0;
0.5 0 0 0]; % * dqtildedq;
end
end