Add function to initialize cylindrical struts

This commit is contained in:
Thomas Dehaeze 2020-01-22 13:25:40 +01:00
parent 7cfd4fef39
commit 6f5280cb33
2 changed files with 163 additions and 22 deletions

View File

@ -102,12 +102,14 @@ By following this procedure, we obtain a Matlab structure =stewart= that contain
** Test the functions
#+begin_src matlab
stewart = initializeFramesPositions('H', 90e-3, 'MO_B', 45e-3);
stewart = generateCubicConfiguration(stewart, 'Hc', 60e-3, 'FOc', 45e-3, 'FHa', 5e-3, 'MHb', 5e-3);
% stewart = generateCubicConfiguration(stewart, 'Hc', 60e-3, 'FOc', 45e-3, 'FHa', 5e-3, 'MHb', 5e-3);
stewart = generateGeneralConfiguration(stewart);
stewart = computeJointsPose(stewart);
stewart = initializeStrutDynamics(stewart, 'Ki', 1e6*ones(6,1), 'Ci', 1e2*ones(6,1));
stewart = initializeCylindricalStruts(stewart);
stewart = computeJacobian(stewart);
[Li, dLi] = inverseKinematics(stewart, 'AP', [0;0;0.00001], 'ARB', eye(3));
[P, R] = forwardKinematicsApprox(stewart, 'dL', dLi)
[P, R] = forwardKinematicsApprox(stewart, 'dL', dLi);
#+end_src
* =initializeFramesPositions=: Initialize the positions of frames {A}, {B}, {F} and {M}
@ -169,7 +171,8 @@ This Matlab function is accessible [[file:src/initializeFramesPositions.m][here]
stewart.FO_A = stewart.MO_B + stewart.FO_M; % Position of {A} with respect to {F} [m]
#+end_src
* =generateCubicConfiguration=: Generate a Cubic Configuration
* Initialize the position of the Joints
** =generateCubicConfiguration=: Generate a Cubic Configuration
:PROPERTIES:
:header-args:matlab+: :tangle src/generateCubicConfiguration.m
:header-args:matlab+: :comments none :mkdirp yes :eval no
@ -178,7 +181,7 @@ This Matlab function is accessible [[file:src/initializeFramesPositions.m][here]
This Matlab function is accessible [[file:src/generateCubicConfiguration.m][here]].
** Function description
*** Function description
#+begin_src matlab
function [stewart] = generateCubicConfiguration(stewart, args)
% generateCubicConfiguration - Generate a Cubic Configuration
@ -200,12 +203,12 @@ This Matlab function is accessible [[file:src/generateCubicConfiguration.m][here
% - Mb [3x6] - Its i'th column is the position vector of joint bi with respect to {M}
#+end_src
** Documentation
*** Documentation
#+name: fig:cubic-configuration-definition
#+caption: Cubic Configuration
[[file:figs/cubic-configuration-definition.png]]
** Optional Parameters
*** Optional Parameters
#+begin_src matlab
arguments
stewart
@ -216,7 +219,7 @@ This Matlab function is accessible [[file:src/generateCubicConfiguration.m][here
end
#+end_src
** Position of the Cube
*** Position of the Cube
We define the useful points of the cube with respect to the Cube's center.
${}^{C}C$ are the 6 vertices of the cubes expressed in a frame {C} which is
located at the center of the cube and aligned with {F} and {M}.
@ -236,7 +239,7 @@ located at the center of the cube and aligned with {F} and {M}.
CCm = [Cc(:,2), Cc(:,2), Cc(:,4), Cc(:,4), Cc(:,6), Cc(:,6)]; % CCm(:,i) corresponds to the top cube's vertice corresponding to the i'th leg
#+end_src
** Compute the pose
*** Compute the pose
We can compute the vector of each leg ${}^{C}\hat{\bm{s}}_{i}$ (unit vector from ${}^{C}C_{f}$ to ${}^{C}C_{m}$).
#+begin_src matlab
CSi = (CCm - CCf)./vecnorm(CCm - CCf);
@ -248,7 +251,7 @@ We now which to compute the position of the joints $a_{i}$ and $b_{i}$.
stewart.Mb = CCf + [0; 0; args.FOc-stewart.H] + ((stewart.H-args.MHb-(args.FOc-args.Hc/2))./CSi(3,:)).*CSi;
#+end_src
* =generateGeneralConfiguration=: Generate a Very General Configuration
** =generateGeneralConfiguration=: Generate a Very General Configuration
:PROPERTIES:
:header-args:matlab+: :tangle src/generateGeneralConfiguration.m
:header-args:matlab+: :comments none :mkdirp yes :eval no
@ -257,7 +260,7 @@ We now which to compute the position of the joints $a_{i}$ and $b_{i}$.
This Matlab function is accessible [[file:src/generateGeneralConfiguration.m][here]].
** Function description
*** Function description
#+begin_src matlab
function [stewart] = generateGeneralConfiguration(stewart, args)
% generateGeneralConfiguration - Generate a Very General Configuration
@ -281,11 +284,11 @@ This Matlab function is accessible [[file:src/generateGeneralConfiguration.m][he
% - Mb [3x6] - Its i'th column is the position vector of joint bi with respect to {M}
#+end_src
** Documentation
*** Documentation
Joints are positions on a circle centered with the Z axis of {F} and {M} and at a chosen distance from {F} and {M}.
The radius of the circles can be chosen as well as the angles where the joints are located.
** Optional Parameters
*** Optional Parameters
#+begin_src matlab
arguments
stewart
@ -298,7 +301,7 @@ The radius of the circles can be chosen as well as the angles where the joints a
end
#+end_src
** Compute the pose
*** Compute the pose
#+begin_src matlab
stewart.Fa = zeros(3,6);
stewart.Mb = zeros(3,6);
@ -430,6 +433,85 @@ This Matlab function is accessible [[file:src/initializeStrutDynamics.m][here]].
stewart.Ci = args.Ci;
#+end_src
* =initializeCylindricalStruts=: Define the mass and moment of inertia of cylindrical struts
:PROPERTIES:
:header-args:matlab+: :tangle src/initializeCylindricalStruts.m
:header-args:matlab+: :comments none :mkdirp yes :eval no
:END:
<<sec:initializeCylindricalStruts>>
This Matlab function is accessible [[file:src/initializeCylindricalStruts.m][here]].
** Function description
#+begin_src matlab
function [stewart] = initializeCylindricalStruts(stewart, args)
% initializeCylindricalStruts - Define the mass and moment of inertia of cylindrical struts
%
% Syntax: [stewart] = initializeCylindricalStruts(args)
%
% Inputs:
% - args - Structure with the following fields:
% - Fsm [1x1] - Mass of the Fixed part of the struts [kg]
% - Fsh [1x1] - Height of cylinder for the Fixed part of the struts [m]
% - Fsr [1x1] - Radius of cylinder for the Fixed part of the struts [m]
% - Msm [1x1] - Mass of the Mobile part of the struts [kg]
% - Msh [1x1] - Height of cylinder for the Mobile part of the struts [m]
% - Msr [1x1] - Radius of cylinder for the Mobile part of the struts [m]
%
% Outputs:
% - stewart - updated Stewart structure with the added fields:
% - struts [struct] - structure with the following fields:
% - Fsm [6x1] - Mass of the Fixed part of the struts [kg]
% - Fsi [3x3x6] - Moment of Inertia for the Fixed part of the struts [kg*m^2]
% - Msm [6x1] - Mass of the Mobile part of the struts [kg]
% - Msi [3x3x6] - Moment of Inertia for the Mobile part of the struts [kg*m^2]
% - Fsh [6x1] - Height of cylinder for the Fixed part of the struts [m]
% - Fsr [6x1] - Radius of cylinder for the Fixed part of the struts [m]
% - Msh [6x1] - Height of cylinder for the Mobile part of the struts [m]
% - Msr [6x1] - Radius of cylinder for the Mobile part of the struts [m]
#+end_src
** Optional Parameters
#+begin_src matlab
arguments
stewart
args.Fsm (6,1) double {mustBeNumeric, mustBePositive} = 0.1
args.Fsh (6,1) double {mustBeNumeric, mustBePositive} = 50e-3
args.Fsr (6,1) double {mustBeNumeric, mustBePositive} = 5e-3
args.Msm (6,1) double {mustBeNumeric, mustBePositive} = 0.1
args.Msh (6,1) double {mustBeNumeric, mustBePositive} = 50e-3
args.Msr (6,1) double {mustBeNumeric, mustBePositive} = 5e-3
end
#+end_src
** Add Stiffness and Damping properties of each strut
#+begin_src matlab
struts = struct();
struts.Fsm = ones(6,1).*args.Fsm;
struts.Msm = ones(6,1).*args.Msm;
struts.Fsh = ones(6,1).*args.Fsh;
struts.Fsr = ones(6,1).*args.Fsr;
struts.Msh = ones(6,1).*args.Msh;
struts.Msr = ones(6,1).*args.Msr;
struts.Fsi = zeros(3, 3, 6);
struts.Msi = zeros(3, 3, 6);
for i = 1:6
struts.Fsi(:,:,i) = diag([1/12 * struts.Fsm(i) * (3*struts.Fsr(i)^2 + struts.Fsh(i)^2), ...
1/12 * struts.Fsm(i) * (3*struts.Fsr(i)^2 + struts.Fsh(i)^2), ...
1/2 * struts.Fsm(i) * struts.Fsr(i)^2]);
struts.Msi(:,:,i) = diag([1/12 * struts.Msm(i) * (3*struts.Msr(i)^2 + struts.Msh(i)^2), ...
1/12 * struts.Msm(i) * (3*struts.Msr(i)^2 + struts.Msh(i)^2), ...
1/2 * struts.Msm(i) * struts.Msr(i)^2]);
end
#+end_src
#+begin_src matlab
stewart.struts = struts;
#+end_src
* =computeJacobian=: Compute the Jacobian Matrix
:PROPERTIES:
:header-args:matlab+: :tangle src/computeJacobian.m
@ -473,7 +555,8 @@ This Matlab function is accessible [[file:src/computeJacobian.m][here]].
stewart.C = inv(stewart.K);
#+end_src
* =inverseKinematics=: Compute Inverse Kinematics
* Utility Functions
** =inverseKinematics=: Compute Inverse Kinematics
:PROPERTIES:
:header-args:matlab+: :tangle src/inverseKinematics.m
:header-args:matlab+: :comments none :mkdirp yes :eval no
@ -482,7 +565,7 @@ This Matlab function is accessible [[file:src/computeJacobian.m][here]].
This Matlab function is accessible [[file:src/inverseKinematics.m][here]].
** Function description
*** Function description
#+begin_src matlab
function [Li, dLi] = inverseKinematics(stewart, args)
% inverseKinematics - Compute the needed length of each strut to have the wanted position and orientation of {B} with respect to {A}
@ -502,7 +585,7 @@ This Matlab function is accessible [[file:src/inverseKinematics.m][here]].
% - dLi [6x1] - The 6 needed displacement of the struts from the initial position in [m] to have the wanted pose of {B} w.r.t. {A}
#+end_src
** Optional Parameters
*** Optional Parameters
#+begin_src matlab
arguments
stewart
@ -511,7 +594,7 @@ This Matlab function is accessible [[file:src/inverseKinematics.m][here]].
end
#+end_src
** Theory
*** Theory
For inverse kinematic analysis, it is assumed that the position ${}^A\bm{P}$ and orientation of the moving platform ${}^A\bm{R}_B$ are given and the problem is to obtain the joint variables, namely, $\bm{L} = [l_1, l_2, \dots, l_6]^T$.
From the geometry of the manipulator, the loop closure for each limb, $i = 1, 2, \dots, 6$ can be written as
@ -533,7 +616,7 @@ Hence, for $i = 1, 2, \dots, 6$, each limb length can be uniquely determined by:
If the position and orientation of the moving platform lie in the feasible workspace of the manipulator, one unique solution to the limb length is determined by the above equation.
Otherwise, when the limbs' lengths derived yield complex numbers, then the position or orientation of the moving platform is not reachable.
** Compute
*** Compute
#+begin_src matlab
Li = sqrt(args.AP'*args.AP + diag(stewart.Bb'*stewart.Bb) + diag(stewart.Aa'*stewart.Aa) - (2*args.AP'*stewart.Aa)' + (2*args.AP'*(args.ARB*stewart.Bb))' - diag(2*(args.ARB*stewart.Bb)'*stewart.Aa));
#+end_src
@ -542,7 +625,7 @@ Otherwise, when the limbs' lengths derived yield complex numbers, then the posit
dLi = Li-stewart.l;
#+end_src
* =forwardKinematicsApprox=: Compute the Forward Kinematics
** =forwardKinematicsApprox=: Compute the Forward Kinematics
:PROPERTIES:
:header-args:matlab+: :tangle src/forwardKinematicsApprox.m
:header-args:matlab+: :comments none :mkdirp yes :eval no
@ -551,7 +634,7 @@ Otherwise, when the limbs' lengths derived yield complex numbers, then the posit
This Matlab function is accessible [[file:src/forwardKinematicsApprox.m][here]].
** Function description
*** Function description
#+begin_src matlab
function [P, R] = forwardKinematicsApprox(stewart, args)
% forwardKinematicsApprox - Computed the approximate pose of {B} with respect to {A} from the length of each strut and using
@ -570,7 +653,7 @@ This Matlab function is accessible [[file:src/forwardKinematicsApprox.m][here]].
% - R [3x3] - The estimated rotation matrix that gives the orientation of {B} with respect to {A}
#+end_src
** Optional Parameters
*** Optional Parameters
#+begin_src matlab
arguments
stewart
@ -578,7 +661,7 @@ This Matlab function is accessible [[file:src/forwardKinematicsApprox.m][here]].
end
#+end_src
** Computation
*** Computation
From a small displacement of each strut $d\bm{\mathcal{L}}$, we can compute the
position and orientation of {B} with respect to {A} using the following formula:
\[ d \bm{\mathcal{X}} = \bm{J}^{-1} d\bm{\mathcal{L}} \]

View File

@ -0,0 +1,58 @@
function [stewart] = initializeCylindricalStruts(stewart, args)
% initializeCylindricalStruts - Define the mass and moment of inertia of cylindrical struts
%
% Syntax: [stewart] = initializeCylindricalStruts(args)
%
% Inputs:
% - args - Structure with the following fields:
% - Fsm [1x1] - Mass of the Fixed part of the struts [kg]
% - Fsh [1x1] - Height of cylinder for the Fixed part of the struts [m]
% - Fsr [1x1] - Radius of cylinder for the Fixed part of the struts [m]
% - Msm [1x1] - Mass of the Mobile part of the struts [kg]
% - Msh [1x1] - Height of cylinder for the Mobile part of the struts [m]
% - Msr [1x1] - Radius of cylinder for the Mobile part of the struts [m]
%
% Outputs:
% - stewart - updated Stewart structure with the added fields:
% - struts [struct] - structure with the following fields:
% - Fsm [6x1] - Mass of the Fixed part of the struts [kg]
% - Fsi [3x3x6] - Moment of Inertia for the Fixed part of the struts [kg*m^2]
% - Msm [6x1] - Mass of the Mobile part of the struts [kg]
% - Msi [3x3x6] - Moment of Inertia for the Mobile part of the struts [kg*m^2]
% - Fsh [6x1] - Height of cylinder for the Fixed part of the struts [m]
% - Fsr [6x1] - Radius of cylinder for the Fixed part of the struts [m]
% - Msh [6x1] - Height of cylinder for the Mobile part of the struts [m]
% - Msr [6x1] - Radius of cylinder for the Mobile part of the struts [m]
arguments
stewart
args.Fsm (6,1) double {mustBeNumeric, mustBePositive} = 0.1
args.Fsh (6,1) double {mustBeNumeric, mustBePositive} = 50e-3
args.Fsr (6,1) double {mustBeNumeric, mustBePositive} = 5e-3
args.Msm (6,1) double {mustBeNumeric, mustBePositive} = 0.1
args.Msh (6,1) double {mustBeNumeric, mustBePositive} = 50e-3
args.Msr (6,1) double {mustBeNumeric, mustBePositive} = 5e-3
end
struts = struct();
struts.Fsm = ones(6,1).*args.Fsm;
struts.Msm = ones(6,1).*args.Msm;
struts.Fsh = ones(6,1).*args.Fsh;
struts.Fsr = ones(6,1).*args.Fsr;
struts.Msh = ones(6,1).*args.Msh;
struts.Msr = ones(6,1).*args.Msr;
struts.Fsi = zeros(3, 3, 6);
struts.Msi = zeros(3, 3, 6);
for i = 1:6
struts.Fsi(:,:,i) = diag([1/12 * struts.Fsm(i) * (3*struts.Fsr(i)^2 + struts.Fsh(i)^2), ...
1/12 * struts.Fsm(i) * (3*struts.Fsr(i)^2 + struts.Fsh(i)^2), ...
1/2 * struts.Fsm(i) * struts.Fsr(i)^2]);
struts.Msi(:,:,i) = diag([1/12 * struts.Msm(i) * (3*struts.Msr(i)^2 + struts.Msh(i)^2), ...
1/12 * struts.Msm(i) * (3*struts.Msr(i)^2 + struts.Msh(i)^2), ...
1/2 * struts.Msm(i) * struts.Msr(i)^2]);
end
stewart.struts = struts;