stewart-simscape/simscape-model.html

1058 lines
60 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!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>
<!-- 2019-03-25 lun. 11:18 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Stewart Platform - Simscape Model</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Thomas Dehaeze" />
<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"/>
<script src="js/jquery.min.js"></script>
<script 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.
Copyright (C) 2012-2019 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.
*/
<!--/*--><![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>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="content">
<h1 class="title">Stewart Platform - Simscape Model</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org527cc13">1. initializeGeneralConfiguration</a>
<ul>
<li><a href="#orgea5f8f5">1.1. Function description</a></li>
<li><a href="#org2db42cb">1.2. Optional Parameters</a></li>
<li><a href="#org2f9279a">1.3. Geometry Description</a></li>
<li><a href="#org1409cf0">1.4. Compute Aa and Ab</a></li>
<li><a href="#orgb91c416">1.5. Returns Stewart Structure</a></li>
</ul>
</li>
<li><a href="#orgc3aa910">2. computeGeometricalProperties</a>
<ul>
<li><a href="#org180196f">2.1. Function description</a></li>
<li><a href="#org12cee4f">2.2. Optional Parameters</a></li>
<li><a href="#org0010af5">2.3. Rotation matrices</a></li>
<li><a href="#org98f4bad">2.4. Jacobian matrices</a></li>
</ul>
</li>
<li><a href="#orgb3e53d1">3. initializeMechanicalElements</a>
<ul>
<li><a href="#orge7f185e">3.1. Function description</a></li>
<li><a href="#org6bd219d">3.2. Optional Parameters</a></li>
<li><a href="#org8d0d9c0">3.3. Bottom Plate</a></li>
<li><a href="#org23fd88c">3.4. Top Plate</a></li>
<li><a href="#org96d7dab">3.5. Legs</a></li>
<li><a href="#org66df86f">3.6. Ball Joints</a></li>
</ul>
</li>
<li><a href="#orgf3c4474">4. initializeSample</a>
<ul>
<li><a href="#org1ec4152">4.1. Function description</a></li>
<li><a href="#orgcd3268d">4.2. Optional Parameters</a></li>
<li><a href="#org29ee9ed">4.3. Save the Sample structure</a></li>
</ul>
</li>
</ul>
</div>
</div>
<p>
Stewart platforms are generated in multiple steps.
</p>
<p>
First, geometrical parameters are defined:
</p>
<ul class="org-ul">
<li>\({}^Aa_i\) - Position of the joints fixed to the fixed base w.r.t \(\{A\}\)</li>
<li>\({}^Ab_i\) - Position of the joints fixed to the mobile platform w.r.t \(\{A\}\)</li>
<li>\({}^Bb_i\) - Position of the joints fixed to the mobile platform w.r.t \(\{B\}\)</li>
<li>\(H\) - Total height of the mobile platform</li>
</ul>
<p>
These parameter are enough to determine all the kinematic properties of the platform like the Jacobian, stroke, stiffness, &#x2026;
These geometrical parameters can be generated using different functions: <code>initializeCubicConfiguration</code> for cubic configuration or <code>initializeGeneralConfiguration</code> for more general configuration.
</p>
<p>
A function <code>computeGeometricalProperties</code> is then used to compute:
</p>
<ul class="org-ul">
<li>\(J_f\) - Jacobian matrix for the force location</li>
<li>\(J_d\) - Jacobian matrix for displacement estimation</li>
<li>\(R_m\) - Rotation matrices to position the leg vectors</li>
</ul>
<p>
Then, geometrical parameters are computed for all the mechanical elements with the function <code>initializeMechanicalElements</code>:
</p>
<ul class="org-ul">
<li>Shape of the platforms
<ul class="org-ul">
<li>External Radius</li>
<li>Internal Radius</li>
<li>Density</li>
<li>Thickness</li>
</ul></li>
<li>Shape of the Legs
<ul class="org-ul">
<li>Radius</li>
<li>Size of ball joint</li>
<li>Density</li>
</ul></li>
</ul>
<p>
Other Parameters are defined for the Simscape simulation:
</p>
<ul class="org-ul">
<li>Sample mass, volume and position (<code>initializeSample</code> function)</li>
<li>Location of the inertial sensor</li>
<li>Location of the point for the differential measurements</li>
<li>Location of the Jacobian point for velocity/displacement computation</li>
</ul>
<div id="outline-container-org527cc13" class="outline-2">
<h2 id="org527cc13"><span class="section-number-2">1</span> initializeGeneralConfiguration</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-orgea5f8f5" class="outline-3">
<h3 id="orgea5f8f5"><span class="section-number-3">1.1</span> Function description</h3>
<div class="outline-text-3" id="text-1-1">
<p>
The <code>initializeGeneralConfiguration</code> function takes one structure that contains configurations for the hexapod and returns one structure representing the Hexapod.
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #DCDCCC;">[</span><span style="color: #DFAF8F;">stewart</span><span style="color: #DCDCCC;">]</span> = <span style="color: #93E0E3;">initializeGeneralConfiguration</span><span style="color: #DCDCCC;">(</span><span style="color: #DFAF8F;">opts_param</span><span style="color: #DCDCCC;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org2db42cb" class="outline-3">
<h3 id="org2db42cb"><span class="section-number-3">1.2</span> Optional Parameters</h3>
<div class="outline-text-3" id="text-1-2">
<p>
Default values for opts.
</p>
<div class="org-src-container">
<pre class="src src-matlab">opts = struct<span style="color: #DCDCCC;">(</span><span style="text-decoration: underline;">...</span>
<span style="color: #CC9393;">'H_tot'</span>, <span style="color: #BFEBBF;">90</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Height of the platform [mm]</span>
<span style="color: #CC9393;">'H_joint'</span>, <span style="color: #BFEBBF;">15</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Height of the joints [mm]</span>
<span style="color: #CC9393;">'H_plate'</span>, <span style="color: #BFEBBF;">10</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Thickness of the fixed and mobile platforms [mm]</span>
<span style="color: #CC9393;">'R_bot'</span>, <span style="color: #BFEBBF;">100</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Radius where the legs articulations are positionned [mm]</span>
<span style="color: #CC9393;">'R_top'</span>, <span style="color: #BFEBBF;">80</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Radius where the legs articulations are positionned [mm]</span>
<span style="color: #CC9393;">'a_bot'</span>, <span style="color: #BFEBBF;">10</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Angle Offset [deg]</span>
<span style="color: #CC9393;">'a_top'</span>, <span style="color: #BFEBBF;">40</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Angle Offset [deg]</span>
<span style="color: #CC9393;">'da_top'</span>, <span style="color: #BFEBBF;">0</span> <span style="text-decoration: underline;">...</span> % Angle Offset from <span style="color: #BFEBBF;">0</span> position [deg]
<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<p>
Populate opts with input parameters
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">if</span> exist<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'opts_param','var'</span><span style="color: #DCDCCC;">)</span>
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">opt</span> = <span style="color: #BFEBBF;">fieldnames</span><span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">opts_param</span><span style="color: #DCDCCC;">)</span><span style="color: #BFEBBF;">'</span>
opts.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span> = opts_param.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org2f9279a" class="outline-3">
<h3 id="org2f9279a"><span class="section-number-3">1.3</span> Geometry Description</h3>
<div class="outline-text-3" id="text-1-3">
<div id="orgc30ce24" class="figure">
<p><img src="./figs/stewart_bottom_plate.png" alt="stewart_bottom_plate.png" />
</p>
<p><span class="figure-number">Figure 1: </span>Schematic of the bottom plates with all the parameters</p>
</div>
</div>
</div>
<div id="outline-container-org1409cf0" class="outline-3">
<h3 id="org1409cf0"><span class="section-number-3">1.4</span> Compute Aa and Ab</h3>
<div class="outline-text-3" id="text-1-4">
<p>
We 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\).
</p>
<div class="org-src-container">
<pre class="src src-matlab">Aa = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span>, <span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span>; <span style="color: #7F9F7F;">% [mm]</span>
Ab = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span>, <span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span>; <span style="color: #7F9F7F;">% [mm]</span>
Bb = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span>, <span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span>; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">i</span> = <span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">:</span><span style="color: #BFEBBF;">3</span>
Aa<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> = <span style="color: #DCDCCC;">[</span>opts.R_bot<span style="color: #7CB8BB;">*</span>cos<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">-</span> opts.a_bot<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.R_bot<span style="color: #7CB8BB;">*</span>sin<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">-</span> opts.a_bot<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.H_plate<span style="color: #7CB8BB;">+</span>opts.H_joint<span style="color: #DCDCCC;">]</span>;
Aa<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> = <span style="color: #DCDCCC;">[</span>opts.R_bot<span style="color: #7CB8BB;">*</span>cos<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.a_bot<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.R_bot<span style="color: #7CB8BB;">*</span>sin<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.a_bot<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.H_plate<span style="color: #7CB8BB;">+</span>opts.H_joint<span style="color: #DCDCCC;">]</span>;
Ab<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> = <span style="color: #DCDCCC;">[</span>opts.R_top<span style="color: #7CB8BB;">*</span>cos<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.da_top <span style="color: #7CB8BB;">-</span> opts.a_top<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.R_top<span style="color: #7CB8BB;">*</span>sin<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.da_top <span style="color: #7CB8BB;">-</span> opts.a_top<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.H_tot <span style="color: #7CB8BB;">-</span> opts.H_plate <span style="color: #7CB8BB;">-</span> opts.H_joint<span style="color: #DCDCCC;">]</span>;
Ab<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> = <span style="color: #DCDCCC;">[</span>opts.R_top<span style="color: #7CB8BB;">*</span>cos<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.da_top <span style="color: #7CB8BB;">+</span> opts.a_top<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.R_top<span style="color: #7CB8BB;">*</span>sin<span style="color: #BFEBBF;">(</span> <span style="color: #BFEBBF;">pi</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">180</span><span style="color: #7CB8BB;">*</span><span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">120</span><span style="color: #7CB8BB;">*</span><span style="color: #93E0E3;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">1</span><span style="color: #93E0E3;">)</span> <span style="color: #7CB8BB;">+</span> opts.da_top <span style="color: #7CB8BB;">+</span> opts.a_top<span style="color: #D0BF8F;">)</span> <span style="color: #BFEBBF;">)</span>, <span style="text-decoration: underline;">...</span>
opts.H_tot <span style="color: #7CB8BB;">-</span> opts.H_plate <span style="color: #7CB8BB;">-</span> opts.H_joint<span style="color: #DCDCCC;">]</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
Bb = Ab <span style="color: #7CB8BB;">-</span> opts.H_tot<span style="color: #7CB8BB;">*</span><span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span>,<span style="color: #BFEBBF;">0</span>,<span style="color: #BFEBBF;">1</span><span style="color: #DCDCCC;">]</span>;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgb91c416" class="outline-3">
<h3 id="orgb91c416"><span class="section-number-3">1.5</span> Returns Stewart Structure</h3>
<div class="outline-text-3" id="text-1-5">
<div class="org-src-container">
<pre class="src src-matlab"> stewart = struct<span style="color: #DCDCCC;">()</span>;
stewart.Aa = Aa;
stewart.Ab = Ab;
stewart.Bb = Bb;
stewart.H_tot = opts.H_tot;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgc3aa910" class="outline-2">
<h2 id="orgc3aa910"><span class="section-number-2">2</span> computeGeometricalProperties</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-org180196f" class="outline-3">
<h3 id="org180196f"><span class="section-number-3">2.1</span> Function description</h3>
<div class="outline-text-3" id="text-2-1">
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #DCDCCC;">[</span><span style="color: #DFAF8F;">stewart</span><span style="color: #DCDCCC;">]</span> = <span style="color: #93E0E3;">computeGeometricalProperties</span><span style="color: #DCDCCC;">(</span><span style="color: #DFAF8F;">stewart</span>, <span style="color: #DFAF8F;">opts_param</span><span style="color: #DCDCCC;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org12cee4f" class="outline-3">
<h3 id="org12cee4f"><span class="section-number-3">2.2</span> Optional Parameters</h3>
<div class="outline-text-3" id="text-2-2">
<p>
Default values for opts.
</p>
<div class="org-src-container">
<pre class="src src-matlab">opts = struct<span style="color: #DCDCCC;">(</span><span style="text-decoration: underline;">...</span>
<span style="color: #CC9393;">'Jd_pos'</span>, <span style="color: #BFEBBF;">[</span><span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">30</span><span style="color: #BFEBBF;">]</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Position of the Jacobian for displacement estimation from the top of the mobile platform [mm]</span>
<span style="color: #CC9393;">'Jf_pos'</span>, <span style="color: #BFEBBF;">[</span><span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">30</span><span style="color: #BFEBBF;">]</span> <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Position of the Jacobian for force location from the top of the mobile platform [mm]</span>
<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<p>
Populate opts with input parameters
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">if</span> exist<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'opts_param','var'</span><span style="color: #DCDCCC;">)</span>
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">opt</span> = <span style="color: #BFEBBF;">fieldnames</span><span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">opts_param</span><span style="color: #DCDCCC;">)</span><span style="color: #BFEBBF;">'</span>
opts.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span> = opts_param.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org0010af5" class="outline-3">
<h3 id="org0010af5"><span class="section-number-3">2.3</span> Rotation matrices</h3>
<div class="outline-text-3" id="text-2-3">
<p>
We initialize \(l_i\) and \(\hat{s}_i\)
</p>
<div class="org-src-container">
<pre class="src src-matlab">leg_length = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span>, <span style="color: #BFEBBF;">1</span><span style="color: #DCDCCC;">)</span>; <span style="color: #7F9F7F;">% [mm]</span>
leg_vectors = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span>, <span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<p>
We compute \(b_i - a_i\), and then:
</p>
\begin{align*}
l_i &= \left|b_i - a_i\right| \\
\hat{s}_i &= \frac{b_i - a_i}{l_i}
\end{align*}
<div class="org-src-container">
<pre class="src src-matlab">legs = stewart.Ab <span style="color: #7CB8BB;">-</span> stewart.Aa;
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">i</span> = <span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">:</span><span style="color: #BFEBBF;">6</span>
leg_length<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #DCDCCC;">)</span> = norm<span style="color: #DCDCCC;">(</span>legs<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span>;
leg_vectors<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> = legs<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span> <span style="color: #7CB8BB;">/</span> leg_length<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
<p>
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.
</p>
<div class="org-src-container">
<pre class="src src-matlab">stewart.Rm = struct<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'R'</span>, eye<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">3</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">i</span> = <span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">:</span><span style="color: #BFEBBF;">6</span>
sx = cross<span style="color: #DCDCCC;">(</span>leg_vectors<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span>, <span style="color: #BFEBBF;">[</span><span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">0</span> <span style="color: #BFEBBF;">0</span><span style="color: #BFEBBF;">]</span><span style="color: #DCDCCC;">)</span>;
sx = sx<span style="color: #7CB8BB;">/</span>norm<span style="color: #DCDCCC;">(</span>sx<span style="color: #DCDCCC;">)</span>;
sy = <span style="color: #7CB8BB;">-</span>cross<span style="color: #DCDCCC;">(</span>sx, leg_vectors<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span>;
sy = sy<span style="color: #7CB8BB;">/</span>norm<span style="color: #DCDCCC;">(</span>sy<span style="color: #DCDCCC;">)</span>;
sz = leg_vectors<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>,<span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span>;
sz = sz<span style="color: #7CB8BB;">/</span>norm<span style="color: #DCDCCC;">(</span>sz<span style="color: #DCDCCC;">)</span>;
stewart.Rm<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span><span style="color: #DCDCCC;">)</span>.R = <span style="color: #DCDCCC;">[</span>sx', sy', sz'<span style="color: #DCDCCC;">]</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org98f4bad" class="outline-3">
<h3 id="org98f4bad"><span class="section-number-3">2.4</span> Jacobian matrices</h3>
<div class="outline-text-3" id="text-2-4">
<p>
Compute Jacobian Matrix
</p>
<div class="org-src-container">
<pre class="src src-matlab">Jd = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">i</span> = <span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">:</span><span style="color: #BFEBBF;">6</span>
Jd<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #BFEBBF;">1</span><span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span> = leg_vectors<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span>;
Jd<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #BFEBBF;">4</span><span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">6</span><span style="color: #DCDCCC;">)</span> = cross<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">001</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">(</span>stewart.Bb<span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #D0BF8F;">)</span> <span style="color: #7CB8BB;">-</span> opts.Jd_pos<span style="color: #BFEBBF;">)</span>, leg_vectors<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
stewart.Jd = Jd;
stewart.Jd_inv = inv<span style="color: #DCDCCC;">(</span>Jd<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">Jf = zeros<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">6</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">i</span> = <span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">:</span><span style="color: #BFEBBF;">6</span>
Jf<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #BFEBBF;">1</span><span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span> = leg_vectors<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #DCDCCC;">)</span>;
Jf<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #BFEBBF;">4</span><span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">6</span><span style="color: #DCDCCC;">)</span> = cross<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">001</span><span style="color: #7CB8BB;">*</span><span style="color: #BFEBBF;">(</span>stewart.Bb<span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #D0BF8F;">)</span> <span style="color: #7CB8BB;">-</span> opts.Jf_pos<span style="color: #BFEBBF;">)</span>, leg_vectors<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">i</span>, <span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
stewart.Jf = Jf;
stewart.Jf_inv = inv<span style="color: #DCDCCC;">(</span>Jf<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgb3e53d1" class="outline-2">
<h2 id="orgb3e53d1"><span class="section-number-2">3</span> initializeMechanicalElements</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-orge7f185e" class="outline-3">
<h3 id="orge7f185e"><span class="section-number-3">3.1</span> Function description</h3>
<div class="outline-text-3" id="text-3-1">
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #DCDCCC;">[</span><span style="color: #DFAF8F;">stewart</span><span style="color: #DCDCCC;">]</span> = <span style="color: #93E0E3;">initializeMechanicalElements</span><span style="color: #DCDCCC;">(</span><span style="color: #DFAF8F;">stewart</span>, <span style="color: #DFAF8F;">opts_param</span><span style="color: #DCDCCC;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org6bd219d" class="outline-3">
<h3 id="org6bd219d"><span class="section-number-3">3.2</span> Optional Parameters</h3>
<div class="outline-text-3" id="text-3-2">
<p>
Default values for opts.
</p>
<div class="org-src-container">
<pre class="src src-matlab">opts = struct<span style="color: #DCDCCC;">(</span><span style="text-decoration: underline;">...</span>
<span style="color: #CC9393;">'thickness'</span>, <span style="color: #BFEBBF;">10</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Thickness of the base and platform [mm]</span>
<span style="color: #CC9393;">'density'</span>, <span style="color: #BFEBBF;">1000</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Density of the material used for the hexapod [kg/m3]</span>
<span style="color: #CC9393;">'k_ax'</span>, <span style="color: #BFEBBF;">1e8</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Stiffness of each actuator [N/m]</span>
<span style="color: #CC9393;">'c_ax'</span>, <span style="color: #BFEBBF;">1000</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Damping of each actuator [N/(m/s)]</span>
<span style="color: #CC9393;">'stroke'</span>, <span style="color: #BFEBBF;">50e</span><span style="color: #7CB8BB;">-</span><span style="color: #BFEBBF;">6</span> <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% Maximum stroke of each actuator [m]</span>
<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<p>
Populate opts with input parameters
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">if</span> exist<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'opts_param','var'</span><span style="color: #DCDCCC;">)</span>
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">opt</span> = <span style="color: #BFEBBF;">fieldnames</span><span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">opts_param</span><span style="color: #DCDCCC;">)</span><span style="color: #BFEBBF;">'</span>
opts.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span> = opts_param.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org8d0d9c0" class="outline-3">
<h3 id="org8d0d9c0"><span class="section-number-3">3.3</span> Bottom Plate</h3>
<div class="outline-text-3" id="text-3-3">
<div id="org38598b1" class="figure">
<p><img src="./figs/stewart_bottom_plate.png" alt="stewart_bottom_plate.png" />
</p>
<p><span class="figure-number">Figure 2: </span>Schematic of the bottom plates with all the parameters</p>
</div>
<p>
The bottom plate structure is initialized.
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP = struct<span style="color: #DCDCCC;">()</span>;
</pre>
</div>
<p>
We defined its internal radius (if there is a hole in the bottom plate) and its outer radius.
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP.Rint = <span style="color: #BFEBBF;">0</span>; <span style="color: #7F9F7F;">% Internal Radius [mm]</span>
BP.Rext = <span style="color: #BFEBBF;">150</span>; <span style="color: #7F9F7F;">% External Radius [mm]</span>
</pre>
</div>
<p>
We define its thickness.
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP.H = opts.thickness; <span style="color: #7F9F7F;">% Thickness of the Bottom Plate [mm]</span>
</pre>
</div>
<p>
We defined the density of the material of the bottom plate.
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP.density = opts.density; <span style="color: #7F9F7F;">% Density of the material [kg/m3]</span>
</pre>
</div>
<p>
And its color.
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP.color = <span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span><span style="color: #DCDCCC;">]</span>; <span style="color: #7F9F7F;">% Color [RGB]</span>
</pre>
</div>
<p>
Then the profile of the bottom plate is computed and will be used by Simscape
</p>
<div class="org-src-container">
<pre class="src src-matlab">BP.shape = <span style="color: #DCDCCC;">[</span>BP.Rint BP.H; BP.Rint <span style="color: #BFEBBF;">0</span>; BP.Rext <span style="color: #BFEBBF;">0</span>; BP.Rext BP.H<span style="color: #DCDCCC;">]</span>; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<p>
The structure is added to the stewart structure
</p>
<div class="org-src-container">
<pre class="src src-matlab">stewart.BP = BP;
</pre>
</div>
</div>
</div>
<div id="outline-container-org23fd88c" class="outline-3">
<h3 id="org23fd88c"><span class="section-number-3">3.4</span> Top Plate</h3>
<div class="outline-text-3" id="text-3-4">
<p>
The top plate structure is initialized.
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP = struct<span style="color: #DCDCCC;">()</span>;
</pre>
</div>
<p>
We defined the internal and external radius of the top plate.
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP.Rint = <span style="color: #BFEBBF;">0</span>; <span style="color: #7F9F7F;">% [mm]</span>
TP.Rext = <span style="color: #BFEBBF;">100</span>; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<p>
The thickness of the top plate.
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP.H = <span style="color: #BFEBBF;">10</span>; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<p>
The density of its material.
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP.density = opts.density; <span style="color: #7F9F7F;">% Density of the material [kg/m3]</span>
</pre>
</div>
<p>
Its color.
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP.color = <span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span><span style="color: #DCDCCC;">]</span>; <span style="color: #7F9F7F;">% Color [RGB]</span>
</pre>
</div>
<p>
Then the shape of the top plate is computed
</p>
<div class="org-src-container">
<pre class="src src-matlab">TP.shape = <span style="color: #DCDCCC;">[</span>TP.Rint TP.H; TP.Rint <span style="color: #BFEBBF;">0</span>; TP.Rext <span style="color: #BFEBBF;">0</span>; TP.Rext TP.H<span style="color: #DCDCCC;">]</span>;
</pre>
</div>
<p>
The structure is added to the stewart structure
</p>
<div class="org-src-container">
<pre class="src src-matlab">stewart.TP = TP;
</pre>
</div>
</div>
</div>
<div id="outline-container-org96d7dab" class="outline-3">
<h3 id="org96d7dab"><span class="section-number-3">3.5</span> Legs</h3>
<div class="outline-text-3" id="text-3-5">
<div id="orga9ade83" class="figure">
<p><img src="./figs/stewart_legs.png" alt="stewart_legs.png" />
</p>
<p><span class="figure-number">Figure 3: </span>Schematic for the legs of the Stewart platform</p>
</div>
<p>
The leg structure is initialized.
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg = struct<span style="color: #DCDCCC;">()</span>;
</pre>
</div>
<p>
The maximum Stroke of each leg is defined.
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.stroke = opts.stroke; <span style="color: #7F9F7F;">% [m]</span>
</pre>
</div>
<p>
The stiffness and damping of each leg are defined
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.k_ax = opts.k_ax; <span style="color: #7F9F7F;">% Stiffness of each leg [N/m]</span>
Leg.c_ax = opts.c_ax; <span style="color: #7F9F7F;">% Damping of each leg [N/(m/s)]</span>
</pre>
</div>
<p>
The radius of the legs are defined
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.Rtop = <span style="color: #BFEBBF;">10</span>; <span style="color: #7F9F7F;">% Radius of the cylinder of the top part of the leg[mm]</span>
Leg.Rbot = <span style="color: #BFEBBF;">12</span>; <span style="color: #7F9F7F;">% Radius of the cylinder of the bottom part of the leg [mm]</span>
</pre>
</div>
<p>
The density of its material.
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.density = opts.density; <span style="color: #7F9F7F;">% Density of the material used for the legs [kg/m3]</span>
</pre>
</div>
<p>
Its color.
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.color = <span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">5</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">5</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">5</span><span style="color: #DCDCCC;">]</span>; <span style="color: #7F9F7F;">% Color of the top part of the leg [RGB]</span>
</pre>
</div>
<p>
The radius of spheres representing the ball joints are defined.
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.R = <span style="color: #BFEBBF;">1</span>.<span style="color: #BFEBBF;">3</span><span style="color: #7CB8BB;">*</span>Leg.Rbot; <span style="color: #7F9F7F;">% Size of the sphere at the extremity of the leg [mm]</span>
</pre>
</div>
<p>
We estimate the length of the legs.
</p>
<div class="org-src-container">
<pre class="src src-matlab">legs = stewart.Ab <span style="color: #7CB8BB;">-</span> stewart.Aa;
Leg.lenght = norm<span style="color: #DCDCCC;">(</span>legs<span style="color: #BFEBBF;">(</span><span style="color: #BFEBBF;">1</span>,<span style="color: #7CB8BB;">:</span><span style="color: #BFEBBF;">)</span><span style="color: #DCDCCC;">)</span><span style="color: #7CB8BB;">/</span><span style="color: #BFEBBF;">1</span>.<span style="color: #BFEBBF;">5</span>;
</pre>
</div>
<p>
Then the shape of the bottom leg is estimated
</p>
<div class="org-src-container">
<pre class="src src-matlab">Leg.shape.bot = <span style="text-decoration: underline;">...</span>
<span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span> <span style="color: #BFEBBF;">0</span>; <span style="text-decoration: underline;">...</span>
Leg.Rbot <span style="color: #BFEBBF;">0</span>; <span style="text-decoration: underline;">...</span>
Leg.Rbot Leg.lenght; <span style="text-decoration: underline;">...</span>
Leg.Rtop Leg.lenght; <span style="text-decoration: underline;">...</span>
Leg.Rtop <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span>Leg.lenght; <span style="text-decoration: underline;">...</span>
<span style="color: #BFEBBF;">0</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">2</span><span style="color: #7CB8BB;">*</span>Leg.lenght<span style="color: #DCDCCC;">]</span>;
</pre>
</div>
<p>
The structure is added to the stewart structure
</p>
<div class="org-src-container">
<pre class="src src-matlab">stewart.Leg = Leg;
</pre>
</div>
</div>
</div>
<div id="outline-container-org66df86f" class="outline-3">
<h3 id="org66df86f"><span class="section-number-3">3.6</span> Ball Joints</h3>
<div class="outline-text-3" id="text-3-6">
<div id="org250b20b" class="figure">
<p><img src="./figs/stewart_ball_joints.png" alt="stewart_ball_joints.png" />
</p>
<p><span class="figure-number">Figure 4: </span>Schematic of the support for the ball joints</p>
</div>
<p>
<code>SP</code> is the structure representing the support for the ball joints at the extremity of each leg.
</p>
<p>
The <code>SP</code> structure is initialized.
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP = struct<span style="color: #DCDCCC;">()</span>;
</pre>
</div>
<p>
We can define its rotational stiffness and damping. For now, we use perfect joints.
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP.k = <span style="color: #BFEBBF;">0</span>; <span style="color: #7F9F7F;">% [N*m/deg]</span>
SP.c = <span style="color: #BFEBBF;">0</span>; <span style="color: #7F9F7F;">% [N*m/deg]</span>
</pre>
</div>
<p>
Its height is defined
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP.H = stewart.Aa<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">1</span>, <span style="color: #BFEBBF;">3</span><span style="color: #DCDCCC;">)</span> <span style="color: #7CB8BB;">-</span> BP.H; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<p>
Its radius is based on the radius on the sphere at the end of the legs.
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP.R = Leg.R; <span style="color: #7F9F7F;">% [mm]</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">SP.section = <span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span> SP.H<span style="color: #7CB8BB;">-</span>SP.R;
<span style="color: #BFEBBF;">0</span> <span style="color: #BFEBBF;">0</span>;
SP.R <span style="color: #BFEBBF;">0</span>;
SP.R SP.H<span style="color: #DCDCCC;">]</span>;
</pre>
</div>
<p>
The density of its material is defined.
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP.density = opts.density; % [kg<span style="color: #7CB8BB;">/</span>m<span style="color: #7CB8BB;">^</span><span style="color: #BFEBBF;">3</span>]
</pre>
</div>
<p>
Its color is defined.
</p>
<div class="org-src-container">
<pre class="src src-matlab">SP.color = <span style="color: #DCDCCC;">[</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">7</span><span style="color: #DCDCCC;">]</span>; <span style="color: #7F9F7F;">% [RGB]</span>
</pre>
</div>
<p>
The structure is added to the Hexapod structure
</p>
<div class="org-src-container">
<pre class="src src-matlab">stewart.SP = SP;
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf3c4474" class="outline-2">
<h2 id="orgf3c4474"><span class="section-number-2">4</span> initializeSample</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-org1ec4152" class="outline-3">
<h3 id="org1ec4152"><span class="section-number-3">4.1</span> Function description</h3>
<div class="outline-text-3" id="text-4-1">
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #DCDCCC;">[]</span> = <span style="color: #93E0E3;">initializeSample</span><span style="color: #DCDCCC;">(</span><span style="color: #DFAF8F;">opts_param</span><span style="color: #DCDCCC;">)</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-orgcd3268d" class="outline-3">
<h3 id="orgcd3268d"><span class="section-number-3">4.2</span> Optional Parameters</h3>
<div class="outline-text-3" id="text-4-2">
<p>
Default values for opts.
</p>
<div class="org-src-container">
<pre class="src src-matlab">sample = struct<span style="color: #DCDCCC;">(</span> <span style="text-decoration: underline;">...</span>
<span style="color: #CC9393;">'radius'</span>, <span style="color: #BFEBBF;">100</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% radius of the cylinder [mm]</span>
<span style="color: #CC9393;">'height'</span>, <span style="color: #BFEBBF;">100</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% height of the cylinder [mm]</span>
<span style="color: #CC9393;">'mass'</span>, <span style="color: #BFEBBF;">10</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% mass of the cylinder [kg]</span>
<span style="color: #CC9393;">'measheight'</span>, <span style="color: #BFEBBF;">50</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% measurement point z-offset [mm]</span>
<span style="color: #CC9393;">'offset'</span>, <span style="color: #BFEBBF;">[</span><span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">0</span>, <span style="color: #BFEBBF;">0</span><span style="color: #BFEBBF;">]</span>, <span style="text-decoration: underline;">...</span> <span style="color: #7F9F7F;">% offset position of the sample [mm]</span>
<span style="color: #CC9393;">'color'</span>, <span style="color: #BFEBBF;">[</span><span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">9</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">0</span>.<span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">]</span> <span style="text-decoration: underline;">...</span>
<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<p>
Populate opts with input parameters
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">if</span> exist<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'opts_param','var'</span><span style="color: #DCDCCC;">)</span>
<span style="color: #F0DFAF; font-weight: bold;">for</span> <span style="color: #DFAF8F;">opt</span> = <span style="color: #BFEBBF;">fieldnames</span><span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">opts_param</span><span style="color: #DCDCCC;">)</span><span style="color: #BFEBBF;">'</span>
sample.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span> = opts_param.<span style="color: #DCDCCC;">(</span>opt<span style="color: #BFEBBF;">{</span><span style="color: #BFEBBF;">1</span><span style="color: #BFEBBF;">}</span><span style="color: #DCDCCC;">)</span>;
<span style="color: #F0DFAF; font-weight: bold;">end</span>
<span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org29ee9ed" class="outline-3">
<h3 id="org29ee9ed"><span class="section-number-3">4.3</span> Save the Sample structure</h3>
<div class="outline-text-3" id="text-4-3">
<div class="org-src-container">
<pre class="src src-matlab">save<span style="color: #DCDCCC;">(</span><span style="color: #CC9393;">'./mat/sample.mat', 'sample'</span><span style="color: #DCDCCC;">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span style="color: #F0DFAF; font-weight: bold;">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Thomas Dehaeze</p>
<p class="date">Created: 2019-03-25 lun. 11:18</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>