Reworked index.org: better filenames
Removed few unused functions
This commit is contained in:
		@@ -1,10 +1,12 @@
 | 
			
		||||
function [stewart] = computeJointsPose(stewart)
 | 
			
		||||
% computeJointsPose -
 | 
			
		||||
%
 | 
			
		||||
% Syntax: [stewart] = computeJointsPose(stewart, opts_param)
 | 
			
		||||
% Syntax: [stewart] = computeJointsPose(stewart)
 | 
			
		||||
%
 | 
			
		||||
% Inputs:
 | 
			
		||||
%    - stewart - A structure with the following fields
 | 
			
		||||
%        - Fa   [3x6] - Its i'th column is the position vector of joint ai with respect to {F}
 | 
			
		||||
%        - Mb   [3x6] - Its i'th column is the position vector of joint bi with respect to {M}
 | 
			
		||||
%        - FO_A [3x1] - Position of {A} with respect to {F}
 | 
			
		||||
%        - MO_B [3x1] - Position of {B} with respect to {M}
 | 
			
		||||
%        - FO_M [3x1] - Position of {M} with respect to {F}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,30 +0,0 @@
 | 
			
		||||
function [P, R] = forwardKinematics(stewart, args)
 | 
			
		||||
% forwardKinematics - Computed the pose of {B} with respect to {A} from the length of each strut
 | 
			
		||||
%
 | 
			
		||||
% Syntax: [in_data] = forwardKinematics(stewart)
 | 
			
		||||
%
 | 
			
		||||
% Inputs:
 | 
			
		||||
%    - stewart - A structure with the following fields
 | 
			
		||||
%        - J  [6x6] - The Jacobian Matrix
 | 
			
		||||
%    - args - Can have the following fields:
 | 
			
		||||
%        - L  [6x1] - Length of each strut [m]
 | 
			
		||||
%
 | 
			
		||||
% Outputs:
 | 
			
		||||
%    - P  [3x1] - The estimated position of {B} with respect to {A}
 | 
			
		||||
%    - R  [3x3] - The estimated rotation matrix that gives the orientation of {B} with respect to {A}
 | 
			
		||||
 | 
			
		||||
arguments
 | 
			
		||||
    stewart
 | 
			
		||||
    args.L (6,1) double {mustBeNumeric} = zeros(6,1)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
X = stewart.J\args.L;
 | 
			
		||||
 | 
			
		||||
P = X(1:3);
 | 
			
		||||
 | 
			
		||||
theta = norm(X(4:6));
 | 
			
		||||
s = X(4:6)/theta;
 | 
			
		||||
 | 
			
		||||
R = [s(1)^2*(1-cos(theta)) + cos(theta) ,        s(1)*s(2)*(1-cos(theta)) - s(3)*sin(theta), s(1)*s(3)*(1-cos(theta)) + s(2)*sin(theta);
 | 
			
		||||
     s(2)*s(1)*(1-cos(theta)) + s(3)*sin(theta), s(2)^2*(1-cos(theta)) + cos(theta),         s(2)*s(3)*(1-cos(theta)) - s(1)*sin(theta);
 | 
			
		||||
     s(3)*s(1)*(1-cos(theta)) - s(2)*sin(theta), s(3)*s(2)*(1-cos(theta)) + s(1)*sin(theta), s(3)^2*(1-cos(theta)) + cos(theta)];
 | 
			
		||||
@@ -4,8 +4,6 @@ function [stewart] = generateGeneralConfiguration(stewart, args)
 | 
			
		||||
% Syntax: [stewart] = generateGeneralConfiguration(stewart, args)
 | 
			
		||||
%
 | 
			
		||||
% Inputs:
 | 
			
		||||
%    - stewart - A structure with the following fields
 | 
			
		||||
%        - H   [1x1] - Total height of the platform [m]
 | 
			
		||||
%    - args - Can have the following fields:
 | 
			
		||||
%        - FH  [1x1] - Height of the position of the fixed joints with respect to the frame {F} [m]
 | 
			
		||||
%        - FR  [1x1] - Radius of the position of the fixed joints in the X-Y [m]
 | 
			
		||||
@@ -22,10 +20,10 @@ function [stewart] = generateGeneralConfiguration(stewart, args)
 | 
			
		||||
