Update documentation

This commit is contained in:
Joel Klimont 2022-11-18 16:46:58 +01:00
parent 64ff14b9b1
commit 75185f19b6
36 changed files with 14537 additions and 3800 deletions

View file

@ -1,73 +1,32 @@
<!DOCTYPE html>
<html class="writer-html5" lang="de" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mein drittes Programm &mdash; CompLib 0.2.3 Dokumentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mein drittes Programm &mdash; CompLib 0.2.3 Dokumentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/translations.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Stichwortverzeichnis" href="../genindex.html" />
<link rel="search" title="Suche" href="../search.html" />
<link rel="next" title="Installationsanweisungen" href="../software/installation.html" />
<link rel="prev" title="Mein zweites Programm" href="secondProgram.html" />
</head>
<body class="wy-body-for-nav">
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html">
<img src="../_static/compair-logo-white.svg" class="logo" alt="Logo"/>
<a href="../index.html"><img src="../_static/compair-logo-white.svg" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Dokumentation durchsuchen" />
@ -75,18 +34,7 @@
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Erste Schritte</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="wifi.html">WLAN-Verbindung herstellen</a></li>
@ -104,111 +52,88 @@
<li class="toctree-l1"><a class="reference internal" href="../other/hardware.html">Hardware</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">CompLib</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="index.html">Erste Schritte</a> &raquo;</li>
<li>Mein drittes Programm</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/gettingStarted/thridProgram.rst.txt" rel="nofollow"> Quelltext anzeigen</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="mein-drittes-programm">
<h1>Mein drittes Programm<a class="headerlink" href="#mein-drittes-programm" title="Permalink to this heading"></a></h1>
<h1>Mein drittes Programm<a class="headerlink" href="#mein-drittes-programm" title="Link zu dieser Überschrift"></a></h1>
<p>Der offizielle compAIR-Bot ist mit einer Reihe von Sensoren ausgestattet. Die wichtigsten sind die Infrarotsensoren und -sender, die an der Vorderseite des Roboters angebracht sind. Insgesamt gibt es fünf IR-Sensoren.</p>
<p>Um loszulegen, muss man zunächst das entsprechende Modul wie folgt importieren:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
</pre></div>
</div>
</td></tr></table></div>
<p><img alt="irSensor" src="../_images/07_irSensor.webp" /></p>
<p>Wie im obigen Diagramm zu sehen ist, verfügt jeder Sensor auch über einen entsprechenden IR-Sender / Emitter. Dieser Sender kann mit <code class="docutils literal notranslate"><span class="pre">IRSensor.set(port,</span> <span class="pre">enable)</span></code> aktiviert werden.</p>
<p>Schalten wir nun alle fünf Sender ein:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="linenos">2</span>
<span class="linenos">3</span><span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
</pre></div>
</div>
</td></tr></table></div>
<p>Diese fünf verschiedenen Sensoren befinden sich an der Vorderseite des Roboters und sind wichtig, um schwarze Linien zu erkennen.</p>
<p>Es ist sehr einfach, den Wert der Sensoren abzulesen:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="linenos">2</span>
<span class="linenos">3</span><span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
<span class="linenos">4</span>
<span class="linenos">5</span><span class="k">if</span> <span class="n">IRSensor</span><span class="o">.</span><span class="n">read_all</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">500</span><span class="p">:</span>
<span class="linenos">6</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;high&quot;</span><span class="p">)</span>
<span class="linenos">7</span><span class="k">else</span><span class="p">:</span>
<span class="linenos">8</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;low&quot;</span><span class="p">)</span>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7
8</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
<span class="k">if</span> <span class="n">IRSensor</span><span class="o">.</span><span class="n">read_all</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">500</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;high&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;low&quot;</span><span class="p">)</span>
</pre></div>
</div>
</td></tr></table></div>
<p><strong>Erkennen einer schwarzen Linie</strong>
Um den IR-Sensor zu testen, kannst du deinen Roboter auf eine schwarze Linie stellen. Der Sensor in der Mitte sollte auf der schwarzen Linie liegen.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="linenos">2</span>
<span class="linenos">3</span><span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
<span class="linenos">4</span><span class="n">COLOR_BREAK</span> <span class="o">=</span> <span class="mi">900</span>
<span class="linenos">5</span>
<span class="linenos">6</span><span class="k">if</span> <span class="n">IRSensor</span><span class="o">.</span><span class="n">read_all</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">COLOR_BREAK</span><span class="p">:</span>
<span class="linenos">7</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Robot is standing on a black line&quot;</span><span class="p">)</span>
<span class="linenos">8</span><span class="k">else</span><span class="p">:</span>
<span class="linenos">9</span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Robot is NOT standing on a black line&quot;</span><span class="p">)</span>
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7
8
9</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.IRSensor</span> <span class="kn">import</span> <span class="n">IRSensor</span>
<span class="n">IRSensor</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
<span class="n">COLOR_BREAK</span> <span class="o">=</span> <span class="mi">900</span>
<span class="k">if</span> <span class="n">IRSensor</span><span class="o">.</span><span class="n">read_all</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">COLOR_BREAK</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Robot is standing on a black line&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Robot is NOT standing on a black line&quot;</span><span class="p">)</span>
</pre></div>
</div>
</td></tr></table></div>
<p>Wenn das Programm ausgeführt wird, zeigt es an, dass der Roboter auf einer schwarzen Linie steht, wenn sich der mittlere IR-Sensor des Roboters über einer schwarzen Linie befindet, und es zeigt an, dass der Roboter NICHT auf einer schwarzen Linie steht, wenn sich der mittlere IR-Sensor nicht über einer Linie befindet.</p>
<div class="line-block">
<div class="line">In <code class="docutils literal notranslate"><span class="pre">Zeile</span> <span class="pre">1</span></code> importieren wir das <code class="docutils literal notranslate"><span class="pre">IRSensor</span></code>-Modul, das zur Kommunikation mit dem IR-Sensor-Board verwendet werden kann.</div>
@ -223,58 +148,33 @@ Um den IR-Sensor zu testen, kannst du deinen Roboter auf eine schwarze Linie ste
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="../software/installation.html" class="btn btn-neutral float-right" title="Installationsanweisungen" accesskey="n" rel="next">Weiter <span class="fa fa-arrow-circle-right"></span></a>
<a href="secondProgram.html" class="btn btn-neutral float-left" title="Mein zweites Programm" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Zurück</a>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="secondProgram.html" class="btn btn-neutral float-left" title="Mein zweites Programm" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Zurück</a>
<a href="../software/installation.html" class="btn btn-neutral float-right" title="Installationsanweisungen" accesskey="n" rel="next">Weiter <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2022, Verein zur Förderung von Wissenschaft und Technik an Schulen (F-WuTS)
</p>
<p>&#169; Copyright 2022, Verein zur Förderung von Wissenschaft und Technik an Schulen (F-WuTS).</p>
</div>
Erstellt mit <a href="http://sphinx-doc.org/">Sphinx</a> mit einem
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
bereitgestellt von <a href="https://readthedocs.org">Read the Docs</a>.
Erstellt mit <a href="https://www.sphinx-doc.org/">Sphinx</a> mit einem
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
bereitgestellt von <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</script>
</body>
</html>