496 lines
No EOL
30 KiB
HTML
496 lines
No EOL
30 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="en" >
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>Api — CompLib 0.2.3 documentation</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 src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
|
||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||
|
||
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Aruco" href="Aruco.html" />
|
||
<link rel="prev" title="Usage" href="../other/usage.html" />
|
||
</head>
|
||
|
||
<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" class="icon icon-home" alt="Documentation Home"> CompLib
|
||
|
||
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<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">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<ul class="current">
|
||
<li class="toctree-l1"><a class="reference internal" href="../index.html">Competition Robot Library</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="../other/usage.html">Usage</a></li>
|
||
<li class="toctree-l1 current"><a class="current reference internal" href="#">Api</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="#seeding">Seeding</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#double-elimination">Double Elimination</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#position">Position</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="#examples">Examples</a><ul>
|
||
<li class="toctree-l3"><a class="reference internal" href="#calling-seeding-api">Calling Seeding API</a></li>
|
||
<li class="toctree-l3"><a class="reference internal" href="#calling-double-elimination-api">Calling Double Elimination API</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Aruco.html">Aruco</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Display.html">Display</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Encoder.html">Encoder</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="IRSensor.html">Infrared Sensor</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Linefollower.html">Linefollower Examples</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Logging.html">Logging</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Motor.html">Motor</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="QC.html">Quality Control</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Servo.html">Servo</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="Vision.html">Vision</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">
|
||
|
||
<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">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="../index.html" class="icon icon-home"></a> »</li>
|
||
|
||
<li>Api</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="../_sources/lib/Api.rst.txt" rel="nofollow"> View page source</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="api">
|
||
<span id="lib-api"></span><h1>Api<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
|
||
<div class="section" id="seeding">
|
||
<h2>Seeding<a class="headerlink" href="#seeding" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="py class">
|
||
<dt id="compLib.Api.Seeding">
|
||
<em class="property">class </em><code class="sig-prename descclassname">compLib.Api.</code><code class="sig-name descname">Seeding</code><a class="headerlink" href="#compLib.Api.Seeding" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Class used for communicating with seeding api</p>
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.Seeding.get_cargo">
|
||
<em class="property">static </em><code class="sig-name descname">get_cargo</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">color</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.Seeding.get_cargo" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/listCargo call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>color</strong> – Color parameter which specifies which cargo should be taken. (A string which is either “green”, “red”, “yellow” or “blue”</p>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p>Json Object and status code as returned by the api.</p>
|
||
</dd>
|
||
<dt class="field-odd">Return type</dt>
|
||
<dd class="field-odd"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.Seeding.get_delivery">
|
||
<em class="property">static </em><code class="sig-name descname">get_delivery</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.Seeding.get_delivery" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getDelivery call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>Json Object and status code as returned by the api.</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.Seeding.get_garbage">
|
||
<em class="property">static </em><code class="sig-name descname">get_garbage</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.Seeding.get_garbage" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getGarbage call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>Json Object and status code as returned by the api.</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.Seeding.get_material">
|
||
<em class="property">static </em><code class="sig-name descname">get_material</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.Seeding.get_material" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getMaterial call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>Json Object and status code as returned by the api.</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.Seeding.list_cargo">
|
||
<em class="property">static </em><code class="sig-name descname">list_cargo</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.Seeding.list_cargo" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/listCargo call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>Json Object and status code as returned by the api.</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="double-elimination">
|
||
<h2>Double Elimination<a class="headerlink" href="#double-elimination" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="py class">
|
||
<dt id="compLib.Api.DoubleElim">
|
||
<em class="property">class </em><code class="sig-prename descclassname">compLib.Api.</code><code class="sig-name descname">DoubleElim</code><a class="headerlink" href="#compLib.Api.DoubleElim" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Class used for communicating with double elimination api</p>
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_goal">
|
||
<em class="property">static </em><code class="sig-name descname">get_goal</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span><a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">compLib.Api.Position</a><span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_goal" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getGoal call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A Position object with x and y coordinates of the goal, rotation is always -1</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[<a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">Position</a>, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_items">
|
||
<em class="property">static </em><code class="sig-name descname">get_items</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>List<span class="p">[</span>Dict<span class="p">]</span><span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_items" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getItems call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A list will all items currently on the game field. Items are dictionaries that look like: {“id”: 0, “x”: 0, “y”: 0}</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[List[Dict], int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_meteoroids">
|
||
<em class="property">static </em><code class="sig-name descname">get_meteoroids</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>List<span class="p">[</span>Dict<span class="p">]</span><span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_meteoroids" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getMeteoroids call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A list will all meteoroids currently on the game field. Meteoroids are dictionaries that look like: {“x”: 0, “y”: 0}</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[List[Dict], int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_opponent">
|
||
<em class="property">static </em><code class="sig-name descname">get_opponent</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span><a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">compLib.Api.Position</a><span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_opponent" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getOp call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A Position object with opponents robot position</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[<a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">Position</a>, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_position">
|
||
<em class="property">static </em><code class="sig-name descname">get_position</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span><a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">compLib.Api.Position</a><span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_position" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getPos call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A Position object with robot position</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[<a class="reference internal" href="#compLib.Api.Position" title="compLib.Api.Position">Position</a>, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="compLib.Api.DoubleElim.get_scores">
|
||
<em class="property">static </em><code class="sig-name descname">get_scores</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Tuple<span class="p">[</span>Dict<span class="p">, </span>int<span class="p">]</span><a class="headerlink" href="#compLib.Api.DoubleElim.get_scores" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Makes the /api/getScores call to the api.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p>A dictionary with all scores included like: {“self”:2,”opponent”:0}</p>
|
||
</dd>
|
||
<dt class="field-even">Return type</dt>
|
||
<dd class="field-even"><p>Tuple[Dict, int]</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="position">
|
||
<h2>Position<a class="headerlink" href="#position" title="Permalink to this headline">¶</a></h2>
|
||
<dl class="py class">
|
||
<dt id="compLib.Api.Position">
|
||
<em class="property">class </em><code class="sig-prename descclassname">compLib.Api.</code><code class="sig-name descname">Position</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">y</span></em>, <em class="sig-param"><span class="n">degrees</span></em><span class="sig-paren">)</span><a class="headerlink" href="#compLib.Api.Position" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Datastructure for holding a position</p>
|
||
</dd></dl>
|
||
|
||
</div>
|
||
<div class="section" id="examples">
|
||
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
|
||
<div class="section" id="calling-seeding-api">
|
||
<h3>Calling Seeding API<a class="headerlink" href="#calling-seeding-api" title="Permalink to this headline">¶</a></h3>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.Api</span> <span class="kn">import</span> <span class="n">Seeding</span>
|
||
|
||
<span class="n">zones</span><span class="p">,</span> <span class="n">code</span> <span class="o">=</span> <span class="n">Seeding</span><span class="o">.</span><span class="n">get_delivery</span><span class="p">()</span>
|
||
<span class="k">if</span> <span class="n">code</span> <span class="o">==</span> <span class="mi">403</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"I am not in the correct zone to make that request!"</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="sa">f</span><span class="s2">"First we need to go to zone </span><span class="si">{</span><span class="n">zone</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
<span class="c1"># put code here to follow line and drive to the zone</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Now we need to go to zone </span><span class="si">{</span><span class="n">zone</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
<span class="c1"># put code here to follow line and drive to the next zone</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Now we need to go to zone </span><span class="si">{</span><span class="n">zone</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
<span class="c1"># put code here to follow line and drive to the last zone</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"We delivered all packages, hopefully we scored some points!"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.Api</span> <span class="kn">import</span> <span class="n">Seeding</span>
|
||
|
||
<span class="n">package</span><span class="p">,</span> <span class="n">code</span> <span class="o">=</span> <span class="n">Seeding</span><span class="o">.</span><span class="n">get_cargo</span><span class="p">(</span><span class="s2">"yellow"</span><span class="p">)</span>
|
||
<span class="k">if</span> <span class="n">code</span> <span class="o">==</span> <span class="mi">403</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"I am not in the correct zone to make that request!"</span><span class="p">)</span>
|
||
<span class="k">elif</span> <span class="n">code</span> <span class="o">==</span> <span class="mi">404</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"I am in the correct zone, but there is no yellow package here."</span><span class="p">)</span>
|
||
<span class="k">elif</span> <span class="n">code</span> <span class="o">==</span> <span class="mi">413</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"I am in the correct zone, but I already have two packages loaded."</span><span class="p">)</span>
|
||
<span class="k">else</span> <span class="n">code</span> <span class="o">==</span> <span class="mi">200</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"The </span><span class="si">{</span><span class="n">package</span><span class="p">[</span><span class="s1">'color'</span><span class="p">]</span><span class="si">}</span><span class="s2"> has been picked up!"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<div class="section" id="calling-double-elimination-api">
|
||
<h3>Calling Double Elimination API<a class="headerlink" href="#calling-double-elimination-api" title="Permalink to this headline">¶</a></h3>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.Api</span> <span class="kn">import</span> <span class="n">DoubleElim</span>
|
||
|
||
<span class="n">position</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_position</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Position of my robot is: x=</span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">x</span><span class="si">}</span><span class="s2">, y=</span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">y</span><span class="si">}</span><span class="s2"> and rotation is: </span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">degrees</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">goal</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_goal</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Goal is at: x=</span><span class="si">{</span><span class="n">goal</span><span class="o">.</span><span class="n">x</span><span class="si">}</span><span class="s2">, y=</span><span class="si">{</span><span class="n">goal</span><span class="o">.</span><span class="n">y</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">compLib.Api</span> <span class="kn">import</span> <span class="n">DoubleElim</span>
|
||
<span class="kn">import</span> <span class="nn">time</span>
|
||
|
||
<span class="c1"># function which waits for the game to be started (you should include this in your double elimination program)</span>
|
||
<span class="k">def</span> <span class="nf">wait_for_start</span><span class="p">():</span>
|
||
<span class="n">_</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_position</span><span class="p">()</span>
|
||
<span class="k">while</span> <span class="n">status</span> <span class="o">==</span> <span class="mi">503</span><span class="p">:</span>
|
||
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
|
||
<span class="n">_</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_position</span><span class="p">()</span>
|
||
|
||
<span class="n">wait_for_start</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Game has started, lets score some points!!"</span><span class="p">)</span>
|
||
|
||
<span class="n">position</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_position</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Position of my robot is: x=</span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">x</span><span class="si">}</span><span class="s2">, y=</span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">y</span><span class="si">}</span><span class="s2"> and rotation is: </span><span class="si">{</span><span class="n">position</span><span class="o">.</span><span class="n">degrees</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">opponent_position</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_opponent</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Position of the opponents robot is: x=</span><span class="si">{</span><span class="n">opponent_position</span><span class="o">.</span><span class="n">x</span><span class="si">}</span><span class="s2">, y=</span><span class="si">{</span><span class="n">opponent_position</span><span class="o">.</span><span class="n">y</span><span class="si">}</span><span class="s2"> and rotation is: </span><span class="si">{</span><span class="n">opponent_position</span><span class="o">.</span><span class="n">degrees</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">goal</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_goal</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Goal is at: x=</span><span class="si">{</span><span class="n">goal</span><span class="o">.</span><span class="n">x</span><span class="si">}</span><span class="s2">, y=</span><span class="si">{</span><span class="n">goal</span><span class="o">.</span><span class="n">y</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">items</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_items</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"There are currently </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">items</span><span class="p">)</span><span class="si">}</span><span class="s2"> on the gameboard: </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">score</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_score</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"The current score of the game is </span><span class="si">{</span><span class="n">score</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">meteoroids</span><span class="p">,</span> <span class="n">status</span> <span class="o">=</span> <span class="n">DoubleElim</span><span class="o">.</span><span class="n">get_meteoroids</span><span class="p">()</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"The current meteoroids in the game are </span><span class="si">{</span><span class="n">meteoroids</span><span class="si">}</span><span class="s2">, the server responded with status code: </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>In this second example we wait until the game is started by the judges and then make all possible requests once. You should use the wait_for_start function in your double elimination program. If your robot starts too soon your run will not count!</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
<footer>
|
||
|
||
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||
|
||
<a href="Aruco.html" class="btn btn-neutral float-right" title="Aruco" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||
|
||
|
||
<a href="../other/usage.html" class="btn btn-neutral float-left" title="Usage" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||
|
||
</div>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
|
||
© Copyright 2021, robo4you
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
|
||
|
||
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
|
||
|
||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(true);
|
||
});
|
||
</script>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</body>
|
||
</html> |