arguments
 | 
			
		||||
    stewart
 | 
			
		||||
    args.FH  (1,1) double {mustBeNumeric, mustBePositive} = 15e-3
 | 
			
		||||
    args.FR  (1,1) double {mustBeNumeric, mustBePositive} = 90e-3;
 | 
			
		||||
    args.FR  (1,1) double {mustBeNumeric, mustBePositive} = 115e-3;
 | 
			
		||||
    args.FTh (6,1) double {mustBeNumeric} = [-10, 10, 120-10, 120+10, 240-10, 240+10]*(pi/180);
 | 
			
		||||
    args.MH  (1,1) double {mustBeNumeric, mustBePositive} = 15e-3
 | 
			
		||||
    args.MR  (1,1) double {mustBeNumeric, mustBePositive} = 70e-3;
 | 
			
		||||
    args.MR  (1,1) double {mustBeNumeric, mustBePositive} = 90e-3;
 | 
			
		||||
    args.MTh (6,1) double {mustBeNumeric} = [-60+10, 60-10, 60+10, 180-10, 180+10, -60-10]*(pi/180);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
function [X, Y, Z] = getMaxPositions(stewart)
 | 
			
		||||
    Leg = stewart.Leg;
 | 
			
		||||
    J = stewart.Jd;
 | 
			
		||||
    theta = linspace(0, 2*pi, 100);
 | 
			
		||||
    phi = linspace(-pi/2 , pi/2, 100);
 | 
			
		||||
    dmax = zeros(length(theta), length(phi));
 | 
			
		||||
 | 
			
		||||
    for i = 1:length(theta)
 | 
			
		||||
        for j = 1:length(phi)
 | 
			
		||||
            L = J*[cos(phi(j))*cos(theta(i)) cos(phi(j))*sin(theta(i)) sin(phi(j)) 0 0 0]';
 | 
			
		||||
            dmax(i, j) = Leg.stroke/max(abs(L));
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    X = dmax.*cos(repmat(phi,length(theta),1)).*cos(repmat(theta,length(phi),1))';
 | 
			
		||||
    Y = dmax.*cos(repmat(phi,length(theta),1)).*sin(repmat(theta,length(phi),1))';
 | 
			
		||||
    Z = dmax.*sin(repmat(phi,length(theta),1));
 | 
			
		||||
end
 | 
			
		||||
@@ -1,9 +0,0 @@
 | 
			
		||||
function [max_disp] = getMaxPureDisplacement(Leg, J)
 | 
			
		||||
    max_disp = zeros(6, 1);
 | 
			
		||||
    max_disp(1) = Leg.stroke/max(abs(J*[1 0 0 0 0 0]'));
 | 
			
		||||
    max_disp(2) = Leg.stroke/max(abs(J*[0 1 0 0 0 0]'));
 | 
			
		||||
    max_disp(3) = Leg.stroke/max(abs(J*[0 0 1 0 0 0]'));
 | 
			
		||||
    max_disp(4) = Leg.stroke/max(abs(J*[0 0 0 1 0 0]'));
 | 
			
		||||
    max_disp(5) = Leg.stroke/max(abs(J*[0 0 0 0 1 0]'));
 | 
			
		||||
    max_disp(6) = Leg.stroke/max(abs(J*[0 0 0 0 0 1]'));
 | 
			
		||||
end
 | 
			
		||||
@@ -1,5 +0,0 @@
 | 
			
		||||
function [K] = getStiffnessMatrix(k, J)
 | 
			
		||||
% k - leg stiffness
 | 
			
		||||
% J - Jacobian matrix
 | 
			
		||||
    K = k*(J'*J);
 | 
			
		||||
end
 | 
			
		||||
@@ -1,67 +0,0 @@
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:1]]
 | 
			
		||||
function [sys] = identifyPlant(opts_param)
 | 
			
		||||
% identifyPlant:1 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:2]]
 | 
			
		||||
%% Default values for opts
 | 
			
		||||
opts = struct();
 | 
			
		||||
 | 
			
		||||
%% Populate opts with input parameters
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
% identifyPlant:2 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:3]]
 | 
			
		||||
options = linearizeOptions;
 | 
			
		||||
options.SampleTime = 0;
 | 
			
		||||
% identifyPlant:3 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:4]]
 | 
			
		||||
mdl = 'stewart';
 | 
			
		||||
% identifyPlant:4 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:5]]
 | 
			
		||||
%% Inputs
 | 
			
		||||
io(1) = linio([mdl, '/F'],  1, 'input'); % Cartesian forces
 | 
			
		||||
io(2) = linio([mdl, '/Fl'], 1, 'input'); % Leg forces
 | 
			
		||||
io(3) = linio([mdl, '/Fd'], 1, 'input'); % Direct forces
 | 
			
		||||
io(4) = linio([mdl, '/Dw'], 1, 'input'); % Base motion
 | 
			
		||||
 | 
			
		||||
%% Outputs
 | 
			
		||||
io(5) = linio([mdl, '/Dm'],  1, 'output'); % Relative Motion
 | 
			
		||||
io(6) = linio([mdl, '/Dlm'], 1, 'output'); % Displacement of each leg
 | 
			
		||||
io(7) = linio([mdl, '/Flm'], 1, 'output'); % Force sensor in each leg
 | 
			
		||||
io(8) = linio([mdl, '/Xm'],  1, 'output'); % Absolute motion of platform
 | 
			
		||||
% identifyPlant:5 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:6]]
 | 
			
		||||
G = linearize(mdl, io, 0);
 | 
			
		||||
% identifyPlant:6 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:7]]
 | 
			
		||||
