Work on Control (HAC-LAC) + Models

This commit is contained in:
2020-03-13 17:40:22 +01:00
parent 493268638b
commit fab78b6527
78 changed files with 5395 additions and 2475 deletions

View File

@@ -4,7 +4,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2020-02-25 mar. 18:20 -->
<!-- 2020-03-06 ven. 15:09 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Matlab Functions used for the NASS Project</title>
@@ -202,50 +202,28 @@
<script type="text/javascript" src="./js/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="./js/readtheorg.js"></script>
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
// @license-end
</script>
</head>
<body>
@@ -259,276 +237,15 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgea7e3d7">1. computePsdDispl</a></li>
<li><a href="#org5e769e7">2. computeSetpoint</a></li>
<li><a href="#org0239a56">3. converErrorBasis</a></li>
<li><a href="#orgdc168b9">4. computeReferencePose</a></li>
<li><a href="#org493ab7f">5. Compute the Sample Position Error w.r.t. the NASS</a></li>
<li><a href="#orgdc168b9">1. computeReferencePose</a></li>
<li><a href="#org493ab7f">2. Compute the Sample Position Error w.r.t. the NASS</a></li>
</ul>
</div>
</div>
<div id="outline-container-orgea7e3d7" class="outline-2">
<h2 id="orgea7e3d7"><span class="section-number-2">1</span> computePsdDispl</h2>
<div class="outline-text-2" id="text-1">
<p>
<a id="org2cc2589"></a>
</p>
<p>
This Matlab function is accessible <a href="../src/computePsdDispl.m">here</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-keyword">function</span> <span class="org-variable-name">[psd_object]</span> = <span class="org-function-name">computePsdDispl</span>(<span class="org-variable-name">sys_data</span>, <span class="org-variable-name">t_init</span>, <span class="org-variable-name">n_av</span>)
i_init = find(sys_data.time <span class="org-type">&gt;</span> t_init, 1);
han_win = hanning(ceil(length(sys_data.Dx(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>))<span class="org-type">/</span>n_av));
Fs = 1<span class="org-type">/</span>sys_data.time(2);
[pdx, f] = pwelch(sys_data.Dx(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
[pdy, <span class="org-type">~</span>] = pwelch(sys_data.Dy(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
[pdz, <span class="org-type">~</span>] = pwelch(sys_data.Dz(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
[prx, <span class="org-type">~</span>] = pwelch(sys_data.Rx(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
[pry, <span class="org-type">~</span>] = pwelch(sys_data.Ry(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
[prz, <span class="org-type">~</span>] = pwelch(sys_data.Rz(i_init<span class="org-type">:</span>end, <span class="org-type">:</span>), han_win, [], [], Fs);
psd_object = struct(...
<span class="org-string">'f'</span>, f, ...
<span class="org-string">'dx'</span>, pdx, ...
<span class="org-string">'dy'</span>, pdy, ...
<span class="org-string">'dz'</span>, pdz, ...
<span class="org-string">'rx'</span>, prx, ...
<span class="org-string">'ry'</span>, pry, ...
<span class="org-string">'rz'</span>, prz);
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org5e769e7" class="outline-2">
<h2 id="org5e769e7"><span class="section-number-2">2</span> computeSetpoint</h2>
<div class="outline-text-2" id="text-2">
<p>
<a id="orge6ebb0b"></a>
</p>
<p>
This Matlab function is accessible <a href="../src/computeSetpoint.m">here</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-keyword">function</span> <span class="org-variable-name">setpoint</span> = <span class="org-function-name">computeSetpoint</span>(<span class="org-variable-name">ty</span>, <span class="org-variable-name">ry</span>, <span class="org-variable-name">rz</span>)
<span class="org-matlab-cellbreak"><span class="org-comment">%%</span></span>
setpoint = zeros(<span class="org-variable-name">6</span>, 1);
<span class="org-matlab-cellbreak"><span class="org-comment">%% Ty</span></span>
Ty = [1 0 0 0 ;
0 1 0 ty ;
0 0 1 0 ;
0 0 0 1 ];
<span class="org-comment">% Tyinv = [1 0 0 0 ;</span>
<span class="org-comment">% 0 1 0 -ty ;</span>
<span class="org-comment">% 0 0 1 0 ;</span>
<span class="org-comment">% 0 0 0 1 ];</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Ry</span></span>
Ry = [ cos(ry) 0 sin(ry) 0 ;
0 1 0 0 ;
<span class="org-type">-</span>sin(ry) 0 cos(ry) 0 ;
0 0 0 1 ];
<span class="org-comment">% TMry = Ty*Ry*Tyinv;</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Rz</span></span>
Rz = [cos(rz) <span class="org-type">-</span>sin(rz) 0 0 ;
sin(rz) cos(rz) 0 0 ;
0 0 1 0 ;
0 0 0 1 ];
<span class="org-comment">% TMrz = Ty*TMry*Rz*TMry'*Tyinv;</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% All stages</span></span>
<span class="org-comment">% </span><span class="org-comment"><span class="org-constant">TM </span></span><span class="org-comment">= TMrz*TMry*Ty;</span>
TM = Ty<span class="org-type">*</span>Ry<span class="org-type">*</span>Rz;
[thetax, thetay, thetaz] = RM2angle(TM(1<span class="org-type">:</span>3, 1<span class="org-type">:</span>3));
setpoint<span class="org-type">(1:3) </span>= TM(1<span class="org-type">:</span>3, 4);
setpoint<span class="org-type">(4:6) </span>= [thetax, thetay, thetaz];
<span class="org-matlab-cellbreak"><span class="org-comment">%% Custom Functions</span></span>
<span class="org-keyword">function</span> <span class="org-variable-name">[thetax, thetay, thetaz]</span> = <span class="org-function-name">RM2angle</span>(<span class="org-variable-name">R</span>)
<span class="org-keyword">if</span> abs(abs(R(3, 1)) <span class="org-type">-</span> 1) <span class="org-type">&gt;</span> 1e<span class="org-type">-</span>6 <span class="org-comment">% R31 != 1 and R31 != -1</span>
thetay = <span class="org-type">-</span>asin(R(3, 1));
thetax = atan2(R(3, 2)<span class="org-type">/</span>cos(thetay), R(3, 3)<span class="org-type">/</span>cos(thetay));
thetaz = atan2(R(2, 1)<span class="org-type">/</span>cos(thetay), R(1, 1)<span class="org-type">/</span>cos(thetay));
<span class="org-keyword">else</span>
thetaz = 0;
<span class="org-keyword">if</span> abs(R(3, 1)<span class="org-type">+</span>1) <span class="org-type">&lt;</span> 1e<span class="org-type">-</span>6 <span class="org-comment">% R31 = -1</span>
thetay = <span class="org-constant">pi</span><span class="org-type">/</span>2;
thetax = thetaz <span class="org-type">+</span> atan2(R(1, 2), R(1, 3));
<span class="org-keyword">else</span>
thetay = <span class="org-type">-</span><span class="org-constant">pi</span><span class="org-type">/</span>2;
thetax = <span class="org-type">-</span>thetaz <span class="org-type">+</span> atan2(<span class="org-type">-</span>R(1, 2), <span class="org-type">-</span>R(1, 3));
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org0239a56" class="outline-2">
<h2 id="org0239a56"><span class="section-number-2">3</span> converErrorBasis</h2>
<div class="outline-text-2" id="text-3">
<p>
<a id="org8c2ffe5"></a>
</p>
<p>
This Matlab function is accessible <a href="../src/converErrorBasis.m">here</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-keyword">function</span> <span class="org-variable-name">error_nass</span> = <span class="org-function-name">convertErrorBasis</span>(<span class="org-variable-name">pos</span>, <span class="org-variable-name">setpoint</span>, <span class="org-variable-name">ty</span>, <span class="org-variable-name">ry</span>, <span class="org-variable-name">rz</span>)
<span class="org-comment">% convertErrorBasis -</span>
<span class="org-comment">%</span>
<span class="org-comment">% Syntax: convertErrorBasis(p_error, ty, ry, rz)</span>
<span class="org-comment">%</span>
<span class="org-comment">% Inputs:</span>
<span class="org-comment">% - p_error - Position error of the sample w.r.t. the granite [m, rad]</span>
<span class="org-comment">% - ty - Measured translation of the Ty stage [m]</span>
<span class="org-comment">% - ry - Measured rotation of the Ry stage [rad]</span>
<span class="org-comment">% - rz - Measured rotation of the Rz stage [rad]</span>
<span class="org-comment">%</span>
<span class="org-comment">% Outputs:</span>
<span class="org-comment">% - P_nass - Position error of the sample w.r.t. the NASS base [m]</span>
<span class="org-comment">% - R_nass - Rotation error of the sample w.r.t. the NASS base [rad]</span>
<span class="org-comment">%</span>
<span class="org-comment">% Example:</span>
<span class="org-comment">%</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% If line vector =&gt; column vector</span></span>
<span class="org-keyword">if</span> size(pos, 2) <span class="org-type">==</span> 6
pos = pos<span class="org-type">'</span>;
<span class="org-keyword">end</span>
<span class="org-keyword">if</span> size(setpoint, 2) <span class="org-type">==</span> 6
setpoint = setpoint<span class="org-type">'</span>;
<span class="org-keyword">end</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Position of the sample in the frame fixed to the Granite</span></span>
P_granite = [pos(1<span class="org-type">:</span>3); 1]; <span class="org-comment">% Position [m]</span>
R_granite = [setpoint(1<span class="org-type">:</span>3); 1]; <span class="org-comment">% Reference [m]</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Transformation matrices of the stages</span></span>
<span class="org-comment">% T-y</span>
TMty = [1 0 0 0 ;
0 1 0 ty ;
0 0 1 0 ;
0 0 0 1 ];
<span class="org-comment">% R-y</span>
TMry = [ cos(ry) 0 sin(ry) 0 ;
0 1 0 0 ;
<span class="org-type">-</span>sin(ry) 0 cos(ry) 0 ;
0 0 0 1 ];
<span class="org-comment">% R-z</span>
TMrz = [cos(rz) <span class="org-type">-</span>sin(rz) 0 0 ;
sin(rz) cos(rz) 0 0 ;
0 0 1 0 ;
0 0 0 1 ];
<span class="org-matlab-cellbreak"><span class="org-comment">%% Compute Point coordinates in the new reference fixed to the NASS base</span></span>
<span class="org-comment">% P_nass = TMrz*TMry*TMty*P_granite;</span>
P_nass = TMrz<span class="org-type">\</span>TMry<span class="org-type">\</span>TMty<span class="org-type">\</span>P_granite;
R_nass = TMrz<span class="org-type">\</span>TMry<span class="org-type">\</span>TMty<span class="org-type">\</span>R_granite;
dx = R_nass(1)<span class="org-type">-</span>P_nass(1);
dy = R_nass(2)<span class="org-type">-</span>P_nass(2);
dz = R_nass(3)<span class="org-type">-</span>P_nass(3);
<span class="org-matlab-cellbreak"><span class="org-comment">%% Compute new basis vectors linked to the NASS base</span></span>
<span class="org-comment">% ux_nass = TMrz*TMry*TMty*[1; 0; 0; 0];</span>
<span class="org-comment">% ux_nass = ux_nass(1:3);</span>
<span class="org-comment">% uy_nass = TMrz*TMry*TMty*[0; 1; 0; 0];</span>
<span class="org-comment">% uy_nass = uy_nass(1:3);</span>
<span class="org-comment">% uz_nass = TMrz*TMry*TMty*[0; 0; 1; 0];</span>
<span class="org-comment">% uz_nass = uz_nass(1:3);</span>
ux_nass = TMrz<span class="org-type">\</span>TMry<span class="org-type">\</span>TMty<span class="org-type">\</span>[1; 0; 0; 0];
ux_nass = ux_nass(1<span class="org-type">:</span>3);
uy_nass = TMrz<span class="org-type">\</span>TMry<span class="org-type">\</span>TMty<span class="org-type">\</span>[0; 1; 0; 0];
uy_nass = uy_nass(1<span class="org-type">:</span>3);
uz_nass = TMrz<span class="org-type">\</span>TMry<span class="org-type">\</span>TMty<span class="org-type">\</span>[0; 0; 1; 0];
uz_nass = uz_nass(1<span class="org-type">:</span>3);
<span class="org-matlab-cellbreak"><span class="org-comment">%% Rotations error w.r.t. granite Frame</span></span>
<span class="org-comment">% Rotations error w.r.t. granite Frame</span>
rx_nass = pos(4);
ry_nass = pos(5);
rz_nass = pos(6);
<span class="org-comment">% Rotation matrices of the Sample w.r.t. the Granite</span>
Mrx_error = [1 0 0 ;
0 cos(<span class="org-type">-</span>rx_nass) <span class="org-type">-</span>sin(<span class="org-type">-</span>rx_nass) ;
0 sin(<span class="org-type">-</span>rx_nass) cos(<span class="org-type">-</span>rx_nass)];
Mry_error = [ cos(<span class="org-type">-</span>ry_nass) 0 sin(<span class="org-type">-</span>ry_nass) ;
0 1 0 ;
<span class="org-type">-</span>sin(<span class="org-type">-</span>ry_nass) 0 cos(<span class="org-type">-</span>ry_nass)];
Mrz_error = [cos(<span class="org-type">-</span>rz_nass) <span class="org-type">-</span>sin(<span class="org-type">-</span>rz_nass) 0 ;
sin(<span class="org-type">-</span>rz_nass) cos(<span class="org-type">-</span>rz_nass) 0 ;
0 0 1];
<span class="org-comment">% Rotation matrix of the Sample w.r.t. the Granite</span>
Mr_error = Mrz_error<span class="org-type">*</span>Mry_error<span class="org-type">*</span>Mrx_error;
<span class="org-matlab-cellbreak"><span class="org-comment">%% Use matrix to solve</span></span>
R = Mr_error<span class="org-type">/</span>[ux_nass, uy_nass, uz_nass]; <span class="org-comment">% Rotation matrix from NASS base to Sample</span>
[thetax, thetay, thetaz] = RM2angle(R);
error_nass = [dx; dy; dz; thetax; thetay; thetaz];
<span class="org-matlab-cellbreak"><span class="org-comment">%% Custom Functions</span></span>
<span class="org-keyword">function</span> <span class="org-variable-name">[thetax, thetay, thetaz]</span> = <span class="org-function-name">RM2angle</span>(<span class="org-variable-name">R</span>)
<span class="org-keyword">if</span> abs(abs(R(3, 1)) <span class="org-type">-</span> 1) <span class="org-type">&gt;</span> 1e<span class="org-type">-</span>6 <span class="org-comment">% R31 != 1 and R31 != -1</span>
thetay = <span class="org-type">-</span>asin(R(3, 1));
<span class="org-comment">% thetaybis = pi-thetay;</span>
thetax = atan2(R(3, 2)<span class="org-type">/</span>cos(thetay), R(3, 3)<span class="org-type">/</span>cos(thetay));
<span class="org-comment">% thetaxbis = atan2(R(3, 2)/cos(thetaybis), R(3, 3)/cos(thetaybis));</span>
thetaz = atan2(R(2, 1)<span class="org-type">/</span>cos(thetay), R(1, 1)<span class="org-type">/</span>cos(thetay));
<span class="org-comment">% thetazbis = atan2(R(2, 1)/cos(thetaybis), R(1, 1)/cos(thetaybis));</span>
<span class="org-keyword">else</span>
thetaz = 0;
<span class="org-keyword">if</span> abs(R(3, 1)<span class="org-type">+</span>1) <span class="org-type">&lt;</span> 1e<span class="org-type">-</span>6 <span class="org-comment">% R31 = -1</span>
thetay = <span class="org-constant">pi</span><span class="org-type">/</span>2;
thetax = thetaz <span class="org-type">+</span> atan2(R(1, 2), R(1, 3));
<span class="org-keyword">else</span>
thetay = <span class="org-type">-</span><span class="org-constant">pi</span><span class="org-type">/</span>2;
thetax = <span class="org-type">-</span>thetaz <span class="org-type">+</span> atan2(<span class="org-type">-</span>R(1, 2), <span class="org-type">-</span>R(1, 3));
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgdc168b9" class="outline-2">
<h2 id="orgdc168b9"><span class="section-number-2">4</span> computeReferencePose</h2>
<div class="outline-text-2" id="text-4">
<h2 id="orgdc168b9"><span class="section-number-2">1</span> computeReferencePose</h2>
<div class="outline-text-2" id="text-1">
<p>
<a id="org98cbe6e"></a>
</p>
@@ -620,8 +337,8 @@ This Matlab function is accessible <a href="src/computeReferencePose.m">here</a>
</div>
</div>
<div id="outline-container-org493ab7f" class="outline-2">
<h2 id="org493ab7f"><span class="section-number-2">5</span> Compute the Sample Position Error w.r.t. the NASS</h2>
<div class="outline-text-2" id="text-5">
<h2 id="org493ab7f"><span class="section-number-2">2</span> Compute the Sample Position Error w.r.t. the NASS</h2>
<div class="outline-text-2" id="text-2">
<p>
<a id="org6dcd4fb"></a>
</p>
@@ -658,7 +375,7 @@ MTr = [WTm(1<span class="org-type">:</span>3,1<span class="org-type">:</span>3)<
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2020-02-25 mar. 18:20</p>
<p class="date">Created: 2020-03-06 ven. 15:09</p>
</div>
</body>
</html>