Update study: cubic configuration, renew the function for generation
This commit is contained in:
		
							
								
								
									
										59
									
								
								src/computeGeometricalProperties.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								src/computeGeometricalProperties.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
function [stewart] = computeGeometricalProperties(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
 | 
			
		||||
@@ -53,7 +53,7 @@ G.OutputName = {'Dxm', 'Dym', 'Dzm', 'Rxm', 'Rym', 'Rzm', ...
 | 
			
		||||
% identifyPlant:7 ends here
 | 
			
		||||
 | 
			
		||||
% [[file:~/MEGA/These/Matlab/Simscape/stewart-simscape/identification.org::*identifyPlant][identifyPlant:8]]
 | 
			
		||||
sys.G_cart = minreal(G({'Dxm', 'Dym', 'Dzm', 'Rxm', 'Rym', 'Rzm'}, {'Fx', 'Fy', 'Fz', 'Mx', 'My', 'Mz'}));
 | 
			
		||||
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'}));
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										89
									
								
								src/initializeCubicConfiguration.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								src/initializeCubicConfiguration.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
			
		||||
function [stewart] = initializeCubicConfiguration(opts_param)
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'H_tot', 90,  ... % Total height of the Hexapod [mm]
 | 
			
		||||
    'L',     110, ... % Size of the Cube [mm]
 | 
			
		||||
    'H',     40,  ... % Height between base joints and platform joints [mm]
 | 
			
		||||
    'H0',    75   ... % Height between the corner of the cube and the plane containing the base joints [mm]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
points = [0, 0, 0; ...
 | 
			
		||||
          0, 0, 1; ...
 | 
			
		||||
          0, 1, 0; ...
 | 
			
		||||
          0, 1, 1; ...
 | 
			
		||||
          1, 0, 0; ...
 | 
			
		||||
          1, 0, 1; ...
 | 
			
		||||
          1, 1, 0; ...
 | 
			
		||||
          1, 1, 1];
 | 
			
		||||
points = opts.L*points;
 | 
			
		||||
 | 
			
		||||
sx = cross([1, 1, 1], [1 0 0]);
 | 
			
		||||
sx = sx/norm(sx);
 | 
			
		||||
 | 
			
		||||
sy = -cross(sx, [1, 1, 1]);
 | 
			
		||||
sy = sy/norm(sy);
 | 
			
		||||
 | 
			
		||||
sz = [1, 1, 1];
 | 
			
		||||
sz = sz/norm(sz);
 | 
			
		||||
 | 
			
		||||
R = [sx', sy', sz']';
 | 
			
		||||
 | 
			
		||||
cube = zeros(size(points));
 | 
			
		||||
for i = 1:size(points, 1)
 | 
			
		||||
  cube(i, :) = R * points(i, :)';
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
leg_indices = [3, 4; ...
 | 
			
		||||
               2, 4; ...
 | 
			
		||||
               2, 6; ...
 | 
			
		||||
               5, 6; ...
 | 
			
		||||
               5, 7; ...
 | 
			
		||||
               3, 7];
 | 
			
		||||
 | 
			
		||||
legs = zeros(6, 3);
 | 
			
		||||
legs_start = zeros(6, 3);
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  legs(i, :) = cube(leg_indices(i, 2), :) - cube(leg_indices(i, 1), :);
 | 
			
		||||
  legs_start(i, :) = cube(leg_indices(i, 1), :);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Hmax = cube(4, 3) - cube(2, 3);
 | 
			
		||||
if opts.H0 < cube(2, 3)
 | 
			
		||||
  error(sprintf('H0 is not high enought. Minimum H0 = %.1f', cube(2, 3)));
 | 
			
		||||
else if opts.H0 + opts.H > cube(4, 3)
 | 
			
		||||
  error(sprintf('H0+H is too high. Maximum H0+H = %.1f', cube(4, 3)));
 | 
			
		||||
  error('H0+H is too high');
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Aa = zeros(6, 3);
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  t = (opts.H0-legs_start(i, 3))/(legs(i, 3));
 | 
			
		||||
  Aa(i, :) = legs_start(i, :) + t*legs(i, :);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Ab = zeros(6, 3);
 | 
			
		||||
for i = 1:6
 | 
			
		||||
  t = (opts.H0+opts.H-legs_start(i, 3))/(legs(i, 3));
 | 
			
		||||
  Ab(i, :) = legs_start(i, :) + t*legs(i, :);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Bb = zeros(6, 3);
 | 
			
		||||
Bb = Ab - (opts.H0 + opts.H_tot/2 + opts.H/2)*[0, 0, 1];
 | 
			
		||||
 | 
			
		||||
h = opts.H0 + opts.H/2 - opts.H_tot/2;
 | 
			
		||||
Aa = Aa - h*[0, 0, 1];
 | 
			
		||||
Ab = Ab - h*[0, 0, 1];
 | 
			
		||||
 | 
			
		||||
stewart = struct();
 | 
			
		||||
  stewart.Aa = Aa;
 | 
			
		||||
  stewart.Ab = Ab;
 | 
			
		||||
  stewart.Bb = Bb;
 | 
			
		||||
  stewart.H_tot = opts.H_tot;
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										47
									
								
								src/initializeGeneralConfiguration.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								src/initializeGeneralConfiguration.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
function [stewart] = initializeGeneralConfiguration(opts_param)
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'H_tot',   90, ... % Height of the platform [mm]
 | 
			
		||||
    'H_joint', 15, ... % Height of the joints [mm]
 | 
			
		||||
    'H_plate', 10, ... % Thickness of the fixed and mobile platforms [mm]
 | 
			
		||||
    'R_bot',  100, ... % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
    'R_top',  80,  ... % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
    'a_bot',  10,  ... % Angle Offset [deg]
 | 
			
		||||
    'a_top',  40,  ... % Angle Offset [deg]
 | 
			
		||||
    'da_top', 0    ... % Angle Offset from 0 position [deg]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Aa = zeros(6, 3); % [mm]
 | 
			
		||||
Ab = zeros(6, 3); % [mm]
 | 
			
		||||
Bb = zeros(6, 3); % [mm]
 | 
			
		||||
 | 
			
		||||
for i = 1:3
 | 
			
		||||
    Aa(2*i-1,:) = [opts.R_bot*cos( pi/180*(120*(i-1) - opts.a_bot) ), ...
 | 
			
		||||
                   opts.R_bot*sin( pi/180*(120*(i-1) - opts.a_bot) ), ...
 | 
			
		||||
                   opts.H_plate+opts.H_joint];
 | 
			
		||||
    Aa(2*i,:)   = [opts.R_bot*cos( pi/180*(120*(i-1) + opts.a_bot) ), ...
 | 
			
		||||
                   opts.R_bot*sin( pi/180*(120*(i-1) + opts.a_bot) ), ...
 | 
			
		||||
                   opts.H_plate+opts.H_joint];
 | 
			
		||||
 | 
			
		||||
    Ab(2*i-1,:) = [opts.R_top*cos( pi/180*(120*(i-1) + opts.da_top - opts.a_top) ), ...
 | 
			
		||||
                   opts.R_top*sin( pi/180*(120*(i-1) + opts.da_top - opts.a_top) ), ...
 | 
			
		||||
                   opts.H_tot - opts.H_plate - opts.H_joint];
 | 
			
		||||
    Ab(2*i,:)   = [opts.R_top*cos( pi/180*(120*(i-1) + opts.da_top + opts.a_top) ), ...
 | 
			
		||||
                   opts.R_top*sin( pi/180*(120*(i-1) + opts.da_top + opts.a_top) ), ...
 | 
			
		||||
                   opts.H_tot - opts.H_plate - opts.H_joint];
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
Bb = Ab - opts.H_tot*[0,0,1];
 | 
			
		||||
 | 
			
		||||
stewart = struct();
 | 
			
		||||
  stewart.Aa = Aa;
 | 
			
		||||
  stewart.Ab = Ab;
 | 
			
		||||
  stewart.Bb = Bb;
 | 
			
		||||
  stewart.H_tot = opts.H_tot;
 | 
			
		||||
end
 | 
			
		||||
@@ -1,228 +1,86 @@
 | 
			
		||||
% Function description and arguments
 | 
			
		||||
% The =initializeHexapod= function takes one structure that contains configurations for the hexapod and returns one structure representing the hexapod.
 | 
			
		||||
 | 
			
		||||
function [stewart] = initializeHexapod(opts_param)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Default values for opts.
 | 
			
		||||
 | 
			
		||||
opts = struct(...
 | 
			
		||||
    'height',  90,    ... % Height of the platform [mm]
 | 
			
		||||
    'density', 8000,  ... % Density of the material used for the hexapod [kg/m3]
 | 
			
		||||
    '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
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Populate opts with input parameters
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        opts.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
% Initialization of the stewart structure
 | 
			
		||||
% We initialize the Stewart structure
 | 
			
		||||
 | 
			
		||||
stewart = struct();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% And we defined its total height.
 | 
			
		||||
 | 
			
		||||
stewart.H = opts.height; % [mm]
 | 
			
		||||
 | 
			
		||||
% Bottom Plate
 | 
			
		||||
% #+name: fig:stewart_bottom_plate
 | 
			
		||||
% #+caption: Schematic of the bottom plates with all the parameters
 | 
			
		||||
% [[file:./figs/stewart_bottom_plate.png]]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The bottom plate structure is initialized.
 | 
			
		||||
 | 
			
		||||
BP = struct();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We defined its internal radius (if there is a hole in the bottom plate) and its outer radius.
 | 
			
		||||
 | 
			
		||||
BP.Rint = 0;   % Internal Radius [mm]
 | 
			
		||||
BP.Rext = 150; % External Radius [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We define its thickness.
 | 
			
		||||
 | 
			
		||||
BP.H = 10; % Thickness of the Bottom Plate [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% At which radius legs will be fixed and with that angle offset.
 | 
			
		||||
 | 
			
		||||
BP.Rleg  = 100; % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
BP.alpha = 10;  % Angle Offset [deg]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We defined the density of the material of the bottom plate.
 | 
			
		||||
BP.alpha = 30;  % Angle Offset [deg]
 | 
			
		||||
 | 
			
		||||
BP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% And its color.
 | 
			
		||||
 | 
			
		||||
BP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Then the profile of the bottom plate is computed and will be used by Simscape
 | 
			
		||||
 | 
			
		||||
BP.shape = [BP.Rint BP.H; BP.Rint 0; BP.Rext 0; BP.Rext BP.H]; % [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The structure is added to the stewart structure
 | 
			
		||||
 | 
			
		||||
stewart.BP = BP;
 | 
			
		||||
 | 
			
		||||
% Top Plate
 | 
			
		||||
% The top plate structure is initialized.
 | 
			
		||||
 | 
			
		||||
TP = struct();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We defined the internal and external radius of the top plate.
 | 
			
		||||
 | 
			
		||||
TP.Rint = 0;   % [mm]
 | 
			
		||||
TP.Rext = 100; % [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The thickness of the top plate.
 | 
			
		||||
 | 
			
		||||
TP.H = 10; % [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% At which radius and angle are fixed the legs.
 | 
			
		||||
 | 
			
		||||
TP.Rleg   = 100; % Radius where the legs articulations are positionned [mm]
 | 
			
		||||
TP.alpha  = 20; % Angle [deg]
 | 
			
		||||
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]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The density of its material.
 | 
			
		||||
 | 
			
		||||
TP.density = opts.density; % Density of the material [kg/m3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Its color.
 | 
			
		||||
 | 
			
		||||
TP.color = [0.7 0.7 0.7]; % Color [RGB]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Then the shape of the top plate is computed
 | 
			
		||||
 | 
			
		||||
TP.shape = [TP.Rint TP.H; TP.Rint 0; TP.Rext 0; TP.Rext TP.H];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The structure is added to the stewart structure
 | 
			
		||||
 | 
			
		||||
stewart.TP  = TP;
 | 
			
		||||
 | 
			
		||||
% Legs
 | 
			
		||||
% #+name: fig:stewart_legs
 | 
			
		||||
% #+caption: Schematic for the legs of the Stewart platform
 | 
			
		||||
% [[file:./figs/stewart_legs.png]]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The leg structure is initialized.
 | 
			
		||||
 | 
			
		||||
Leg = struct();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The maximum Stroke of each leg is defined.
 | 
			
		||||
 | 
			
		||||
Leg.stroke = opts.stroke; % [m]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The stiffness and damping of each leg are defined
 | 
			
		||||
 | 
			
		||||
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)]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The radius of the legs are defined
 | 
			
		||||
 | 
			
		||||
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]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The density of its material.
 | 
			
		||||
 | 
			
		||||
Leg.density = opts.density; % Density of the material used for the legs [kg/m3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Its color.
 | 
			
		||||
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]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The radius of spheres representing the ball joints are defined.
 | 
			
		||||
 | 
			
		||||
Leg.R = 1.3*Leg.Rbot; % Size of the sphere at the extremity of the leg [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The structure is added to the stewart structure
 | 
			
		||||
 | 
			
		||||
stewart.Leg = Leg;
 | 
			
		||||
 | 
			
		||||
% Ball Joints
 | 
			
		||||
% #+name: fig:stewart_ball_joints
 | 
			
		||||
% #+caption: Schematic of the support for the ball joints
 | 
			
		||||
% [[file:./figs/stewart_ball_joints.png]]
 | 
			
		||||
 | 
			
		||||
% =SP= is the structure representing the support for the ball joints at the extremity of each leg.
 | 
			
		||||
 | 
			
		||||
% The =SP= structure is initialized.
 | 
			
		||||
 | 
			
		||||
SP = struct();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We can define its rotational stiffness and damping. For now, we use perfect joints.
 | 
			
		||||
 | 
			
		||||
SP.k = 0; % [N*m/deg]
 | 
			
		||||
SP.c = 0; % [N*m/deg]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Its height is defined
 | 
			
		||||
 | 
			
		||||
SP.H = 15; % [mm]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Its radius is based on the radius on the sphere at the end of the legs.
 | 
			
		||||
 | 
			
		||||
SP.R = Leg.R; % [mm]
 | 
			
		||||
 | 
			
		||||
SP.section = [0    SP.H-SP.R;
 | 
			
		||||
@@ -230,40 +88,18 @@ SP.section = [0    SP.H-SP.R;
 | 
			
		||||
              SP.R 0;
 | 
			
		||||
              SP.R SP.H];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The density of its material is defined.
 | 
			
		||||
 | 
			
		||||
SP.density = opts.density; % [kg/m^3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Its color is defined.
 | 
			
		||||
 | 
			
		||||
SP.color = [0.7 0.7 0.7]; % [RGB]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% The structure is added to the Hexapod structure
 | 
			
		||||
 | 
			
		||||
stewart.SP  = SP;
 | 
			
		||||
 | 
			
		||||
% More parameters are initialized
 | 
			
		||||
 | 
			
		||||
stewart = initializeParameters(stewart);
 | 
			
		||||
 | 
			
		||||
% Save the Stewart Structure
 | 
			
		||||
 | 
			
		||||
save('./mat/stewart.mat', 'stewart')
 | 
			
		||||
 | 
			
		||||
% initializeParameters Function
 | 
			
		||||
 | 
			
		||||
function [stewart] = initializeParameters(stewart)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We first compute $[a_1, a_2, a_3, a_4, a_5, a_6]^T$ and $[b_1, b_2, b_3, b_4, b_5, b_6]^T$.
 | 
			
		||||
 | 
			
		||||
stewart.Aa = zeros(6, 3); % [mm]
 | 
			
		||||
stewart.Ab = zeros(6, 3); % [mm]
 | 
			
		||||
stewart.Bb = zeros(6, 3); % [mm]
 | 
			
		||||
@@ -285,25 +121,9 @@ for i = 1:3
 | 
			
		||||
end
 | 
			
		||||
stewart.Bb = stewart.Ab - stewart.H*[0,0,1];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Now, we compute the leg vectors $\hat{s}_i$ and leg position $l_i$:
 | 
			
		||||
% \[ b_i - a_i = l_i \hat{s}_i \]
 | 
			
		||||
 | 
			
		||||
% We initialize $l_i$ and $\hat{s}_i$
 | 
			
		||||
 | 
			
		||||
leg_length = zeros(6, 1); % [mm]
 | 
			
		||||
leg_vectors = zeros(6, 3);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We compute $b_i - a_i$, and then:
 | 
			
		||||
% \begin{align*}
 | 
			
		||||
%   l_i       &= \left|b_i - a_i\right| \\
 | 
			
		||||
%   \hat{s}_i &= \frac{b_i - a_i}{l_i}
 | 
			
		||||
% \end{align*}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
legs = stewart.Ab - stewart.Aa;
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
@@ -311,10 +131,6 @@ for i = 1:6
 | 
			
		||||
    leg_vectors(i,:) = legs(i,:) / leg_length(i);
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Then the shape of the bottom leg is estimated
 | 
			
		||||
 | 
			
		||||
stewart.Leg.lenght = leg_length(1)/1.5;
 | 
			
		||||
stewart.Leg.shape.bot = ...
 | 
			
		||||
    [0                0; ...
 | 
			
		||||
@@ -324,11 +140,6 @@ stewart.Leg.shape.bot = ...
 | 
			
		||||
     stewart.Leg.Rtop 0.2*stewart.Leg.lenght; ...
 | 
			
		||||
     0                0.2*stewart.Leg.lenght];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% We compute rotation matrices to have the orientation of the legs.
 | 
			
		||||
% The rotation matrix transforms the $z$ axis to the axis of the leg. The other axis are not important here.
 | 
			
		||||
 | 
			
		||||
stewart.Rm = struct('R', eye(3));
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
@@ -344,10 +155,6 @@ for i = 1:6
 | 
			
		||||
  stewart.Rm(i).R = [sx', sy', sz'];
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
% Compute Jacobian Matrix
 | 
			
		||||
 | 
			
		||||
J = zeros(6);
 | 
			
		||||
 | 
			
		||||
for i = 1:6
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										94
									
								
								src/initializeMechanicalElements.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/initializeMechanicalElements.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
function [stewart] = initializeMechanicalElements(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;
 | 
			
		||||
@@ -1,21 +1,20 @@
 | 
			
		||||
function [] = initializeSample(opts_param)
 | 
			
		||||
%% Default values for opts
 | 
			
		||||
    sample = struct( ...
 | 
			
		||||
        'radius',     100, ... % radius of the cylinder [mm]
 | 
			
		||||
        'height',     100, ... % height of the cylinder [mm]
 | 
			
		||||
        'mass',       10,  ... % mass of the cylinder [kg]
 | 
			
		||||
        'measheight', 50, ... % measurement point z-offset [mm]
 | 
			
		||||
        'offset',     [0, 0, 0],   ... % offset position of the sample [mm]
 | 
			
		||||
        'color',      [0.9 0.1 0.1] ...
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
    %% Populate opts with input parameters
 | 
			
		||||
    if exist('opts_param','var')
 | 
			
		||||
        for opt = fieldnames(opts_param)'
 | 
			
		||||
            sample.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
        end
 | 
			
		||||
sample = struct( ...
 | 
			
		||||
    'radius',     100, ... % radius of the cylinder [mm]
 | 
			
		||||
    'height',     100, ... % height of the cylinder [mm]
 | 
			
		||||
    'mass',       10,  ... % mass of the cylinder [kg]
 | 
			
		||||
    'measheight', 50, ... % measurement point z-offset [mm]
 | 
			
		||||
    'offset',     [0, 0, 0],   ... % offset position of the sample [mm]
 | 
			
		||||
    'color',      [0.9 0.1 0.1] ...
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
if exist('opts_param','var')
 | 
			
		||||
    for opt = fieldnames(opts_param)'
 | 
			
		||||
        sample.(opt{1}) = opts_param.(opt{1});
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    %% Save
 | 
			
		||||
    save('./mat/sample.mat', 'sample');
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
save('./mat/sample.mat', 'sample');
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										59
									
								
								src/initializeSimscapeData.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								src/initializeSimscapeData.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										94
									
								
								src/initializeStewartPlatform.m
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								src/initializeStewartPlatform.m
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
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;
 | 
			
		||||
		Reference in New Issue
	
	Block a user