G.InputName  = {'Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz', ...
 | 
			
		||||
                'F1', 'F2', 'F3', 'F4', 'F5', 'F6', ...
 | 
			
		||||
                'Fdx', 'Fdy', 'Fdz', 'Mdx', 'Mdy', 'Mdz', ...
 | 
			
		||||
                'Dwx', 'Dwy', 'Dwz', 'Rwx', 'Rwy', 'Rwz'};
 | 
			
		||||
G.OutputName = {'Dxm', 'Dym', 'Dzm', 'Rxm', 'Rym', 'Rzm', ...
 | 
			
		||||
                'D1m', 'D2m', 'D3m', 'D4m', 'D5m', 'D6m', ...
 | 
			
		||||
                'F1m', 'F2m', 'F3m', 'F4m', 'F5m', 'F6m', ...
 | 
			
		||||
                'Dxtm', 'Dytm', 'Dztm', 'Rxtm', 'Rytm', 'Rztm'};
 | 
			
		||||
% identifyPlant:7 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:8]]
 | 
			
		||||
sys.G_cart = G({'Dxm', 'Dym', 'Dzm', 'Rxm', 'Rym', 'Rzm'}, {'Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz'});
 | 
			
		||||
sys.G_forc = minreal(G({'F1m', 'F2m', 'F3m', 'F4m', 'F5m', 'F6m'}, {'F1', 'F2', 'F3', 'F4', 'F5', 'F6'}));
 | 
			
		||||
sys.G_legs = minreal(G({'D1m', 'D2m', 'D3m', 'D4m', 'D5m', 'D6m'}, {'F1', 'F2', 'F3', 'F4', 'F5', 'F6'}));
 | 
			
		||||
sys.G_tran = minreal(G({'Dxtm', 'Dytm', 'Dztm', 'Rxtm', 'Rytm', 'Rztm'}, {'Dwx', 'Dwy', 'Dwz', 'Rwx', 'Rwy', 'Rwz'}));
 | 
			
		||||
sys.G_comp = minreal(G({'Dxm', 'Dym', 'Dzm', 'Rxm', 'Rym', 'Rzm'}, {'Fdx', 'Fdy', 'Fdz', 'Mdx', 'Mdy', 'Mdz'}));
 | 
			
		||||
sys.G_iner = minreal(G({'Dxtm', 'Dytm', 'Dztm', 'Rxtm', 'Rytm', 'Rztm'}, {'Fdx', 'Fdy', 'Fdz', 'Mdx', 'Mdy', 'Mdz'}));
 | 
			
		||||
% sys.G_all  = minreal(G);
 | 
			
		||||
% identifyPlant:8 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:9]]
 | 
			
		||||
end
 | 
			
		||||
% identifyPlant:9 ends here
 | 
			
		||||
