nass-simscape/functions/index.html

703 lines
35 KiB
HTML
Raw Normal View History

2019-12-11 17:33:45 +01:00
<?xml version="1.0" encoding="utf-8"?>
2020-01-29 20:25:59 +01:00
<?xml version="1.0" encoding="utf-8"?>
2019-12-11 17:33:45 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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-01-29 20:25:59 +01:00
<!-- 2020-01-29 mer. 20:25 -->
2019-12-11 17:33:45 +01:00
<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>
<meta name="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="../css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="../css/readtheorg.css"/>
<link rel="stylesheet" type="text/css" href="../css/zenburn.css"/>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<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.
2020-01-29 20:25:59 +01:00
Copyright (C) 2012-2020 Free Software Foundation, Inc.
2019-12-11 17:33:45 +01:00
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.
*/
<!--/*--><![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;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="../index.html"> UP </a>
|
<a accesskey="H" href="../index.html"> HOME </a>
</div><div id="content">
<h1 class="title">Matlab Functions used for the NASS Project</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
2020-01-29 20:25:59 +01:00
<li><a href="#orgf4ff272">1. <span class="todo TODO">TODO</span> computePsdDispl</a></li>
<li><a href="#org4e69743">2. <span class="todo TODO">TODO</span> computeSetpoint</a></li>
<li><a href="#org293101b">3. <span class="todo TODO">TODO</span> converErrorBasis</a></li>
<li><a href="#orgebd9e8d">4. Inverse Kinematics of the Hexapod</a></li>
<li><a href="#orga234cde">5. computeReferencePose</a></li>
<li><a href="#orgf5cf06b">6. Compute the Sample Position Error w.r.t. the NASS</a></li>
2019-12-11 17:33:45 +01:00
</ul>
</div>
</div>
2020-01-29 20:25:59 +01:00
<div id="outline-container-orgf4ff272" class="outline-2">
<h2 id="orgf4ff272"><span class="section-number-2">1</span> <span class="todo TODO">TODO</span> computePsdDispl</h2>
2019-12-11 17:33:45 +01:00
<div class="outline-text-2" id="text-1">
<p>
2020-01-29 20:25:59 +01:00
<a id="orgf1d0895"></a>
2019-12-11 17:33:45 +01:00
</p>
<p>
This Matlab function is accessible <a href="../src/computePsdDispl.m">here</a>.
</p>
<div class="org-src-container">
2020-01-29 20:25:59 +01:00
<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);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
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);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
[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);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
[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);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
psd_object = struct(...
2019-12-11 17:33:45 +01:00
<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, ...
2020-01-29 20:25:59 +01:00
<span class="org-string">'rz'</span>, prz);
2019-12-11 17:33:45 +01:00
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
2020-01-29 20:25:59 +01:00
<div id="outline-container-org4e69743" class="outline-2">
<h2 id="org4e69743"><span class="section-number-2">2</span> <span class="todo TODO">TODO</span> computeSetpoint</h2>
<div class="outline-text-2" id="text-2">
2019-12-11 17:33:45 +01:00
<p>
2020-01-29 20:25:59 +01:00
<a id="org2ff14b2"></a>
2019-12-11 17:33:45 +01:00
</p>
<p>
This Matlab function is accessible <a href="../src/computeSetpoint.m">here</a>.
</p>
<div class="org-src-container">
2020-01-29 20:25:59 +01:00
<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>)
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%%</span></span>
2020-01-29 20:25:59 +01:00
setpoint = zeros(<span class="org-variable-name">6</span>, 1);
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Ty</span></span>
2020-01-29 20:25:59 +01:00
Ty = [1 0 0 0 ;
0 1 0 ty ;
0 0 1 0 ;
0 0 0 1 ];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
<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>
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Ry</span></span>
2020-01-29 20:25:59 +01:00
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 ];
2019-12-11 17:33:45 +01:00
<span class="org-comment">% TMry = Ty*Ry*Tyinv;</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Rz</span></span>
2020-01-29 20:25:59 +01:00
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 ];
2019-12-11 17:33:45 +01:00
<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;
2020-01-29 20:25:59 +01:00
[thetax, thetay, thetaz] = RM2angle(TM(1<span class="org-type">:</span>3, 1<span class="org-type">:</span>3));
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
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];
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Custom Functions</span></span>
2020-01-29 20:25:59 +01:00
<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));
2019-12-11 17:33:45 +01:00
<span class="org-keyword">else</span>
2020-01-29 20:25:59 +01:00
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));
2019-12-11 17:33:45 +01:00
<span class="org-keyword">else</span>
2020-01-29 20:25:59 +01:00
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));
2019-12-11 17:33:45 +01:00
<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>
2020-01-29 20:25:59 +01:00
<div id="outline-container-org293101b" class="outline-2">
<h2 id="org293101b"><span class="section-number-2">3</span> <span class="todo TODO">TODO</span> converErrorBasis</h2>
<div class="outline-text-2" id="text-3">
2019-12-11 17:33:45 +01:00
<p>
2020-01-29 20:25:59 +01:00
<a id="orged36710"></a>
2019-12-11 17:33:45 +01:00
</p>
<p>
This Matlab function is accessible <a href="../src/converErrorBasis.m">here</a>.
</p>
<div class="org-src-container">
2020-01-29 20:25:59 +01:00
<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>)
2019-12-11 17:33:45 +01:00
<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>
2020-01-29 20:25:59 +01:00
<span class="org-keyword">if</span> size(pos, 2) <span class="org-type">==</span> 6
2019-12-11 17:33:45 +01:00
pos = pos<span class="org-type">'</span>;
<span class="org-keyword">end</span>
2020-01-29 20:25:59 +01:00
<span class="org-keyword">if</span> size(setpoint, 2) <span class="org-type">==</span> 6
2019-12-11 17:33:45 +01:00
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>
2020-01-29 20:25:59 +01:00
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>
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Transformation matrices of the stages</span></span>
<span class="org-comment">% T-y</span>
2020-01-29 20:25:59 +01:00
TMty = [1 0 0 0 ;
0 1 0 ty ;
0 0 1 0 ;
0 0 0 1 ];
2019-12-11 17:33:45 +01:00
<span class="org-comment">% R-y</span>
2020-01-29 20:25:59 +01:00
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 ];
2019-12-11 17:33:45 +01:00
<span class="org-comment">% R-z</span>
2020-01-29 20:25:59 +01:00
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 ];
2019-12-11 17:33:45 +01:00
<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;
2020-01-29 20:25:59 +01:00
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);
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Compute new basis vectors linked to the NASS base</span></span>
2020-01-29 20:25:59 +01:00
<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);
2019-12-11 17:33:45 +01:00
<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>
2020-01-29 20:25:59 +01:00
rx_nass = pos(4);
ry_nass = pos(5);
rz_nass = pos(6);
2019-12-11 17:33:45 +01:00
<span class="org-comment">% Rotation matrices of the Sample w.r.t. the Granite</span>
2020-01-29 20:25:59 +01:00
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)];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
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)];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
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];
2019-12-11 17:33:45 +01:00
<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>
2020-01-29 20:25:59 +01:00
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>
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
[thetax, thetay, thetaz] = RM2angle(R);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
error_nass = [dx; dy; dz; thetax; thetay; thetaz];
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Custom Functions</span></span>
2020-01-29 20:25:59 +01:00
<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));
2019-12-11 17:33:45 +01:00
<span class="org-comment">% thetaybis = pi-thetay;</span>
2020-01-29 20:25:59 +01:00
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>
2019-12-11 17:33:45 +01:00
<span class="org-keyword">else</span>
2020-01-29 20:25:59 +01:00
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));
2019-12-11 17:33:45 +01:00
<span class="org-keyword">else</span>
2020-01-29 20:25:59 +01:00
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));
2019-12-11 17:33:45 +01:00
<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>
2020-01-29 20:25:59 +01:00
<div id="outline-container-orgebd9e8d" class="outline-2">
<h2 id="orgebd9e8d"><span class="section-number-2">4</span> Inverse Kinematics of the Hexapod</h2>
<div class="outline-text-2" id="text-4">
2019-12-11 17:33:45 +01:00
<p>
2020-01-29 20:25:59 +01:00
<a id="orgfcd14bf"></a>
2019-12-11 17:33:45 +01:00
</p>
<p>
This Matlab function is accessible <a href="src/inverseKinematicsHexapod.m">here</a>.
</p>
<div class="org-src-container">
2020-01-29 20:25:59 +01:00
<pre class="src src-matlab"><span class="org-keyword">function</span> <span class="org-variable-name">[L]</span> = <span class="org-function-name">inverseKinematicsHexapod</span>(<span class="org-variable-name">hexapod</span>, <span class="org-variable-name">AP</span>, <span class="org-variable-name">ARB</span>)
2019-12-11 17:33:45 +01:00
<span class="org-comment">% inverseKinematicsHexapod - Compute the initial position of each leg to have the wanted Hexapod's position</span>
<span class="org-comment">%</span>
<span class="org-comment">% Syntax: inverseKinematicsHexapod(hexapod, AP, ARB)</span>
<span class="org-comment">%</span>
<span class="org-comment">% Inputs:</span>
<span class="org-comment">% - hexapod - Hexapod object containing the geometry of the hexapod</span>
<span class="org-comment">% - AP - Position vector of point OB expressed in frame {A} in [m]</span>
<span class="org-comment">% - ARB - Rotation Matrix expressed in frame {A}</span>
<span class="org-comment">% Wanted Length of the hexapod's legs [m]</span>
2020-01-29 20:25:59 +01:00
L = zeros(6, 1);
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
<span class="org-keyword">for</span> <span class="org-variable-name"><span class="org-constant">i</span></span> = <span class="org-constant">1:length(L)</span>
Bbi = hexapod.pos_top_tranform(<span class="org-constant">i</span>, <span class="org-type">:</span>)<span class="org-type">'</span> <span class="org-type">-</span> 1e<span class="org-type">-</span>3<span class="org-type">*</span>[0 ; 0 ; hexapod.TP.thickness<span class="org-type">+</span>hexapod.Leg.sphere.top<span class="org-type">+</span>hexapod.SP.thickness.top<span class="org-type">+</span>hexapod.jacobian]; <span class="org-comment">% [m]</span>
Aai = hexapod.pos_base(<span class="org-constant">i</span>, <span class="org-type">:</span>)<span class="org-type">'</span> <span class="org-type">+</span> 1e<span class="org-type">-</span>3<span class="org-type">*</span>[0 ; 0 ; hexapod.BP.thickness<span class="org-type">+</span>hexapod.Leg.sphere.bottom<span class="org-type">+</span>hexapod.SP.thickness.bottom<span class="org-type">-</span>hexapod.h<span class="org-type">-</span>hexapod.jacobian]; <span class="org-comment">% [m]</span>
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
L(<span class="org-constant">i</span>) = sqrt(AP<span class="org-type">'*</span>AP <span class="org-type">+</span> Bbi<span class="org-type">'*</span>Bbi <span class="org-type">+</span> Aai<span class="org-type">'*</span>Aai <span class="org-type">-</span> 2<span class="org-type">*</span>AP<span class="org-type">'*</span>Aai <span class="org-type">+</span> 2<span class="org-type">*</span>AP<span class="org-type">'*</span>(ARB<span class="org-type">*</span>Bbi) <span class="org-type">-</span> 2<span class="org-type">*</span>(ARB<span class="org-type">*</span>Bbi)<span class="org-type">'*</span>Aai);
2019-12-11 17:33:45 +01:00
<span class="org-keyword">end</span>
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
2020-01-29 20:25:59 +01:00
<div id="outline-container-orga234cde" class="outline-2">
<h2 id="orga234cde"><span class="section-number-2">5</span> computeReferencePose</h2>
<div class="outline-text-2" id="text-5">
2019-12-11 17:33:45 +01:00
<p>
2020-01-29 20:25:59 +01:00
<a id="org14a5918"></a>
2019-12-11 17:33:45 +01:00
</p>
<p>
This Matlab function is accessible <a href="src/computeReferencePose.m">here</a>.
</p>
<div class="org-src-container">
2020-01-29 20:25:59 +01:00
<pre class="src src-matlab"><span class="org-keyword">function</span> <span class="org-variable-name">[WTr]</span> = <span class="org-function-name">computeReferencePose</span>(<span class="org-variable-name">Dy</span>, <span class="org-variable-name">Ry</span>, <span class="org-variable-name">Rz</span>, <span class="org-variable-name">Dh</span>, <span class="org-variable-name">Dn</span>)
2019-12-11 17:33:45 +01:00
<span class="org-comment">% computeReferencePose - Compute the homogeneous transformation matrix corresponding to the wanted pose of the sample</span>
<span class="org-comment">%</span>
<span class="org-comment">% Syntax: [WTr] = computeReferencePose(Dy, Ry, Rz, Dh, Dn)</span>
<span class="org-comment">%</span>
<span class="org-comment">% Inputs:</span>
<span class="org-comment">% - Dy - Reference of the Translation Stage [m]</span>
<span class="org-comment">% - Ry - Reference of the Tilt Stage [rad]</span>
<span class="org-comment">% - Rz - Reference of the Spindle [rad]</span>
<span class="org-comment">% - Dh - Reference of the Micro Hexapod (Pitch, Roll, Yaw angles) [m, m, m, rad, rad, rad]</span>
<span class="org-comment">% - Dn - Reference of the Nano Hexapod [m, m, m, rad, rad, rad]</span>
<span class="org-comment">%</span>
<span class="org-comment">% Outputs:</span>
<span class="org-comment">% - WTr -</span>
<span class="org-matlab-cellbreak"><span class="org-comment">%% Translation Stage</span></span>
2020-01-29 20:25:59 +01:00
Rty = [1 0 0 0;
0 1 0 Dy;
0 0 1 0;
0 0 0 1];
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Tilt Stage - Pure rotating aligned with Ob</span></span>
2020-01-29 20:25:59 +01:00
Rry = [ 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];
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Spindle - Rotation along the Z axis</span></span>
2020-01-29 20:25:59 +01:00
Rrz = [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 ];
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Micro-Hexapod</span></span>
2020-01-29 20:25:59 +01:00
Rhx = [1 0 0;
0 cos(Dh(4)) <span class="org-type">-</span>sin(Dh(4));
0 sin(Dh(4)) cos(Dh(4))];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rhy = [ cos(Dh(5)) 0 sin(Dh(5));
0 1 0;
<span class="org-type">-</span>sin(Dh(5)) 0 cos(Dh(5))];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rhz = [cos(Dh(6)) <span class="org-type">-</span>sin(Dh(6)) 0;
sin(Dh(6)) cos(Dh(6)) 0;
0 0 1];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rh = [1 0 0 Dh(1) ;
0 1 0 Dh(2) ;
0 0 1 Dh(3) ;
0 0 0 1 ];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rh(1<span class="org-type">:</span>3, 1<span class="org-type">:</span>3) = Rhz<span class="org-type">*</span>Rhy<span class="org-type">*</span>Rhx;
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Nano-Hexapod</span></span>
2020-01-29 20:25:59 +01:00
Rnx = [1 0 0;
0 cos(Dn(4)) <span class="org-type">-</span>sin(Dn(4));
0 sin(Dn(4)) cos(Dn(4))];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rny = [ cos(Dn(5)) 0 sin(Dn(5));
0 1 0;
<span class="org-type">-</span>sin(Dn(5)) 0 cos(Dn(5))];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rnz = [cos(Dn(6)) <span class="org-type">-</span>sin(Dn(6)) 0;
sin(Dn(6)) cos(Dn(6)) 0;
0 0 1];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rn = [1 0 0 Dn(1) ;
0 1 0 Dn(2) ;
0 0 1 Dn(3) ;
0 0 0 1 ];
2019-12-11 17:33:45 +01:00
2020-01-29 20:25:59 +01:00
Rn(1<span class="org-type">:</span>3, 1<span class="org-type">:</span>3) = Rnx<span class="org-type">*</span>Rny<span class="org-type">*</span>Rnz;
2019-12-11 17:33:45 +01:00
<span class="org-matlab-cellbreak"><span class="org-comment">%% Total Homogeneous transformation</span></span>
WTr = Rty<span class="org-type">*</span>Rry<span class="org-type">*</span>Rrz<span class="org-type">*</span>Rh<span class="org-type">*</span>Rn;
<span class="org-keyword">end</span>
</pre>
</div>
</div>
</div>
2020-01-29 20:25:59 +01:00
<div id="outline-container-orgf5cf06b" class="outline-2">
<h2 id="orgf5cf06b"><span class="section-number-2">6</span> Compute the Sample Position Error w.r.t. the NASS</h2>
<div class="outline-text-2" id="text-6">
<p>
<a id="org6442eec"></a>
</p>
<p>
This Matlab function is accessible <a href="src/computeSampleError.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">[MTr]</span> = <span class="org-function-name">computeSampleError</span>(<span class="org-variable-name">WTm</span>, <span class="org-variable-name">WTr</span>)
<span class="org-comment">% computeSampleError -</span>
<span class="org-comment">%</span>
<span class="org-comment">% Syntax: [MTr] = computeSampleError(WTm, WTr)</span>
<span class="org-comment">%</span>
<span class="org-comment">% Inputs:</span>
<span class="org-comment">% - WTm - Homoegeneous transformation that represent the</span>
<span class="org-comment">% wanted pose of the sample with respect to the granite</span>
<span class="org-comment">% - WTr - Homoegeneous transformation that represent the</span>
<span class="org-comment">% measured pose of the sample with respect to the granite</span>
<span class="org-comment">%</span>
<span class="org-comment">% Outputs:</span>
<span class="org-comment">% - MTr - Homoegeneous transformation that represent the</span>
<span class="org-comment">% wanted pose of the sample expressed in a frame</span>
<span class="org-comment">% attached to the top platform of the nano-hexapod</span>
MTr = zeros(4,4);
MTr = [WTm(1<span class="org-type">:</span>3,1<span class="org-type">:</span>3)<span class="org-type">'</span>, <span class="org-type">-</span>WTm(1<span class="org-type">:</span>3,1<span class="org-type">:</span>3)<span class="org-type">'*</span>WTm(1<span class="org-type">:</span>3,4) ; 0 0 0 1]<span class="org-type">*</span>WTr;
<span class="org-keyword">end</span>
</pre>
</div>
</div>
2019-12-11 17:33:45 +01:00
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
2020-01-29 20:25:59 +01:00
<p class="date">Created: 2020-01-29 mer. 20:25</p>
2019-12-11 17:33:45 +01:00
</div>
</body>
</html>