-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcgr_create.m
60 lines (55 loc) · 1.32 KB
/
cgr_create.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
function robot = cgr_create(theta, d, a, alpha, offset, type, base, ub, lb)
% Create a robot structure
%
% Syntax: robot = cgr_create(theta, d, a, alpha, offset, type, base, ub, lb)
%
% Inputs:
% theta - joint angle
% d - joint extension
% a - joint offset
% alpha - joint twist
% offset - joint variable offset
% type - joint type: 'p' for prosmatic joint and 'r' for rotational
% joint
% base - base coordinate (3x1 vector)
% ub - joint upper boundaries - optional
% lb - joint lower boundaries - optional
%
% Outputs:
% robot - robot structure
%
% Examples:
% theta = [0 0];
% alpha = [0 0];
% offset = [0 0];
% d = [0 0];
% a = [0.5 0.5];
% type = ['r','r'];
% base = [0; 0; 0];
%
% planar_2r = cgr_create(theta, d, a, alpha, offset, type, base, ...
% [pi/2; pi/2], [-pi/2; -pi/2;]);
%
global N_DOFS;
if ~iscolumn(base)
error('>> The base coordinate must be a column vactor (3x1)!');
end
if nargin < 8
ub = ones(1, N_DOFS)*inf;
lb = -ones(1, N_DOFS)*inf;
end
r = struct( ...
'base', base, ...
'theta', theta, ...
'd', d, ...
'a', a, ...
'alpha', alpha, ...
'offset', offset, ...
'qc', zeros(N_DOFS, 1), ...
'type', type, ...
'jac', zeros(3, N_DOFS), ...
'T', repmat(zeros(4), 1, 1, N_DOFS), ...
'ub', ub, ...
'lb', lb);
robot = r;
end