@@ -1,171 +0,0 @@
 | 
			
		||||
function [stewart] = initializeHexapod(opts_param)
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'height',  90,    ... % Height of the platform [mm]
 | 
			
		||||
    'density', 10,  ... % Density of the material used for the hexapod [kg/m3]
 | 
			
		||||
    'k_ax',    1e8,   ... % Stiffness of each actuator [N/m]
 | 
			
		||||
    'c_ax',    1000,   ... % Damping of each actuator [N/(m/s)]
 | 
			
		||||
    'stroke',  50e-6, ... % Maximum stroke of each actuator [m]
 | 
			
		||||
    'name',    'stewart' ... % Name of the file
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart = struct();
 | 
			
		||||
 | 
			
		||||
stewart.H = opts.height; % [mm]
 | 
			
		||||
 | 
			
		||||
BP = struct();
 | 
			
		||||
 | 
			
		||||
BP.Rint = 0;   % Internal Radius [mm]
 | 
			
		||||
BP.Rext = 150; % External Radius [mm]
 | 
			
		||||
 | 
			
		||||
BP.H = 10; % Thickness of the Bottom Plate [mm]
 | 
			
		||||
 | 
			
		||||
BP.Rleg  = 100; % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
BP.alpha = 30;  % Angle Offset [deg]
 | 
			
		||||
 | 
			
		||||
BP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
BP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
BP.shape = [BP.Rint BP.H; BP.Rint 0; BP.Rext 0; BP.Rext BP.H]; % [mm]
 | 
			
		||||
 | 
			
		||||
stewart.BP = BP;
 | 
			
		||||
 | 
			
		||||
TP = struct();
 | 
			
		||||
 | 
			
		||||
TP.Rint = 0;   % [mm]
 | 
			
		||||
TP.Rext = 100; % [mm]
 | 
			
		||||
 | 
			
		||||
TP.H = 10; % [mm]
 | 
			
		||||
 | 
			
		||||
TP.Rleg   = 80; % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
TP.alpha  = 10; % Angle [deg]
 | 
			
		||||
TP.dalpha = 0; % Angle Offset from 0 position [deg]
 | 
			
		||||
 | 
			
		||||
TP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
TP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
TP.shape = [TP.Rint TP.H; TP.Rint 0; TP.Rext 0; TP.Rext TP.H];
 | 
			
		||||
 | 
			
		||||
stewart.TP  = TP;
 | 
			
		||||
 | 
			
		||||
Leg = struct();
 | 
			
		||||
 | 
			
		||||
Leg.stroke = opts.stroke; % [m]
 | 
			
		||||
 | 
			
		||||
Leg.k_ax = opts.k_ax; % Stiffness of each leg [N/m]
 | 
			
		||||
Leg.c_ax = opts.c_ax; % Damping of each leg [N/(m/s)]
 | 
			
		||||
 | 
			
		||||
Leg.Rtop = 10; % Radius of the cylinder of the top part of the leg[mm]
 | 
			
		||||
Leg.Rbot = 12; % Radius of the cylinder of the bottom part of the leg [mm]
 | 
			
		||||
 | 
			
		||||
Leg.density = 0.01*opts.density; % Density of the material used for the legs [kg/m3]
 | 
			
		||||
 | 
			
		||||
Leg.color = [0.5 0.5 0.5]; % Color of the top part of the leg [RGB]
 | 
			
		||||
 | 
			
		||||
Leg.R = 1.3*Leg.Rbot; % Size of the sphere at the extremity of the leg [mm]
 | 
			
		||||
 | 
			
		||||
stewart.Leg = Leg;
 | 
			
		||||
 | 
			
		||||
SP = struct();
 | 
			
		||||
 | 
			
		||||
SP.k = 0; % [N*m/deg]
 | 
			
		||||
SP.c = 0; % [N*m/deg]
 | 
			
		||||
 | 
			
		||||
SP.H = 15; % [mm]
 | 
			
		||||
 | 
			
		||||
SP.R = Leg.R; % [mm]
 | 
			
		||||
 | 
			
		||||
SP.section = [0    SP.H-SP.R;
 | 
			
		||||
              0    0;
 | 
			
		||||
              SP.R 0;
 | 
			
		||||
              SP.R SP.H];
 | 
			
		||||
 | 
			
		||||
