simscape-gravity/index.html

304 lines
11 KiB
HTML
Raw Permalink Normal View History

2020-01-30 15:10:45 +01:00
<?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>
2020-11-12 10:22:15 +01:00
<!-- 2020-11-12 jeu. 10:22 -->
2020-01-30 15:10:45 +01:00
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Gravity with Simscape Models</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
2020-11-12 10:22:15 +01:00
<link rel="stylesheet" type="text/css" href="https://research.tdehaeze.xyz/css/style.css"/>
<script type="text/javascript" src="https://research.tdehaeze.xyz/js/script.js"></script>
2020-11-12 08:53:16 +01:00
<script>MathJax = {
tex: {
tags: 'ams',
macros: {bm: ["\\boldsymbol{#1}",1],}
2020-01-30 15:10:45 +01:00
}
2020-11-12 08:53:16 +01:00
};
</script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
2020-01-30 15:10:45 +01:00
</head>
<body>
<div id="org-div-home-and-up">
2020-11-12 08:53:16 +01:00
<a accesskey="h" href="../index.html"> UP </a>
2020-01-30 15:10:45 +01:00
|
2020-11-12 08:53:16 +01:00
<a accesskey="H" href="../index.html"> HOME </a>
2020-01-30 15:10:45 +01:00
</div><div id="content">
<h1 class="title">Gravity with Simscape Models</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
2020-11-12 10:22:15 +01:00
<li><a href="#orgab8a471">1. Simulink</a></li>
<li><a href="#org4c54ff6">2. Initial Simulation</a></li>
<li><a href="#org24fe46e">3. Change the equilibrium position</a></li>
<li><a href="#orgeb66e34">4. Add external force</a></li>
<li><a href="#org7707124">5. Change initial position</a></li>
<li><a href="#org923fa38">6. Conclusion</a></li>
2020-01-30 15:10:45 +01:00
</ul>
</div>
</div>
<p>
We would like to include gravity in a Simscape multi-body model while starting the simulation at the equilibrium.
</p>
<p>
The basic idea is to first perform a simulation of the system until it goes at it rest position and save the rest position forces and deflection in each joint.
</p>
<p>
We can then think of three solutions to start a new simulation directly at the steady state position:
</p>
<ul class="org-ul">
<li>Change the equilibrium position \(l_0\) of each joint such that at \(t=0\), \(k \times l_0\) is equal to the previously measured force in the joint.
Here, it is suppose that we constrain the initial position of the joint to be equal to zero.
Then, these forces cancel each other and the simulation starts at equilibrium.</li>
<li>Add an External force (or maybe the &ldquo;Internal Force&rdquo;) in the direction of the joint (the &ldquo;resolution frame&rdquo; is fixed to the solids) equal to the opposite of the previously measured force.</li>
<li>After the first simulation, measure the final change of position of each joint, then set the initial position to be the measured static position.
Then, the simulation will start at equilibrium, but all the elements will be &ldquo;deflected&rdquo;.</li>
</ul>
<p>
The three solutions are tested below.
</p>
2020-11-12 10:22:15 +01:00
<div id="outline-container-orgab8a471" class="outline-2">
<h2 id="orgab8a471"><span class="section-number-2">1</span> Simulink</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-1">
<div class="org-src-container">
<pre class="src src-matlab">open <span class="org-string">'gravity_test.slx'</span>
</pre>
</div>
2020-11-12 10:22:15 +01:00
<div id="orgddd05eb" class="figure">
2020-01-30 15:10:45 +01:00
<p><img src="figs/simscape_model.png" alt="simscape_model.png" />
</p>
<p><span class="figure-number">Figure 1: </span>Simscape model used for the simulations</p>
</div>
</div>
</div>
2020-11-12 10:22:15 +01:00
<div id="outline-container-org4c54ff6" class="outline-2">
<h2 id="org4c54ff6"><span class="section-number-2">2</span> Initial Simulation</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-2">
<div class="org-src-container">
<pre class="src src-matlab">g = <span class="org-type">-</span>10; <span class="org-comment">% [m/s^2]</span>
k = 1e3; <span class="org-comment">% Stiffness [N/m]</span>
c = 10; <span class="org-comment">% Damping [N/(m/s)]</span>
l0 = 0; <span class="org-comment">% Initial wanted position [m]</span>
leq = 0; <span class="org-comment">% equilibrium position [m]</span>
F_ext = 0; <span class="org-comment">% External force [N]</span>
F_act = 0; <span class="org-comment">% Actuator force [N]</span>
</pre>
</div>
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab">out_init = <span class="org-matlab-simulink-keyword">sim</span>(<span class="org-string">'gravity_test.slx'</span>)
out_init.d.Name = <span class="org-string">'Displacement'</span>;
out_init.Fm.Name = <span class="org-string">'Force Sensor'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
subplot(1,2,1)
plot(out_init.d)
title(<span class="org-string">''</span>);
subplot(1,2,2)
plot(out_init.Fm)
title(<span class="org-string">''</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">&lt;&lt;</span>plt<span class="org-type">-</span>matlab<span class="org-type">&gt;&gt;</span>
</pre>
</div>
2020-01-30 15:10:45 +01:00
2020-11-12 10:22:15 +01:00
<div id="orge745105" class="figure">
2020-01-30 15:10:45 +01:00
<p><img src="figs/sim_init.png" alt="sim_init.png" />
</p>
<p><span class="figure-number">Figure 2: </span>Initial Simulation (<a href="./figs/sim_init.png">png</a>, <a href="./figs/sim_init.pdf">pdf</a>)</p>
</div>
</div>
</div>
2020-11-12 10:22:15 +01:00
<div id="outline-container-org24fe46e" class="outline-2">
<h2 id="org24fe46e"><span class="section-number-2">3</span> Change the equilibrium position</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-3">
<div class="org-src-container">
<pre class="src src-matlab">l0 = 0; <span class="org-comment">% Initial wanted position [m]</span>
leq = <span class="org-type">-</span>out_init.Fm.Data(end)<span class="org-type">/</span>k; <span class="org-comment">% equilibrium position [m]</span>
F_ext = 0; <span class="org-comment">% External force [N]</span>
F_act = 0; <span class="org-comment">% Actuator force [N]</span>
</pre>
</div>
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab">out = <span class="org-matlab-simulink-keyword">sim</span>(<span class="org-string">'gravity_test.slx'</span>);
out.d.Name = <span class="org-string">'Displacement'</span>;
out.Fm.Name = <span class="org-string">'Force Sensor'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
subplot(1,2,1)
plot(out.d)
title(<span class="org-string">''</span>);
subplot(1,2,2)
plot(out.Fm)
title(<span class="org-string">''</span>);
</pre>
</div>
2020-01-30 15:10:45 +01:00
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">&lt;&lt;</span>plt<span class="org-type">-</span>matlab<span class="org-type">&gt;&gt;</span>
</pre>
</div>
2020-11-12 10:22:15 +01:00
<div id="orga9f22cf" class="figure">
2020-01-30 15:10:45 +01:00
<p><img src="figs/sim_change_eq_position.png" alt="sim_change_eq_position.png" />
</p>
<p><span class="figure-number">Figure 3: </span>Simulation after changing the equilibrium position of the joint (<a href="./figs/sim_change_eq_position.png">png</a>, <a href="./figs/sim_change_eq_position.pdf">pdf</a>)</p>
</div>
</div>
</div>
2020-11-12 10:22:15 +01:00
<div id="outline-container-orgeb66e34" class="outline-2">
<h2 id="orgeb66e34"><span class="section-number-2">4</span> Add external force</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-4">
<div class="org-src-container">
<pre class="src src-matlab">l0 = 0; <span class="org-comment">% Initial wanted position [m]</span>
leq = 0; <span class="org-comment">% equilibrium position [m]</span>
F_ext = <span class="org-type">-</span>out_init.Fm.Data(end); <span class="org-comment">% External force [N]</span>
F_act = 0; <span class="org-comment">% Actuator force [N]</span>
</pre>
</div>
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab">out = <span class="org-matlab-simulink-keyword">sim</span>(<span class="org-string">'gravity_test.slx'</span>);
2020-01-30 15:10:45 +01:00
2020-01-30 15:24:24 +01:00
out.d.Name = <span class="org-string">'Displacement'</span>;
out.Fm.Name = <span class="org-string">'Force Sensor'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
subplot(1,2,1)
plot(out.d)
title(<span class="org-string">''</span>);
subplot(1,2,2)
plot(out.Fm)
title(<span class="org-string">''</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">&lt;&lt;</span>plt<span class="org-type">-</span>matlab<span class="org-type">&gt;&gt;</span>
</pre>
</div>
2020-11-12 10:22:15 +01:00
<div id="org8daf882" class="figure">
2020-01-30 15:10:45 +01:00
<p><img src="figs/sim_add_external_force.png" alt="sim_add_external_force.png" />
</p>
<p><span class="figure-number">Figure 4: </span>Simulater after adding an external force applied to the solid (<a href="./figs/sim_add_external_force.png">png</a>, <a href="./figs/sim_add_external_force.pdf">pdf</a>)</p>
</div>
</div>
</div>
2020-11-12 10:22:15 +01:00
<div id="outline-container-org7707124" class="outline-2">
<h2 id="org7707124"><span class="section-number-2">5</span> Change initial position</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-5">
<div class="org-src-container">
<pre class="src src-matlab">l0 = out_init.d.Data(end); <span class="org-comment">% Initial wanted position [m]</span>
leq = 0; <span class="org-comment">% equilibrium position [m]</span>
F_ext = 0; <span class="org-comment">% External force [N]</span>
F_act = 0; <span class="org-comment">% Actuator force [N]</span>
</pre>
</div>
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab">out = <span class="org-matlab-simulink-keyword">sim</span>(<span class="org-string">'gravity_test.slx'</span>);
out.d.Name = <span class="org-string">'Displacement'</span>;
out.Fm.Name = <span class="org-string">'Force Sensor'</span>;
</pre>
</div>
2020-01-30 15:10:45 +01:00
2020-01-30 15:24:24 +01:00
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
subplot(1,2,1)
plot(out.d)
title(<span class="org-string">''</span>);
subplot(1,2,2)
plot(out.Fm)
title(<span class="org-string">''</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">&lt;&lt;</span>plt<span class="org-type">-</span>matlab<span class="org-type">&gt;&gt;</span>
</pre>
</div>
2020-11-12 10:22:15 +01:00
<div id="orgf1ba95a" class="figure">
2020-01-30 15:10:45 +01:00
<p><img src="figs/sim_change_initial_position.png" alt="sim_change_initial_position.png" />
</p>
<p><span class="figure-number">Figure 5: </span>Simulation after changing the initial position of the joint (<a href="./figs/sim_change_initial_position.png">png</a>, <a href="./figs/sim_change_initial_position.pdf">pdf</a>)</p>
</div>
</div>
</div>
2020-11-12 10:22:15 +01:00
<div id="outline-container-org923fa38" class="outline-2">
<h2 id="org923fa38"><span class="section-number-2">6</span> Conclusion</h2>
2020-01-30 15:10:45 +01:00
<div class="outline-text-2" id="text-6">
<p>
2020-01-30 15:24:24 +01:00
Three techniques:
</p>
<ul class="org-ul">
<li>Change the equilibrium position
<ul class="org-ul">
<li>This does not change the equilibrium position of the system</li>
</ul></li>
<li>Add external force
<ul class="org-ul">
<li>May not be physical</li>
</ul></li>
<li>Change the initial position
<ul class="org-ul">
<li>The static position is not the same as the static position without gravity</li>
<li>Very easy to implement</li>
</ul></li>
</ul>
2020-11-12 10:22:15 +01:00
<div class="important" id="orgd1ea3af">
2020-01-30 15:24:24 +01:00
<p>
2020-01-30 15:10:45 +01:00
Changing the equilibrium position of each joint seem the most practical solution.
</p>
2020-01-30 15:24:24 +01:00
</div>
2020-01-30 15:10:45 +01:00
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
2020-11-12 10:22:15 +01:00
<p class="date">Created: 2020-11-12 jeu. 10:22</p>
2020-01-30 15:10:45 +01:00
</div>
</body>
</html>