SP.density = opts.density; % [kg/m^3]
 | 
			
		||||
 | 
			
		||||
SP.color = [0.7 0.7 0.7]; % [RGB]
 | 
			
		||||
 | 
			
		||||
stewart.SP  = SP;
 | 
			
		||||
 | 
			
		||||
stewart = initializeParameters(stewart);
 | 
			
		||||
 | 
			
		||||
save('./mat/stewart.mat', 'stewart')
 | 
			
		||||
 | 
			
		||||
function [stewart] = initializeParameters(stewart)
 | 
			
		||||
 | 
			
		||||
stewart.Aa = zeros(6, 3); % [mm]
 | 
			
		||||
stewart.Ab = zeros(6, 3); % [mm]
 | 
			
		||||
stewart.Bb = zeros(6, 3); % [mm]
 | 
			
		||||
 | 
			
		||||
for i = 1:3
 | 
			
		||||
    stewart.Aa(2*i-1,:) = [stewart.BP.Rleg*cos( pi/180*(120*(i-1) - stewart.BP.alpha) ), ...
 | 
			
		||||
                           stewart.BP.Rleg*sin( pi/180*(120*(i-1) - stewart.BP.alpha) ), ...
 | 
			
		||||
                           stewart.BP.H+stewart.SP.H];
 | 
			
		||||
    stewart.Aa(2*i,:)   = [stewart.BP.Rleg*cos( pi/180*(120*(i-1) + stewart.BP.alpha) ), ...
 | 
			
		||||
                           stewart.BP.Rleg*sin( pi/180*(120*(i-1) + stewart.BP.alpha) ), ...
 | 
			
		||||
                           stewart.BP.H+stewart.SP.H];
 | 
			
		||||
 | 
			
		||||
    stewart.Ab(2*i-1,:) = [stewart.TP.Rleg*cos( pi/180*(120*(i-1) + stewart.TP.dalpha - stewart.TP.alpha) ), ...
 | 
			
		||||
                           stewart.TP.Rleg*sin( pi/180*(120*(i-1) + stewart.TP.dalpha - stewart.TP.alpha) ), ...
 | 
			
		||||
                           stewart.H - stewart.TP.H - stewart.SP.H];
 | 
			
		||||
    stewart.Ab(2*i,:)   = [stewart.TP.Rleg*cos( pi/180*(120*(i-1) + stewart.TP.dalpha + stewart.TP.alpha) ), ...
 | 
			
		||||
                           stewart.TP.Rleg*sin( pi/180*(120*(i-1) + stewart.TP.dalpha + stewart.TP.alpha) ), ...
 | 
			
		||||
                           stewart.H - stewart.TP.H - stewart.SP.H];
 | 
			
		||||
end
 | 
			
		||||
stewart.Bb = stewart.Ab - stewart.H*[0,0,1];
 | 
			
		||||
 | 
			
		||||
leg_length = zeros(6, 1); % [mm]
 | 
			
		||||
leg_vectors = zeros(6, 3);
 | 
			
		||||
 | 
			
		||||
legs = stewart.Ab - stewart.Aa;
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
    leg_length(i) = norm(legs(i,:));
 | 
			
		||||
    leg_vectors(i,:) = legs(i,:) / leg_length(i);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.Leg.lenght = leg_length(1)/1.5;
 | 
			
		||||
stewart.Leg.shape.bot = ...
 | 
			
		||||
    [0                0; ...
 | 
			
		||||
     stewart.Leg.Rbot 0; ...
 | 
			
		||||
     stewart.Leg.Rbot stewart.Leg.lenght; ...
 | 
			
		||||
     stewart.Leg.Rtop stewart.Leg.lenght; ...
 | 
			
		||||
     stewart.Leg.Rtop 0.2*stewart.Leg.lenght; ...
 | 
			
		||||
     0                0.2*stewart.Leg.lenght];
 | 
			
		||||
 | 
			
		||||
stewart.Rm = struct('R', eye(3));
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  sx = cross(leg_vectors(i,:), [1 0 0]);
 | 
			
		||||
  sx = sx/norm(sx);
 | 
			
		||||
 | 
			
		||||
  sy = -cross(sx, leg_vectors(i,:));
 | 
			
		||||
  sy = sy/norm(sy);
 | 
			
		||||
 | 
			
		||||
  sz = leg_vectors(i,:);
 | 
			
		||||
  sz = sz/norm(sz);
 | 
			
		||||
 | 
			
		||||
  stewart.Rm(i).R = [sx', sy', sz'];
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
J = zeros(6);
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  J(i, 1:3) = leg_vectors(i, :);
 | 
			
		||||
  J(i, 4:6) = cross(0.001*(stewart.Ab(i, :)- stewart.H*[0,0,1]), leg_vectors(i, :));
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.J = J;
 | 
			
		||||
stewart.Jinv = inv(J);
 | 
			
		||||
 | 
			
		||||
stewart.K = stewart.Leg.k_ax*stewart.J'*stewart.J;
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
end
 | 
			
		||||
@@ -1,59 +0,0 @@
 | 
			
		||||
function [stewart] = initializeSimscapeData(stewart, opts_param)
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'Jd_pos', [0, 0, 30], ... % Position of the Jacobian for displacement estimation from the top of the mobile platform [mm]
 | 
			
		||||
    'Jf_pos', [0, 0, 30]  ... % Position of the Jacobian for force location from the top of the mobile platform [mm]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
leg_length = zeros(6, 1); % [mm]
 | 
			
		||||
leg_vectors = zeros(6, 3);
 | 
			
		||||
 | 
			
		||||
legs = stewart.Ab - stewart.Aa;
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
    leg_length(i) = norm(legs(i,:));
 | 
			
		||||
    leg_vectors(i,:) = legs(i,:) / leg_length(i);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.Rm = struct('R', eye(3));
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  sx = cross(leg_vectors(i,:), [1 0 0]);
 | 
			
		||||
  sx = sx/norm(sx);
 | 
			
		||||
 | 
			
		||||
  sy = -cross(sx, leg_vectors(i,:));
 | 
			
		||||
  sy = sy/norm(sy);
 | 
			
		||||
 | 
			
		||||
  sz = leg_vectors(i,:);
 | 
			
		||||
  sz = sz/norm(sz);
 | 
			
		||||
 | 
			
		||||
  stewart.Rm(i).R = [sx', sy', sz'];
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Jd = zeros(6);
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  Jd(i, 1:3) = leg_vectors(i, :);
 | 
			
		||||
  Jd(i, 4:6) = cross(0.001*(stewart.Bb(i, :) - opts.Jd_pos), leg_vectors(i, :));
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.Jd = Jd;
 | 
			
		||||
stewart.Jd_inv = inv(Jd);
 | 
			
		||||
 | 
			
		||||
Jf = zeros(6);
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  Jf(i, 1:3) = leg_vectors(i, :);
 | 
			
		||||
  Jf(i, 4:6) = cross(0.001*(stewart.Bb(i, :) - opts.Jf_pos), leg_vectors(i, :));
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.Jf = Jf;
 | 
			
		||||
stewart.Jf_inv = inv(Jf);
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
@@ -1,94 +0,0 @@
 | 
			
		||||
function [stewart] = initializeStewartPlatform(stewart, opts_param)
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'thickness', 10, ... % Thickness of the base and platform [mm]
 | 
			
		||||
    'density',   1000, ... % Density of the material used for the hexapod [kg/m3]
 | 
			
		||||
    'k_ax',      1e8, ... % Stiffness of each actuator [N/m]
 | 
			
		||||
    'c_ax',      1000, ... % Damping of each actuator [N/(m/s)]
 | 
			
		||||
    'stroke',    50e-6  ... % Maximum stroke of each actuator [m]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
BP = struct();
 | 
			
		||||
 | 
			
		||||
BP.Rint = 0;   % Internal Radius [mm]
 | 
			
		||||
BP.Rext = 150; % External Radius [mm]
 | 
			
		||||
 | 
			
		||||
BP.H = opts.thickness; % Thickness of the Bottom Plate [mm]
 | 
			
		||||
 | 
			
		||||
BP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
BP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
BP.shape = [BP.Rint BP.H; BP.Rint 0; BP.Rext 0; BP.Rext BP.H]; % [mm]
 | 
			
		||||
 | 
			
		||||
stewart.BP = BP;
 | 
			
		||||
 | 
			
		||||
TP = struct();
 | 
			
		||||
 | 
			
		||||
TP.Rint = 0;   % [mm]
 | 
			
		||||
TP.Rext = 100; % [mm]
 | 
			
		||||
 | 
			
		||||
TP.H = 10; % [mm]
 | 
			
		||||
 | 
			
		||||
TP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
TP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
TP.shape = [TP.Rint TP.H; TP.Rint 0; TP.Rext 0; TP.Rext TP.H];
 | 
			
		||||
 | 
			
		||||
stewart.TP  = TP;
 | 
			
		||||
 | 
			
		||||
Leg = struct();
 | 
			
		||||
 | 
			
		||||
Leg.stroke = opts.stroke; % [m]
 | 
			
		||||
 | 
			
		||||
Leg.k_ax = opts.k_ax; % Stiffness of each leg [N/m]
 | 
			
		||||
Leg.c_ax = opts.c_ax; % Damping of each leg [N/(m/s)]
 | 
			
		||||
 | 
			
		||||
Leg.Rtop = 10; % Radius of the cylinder of the top part of the leg[mm]
 | 
			
		||||
Leg.Rbot = 12; % Radius of the cylinder of the bottom part of the leg [mm]
 | 
			
		||||
 | 
			
		||||
Leg.density = opts.density; % Density of the material used for the legs [kg/m3]
 | 
			
		||||
 | 
			
		||||
Leg.color = [0.5 0.5 0.5]; % Color of the top part of the leg [RGB]
 | 
			
		||||
 | 
			
		||||
Leg.R = 1.3*Leg.Rbot; % Size of the sphere at the extremity of the leg [mm]
 | 
			
		||||
 | 
			
		||||
legs = stewart.Ab - stewart.Aa;
 | 
			
		||||
Leg.lenght = norm(legs(1,:))/1.5;
 | 
			
		||||
 | 
			
		||||
Leg.shape.bot = ...
 | 
			
		||||
    [0        0; ...
 | 
			
		||||
     Leg.Rbot 0; ...
 | 
			
		||||
     Leg.Rbot Leg.lenght; ...
 | 
			
		||||
     Leg.Rtop Leg.lenght; ...
 | 
			
		||||
     Leg.Rtop 0.2*Leg.lenght; ...
 | 
			
		||||
     0        0.2*Leg.lenght];
 | 
			
		||||
 | 
			
		||||
stewart.Leg = Leg;
 | 
			
		||||
 | 
			
		||||
SP = struct();
 | 
			
		||||
 | 
			
		||||
SP.k = 0; % [N*m/deg]
 | 
			
		||||
SP.c = 0; % [N*m/deg]
 | 
			
		||||
 | 
			
		||||
SP.H = stewart.Aa(1, 3) - BP.H; % [mm]
 | 
			
		||||
 | 
			
		||||
SP.R = Leg.R; % [mm]
 | 
			
		||||
 | 
			
		||||
SP.section = [0    SP.H-SP.R;
 | 
			
		||||
              0    0;
 | 
			
		||||
              SP.R 0;
 | 
			
		||||
              SP.R SP.H];
 | 
			
		||||
 | 
			
		||||
SP.density = opts.density; % [kg/m^3]
 | 
			
		||||
 | 
			
		||||
SP.color = [0.7 0.7 0.7]; % [RGB]
 | 
			
		||||
 | 
			
		||||
stewart.SP  = SP;
 | 
			
		||||
@@ -16,7 +16,7 @@ function [stewart] = initializeStrutDynamics(stewart, args)
 | 
			
		||||
arguments
 | 
			
		||||
    stewart
 | 
			
		||||
    args.Ki (6,1) double {mustBeNumeric, mustBePositive} = 1e6*ones(6,1)
 | 
			
		||||
    args.Ci (6,1) double {mustBeNumeric, mustBePositive} = 1e3*ones(6,1)
 | 
			
		||||
    args.Ci (6,1) double {mustBeNumeric, mustBePositive} = 1e1*ones(6,1)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
stewart.Ki = args.Ki;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user