-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotors.html
433 lines (309 loc) · 20.4 KB
/
motors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>More about Motors — ev3-micropython 2.0.0 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'2.0.0',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/contentui.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<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/contentui.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Basic Movement" href="examples/robot_educator_basic.html" />
<link rel="prev" title="Signals and Units" href="signaltypes.html" />
<link rel="stylesheet" href="_static/css/theme_overrides.css" type="text/css">
</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">
<img src="_static/lego-education-logo-small.png" class="logo" alt="Logo"/>
</a>
<div class="version">
2.0.0
</div>
<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">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="startinstall.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="startbrick.html">Using the EV3 Brick</a></li>
<li class="toctree-l1"><a class="reference internal" href="startrun.html">Creating and running programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="startlinux.html">Accessing advanced EV3 features</a></li>
<li class="toctree-l1"><a class="reference internal" href="startupgrade.html">Upgrading from v1.0 to v2.0</a></li>
</ul>
<p class="caption"><span class="caption-text">Pybricks Modules</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="hubs.html"><code class="docutils literal notranslate"><span class="pre">hubs</span></code> – Programmable Hubs</a></li>
<li class="toctree-l1"><a class="reference internal" href="ev3devices.html"><code class="docutils literal notranslate"><span class="pre">ev3devices</span></code> – EV3 Devices</a></li>
<li class="toctree-l1"><a class="reference internal" href="nxtdevices.html"><code class="docutils literal notranslate"><span class="pre">nxtdevices</span></code> – NXT Devices</a></li>
<li class="toctree-l1"><a class="reference internal" href="iodevices.html"><code class="docutils literal notranslate"><span class="pre">iodevices</span></code> – Generic I/O Devices</a></li>
<li class="toctree-l1"><a class="reference internal" href="parameters.html"><code class="docutils literal notranslate"><span class="pre">parameters</span></code> – Parameters and Constants</a></li>
<li class="toctree-l1"><a class="reference internal" href="tools.html"><code class="docutils literal notranslate"><span class="pre">tools</span></code> – Timing and Data logging</a></li>
<li class="toctree-l1"><a class="reference internal" href="robotics.html"><code class="docutils literal notranslate"><span class="pre">robotics</span></code> – Robotics</a></li>
<li class="toctree-l1"><a class="reference internal" href="media.html"><code class="docutils literal notranslate"><span class="pre">media</span></code> – Sounds and Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="messaging.html"><code class="docutils literal notranslate"><span class="pre">messaging</span></code> – Messaging</a></li>
</ul>
<p class="caption"><span class="caption-text">Engineering Extras</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="signaltypes.html">Signals and Units</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">More about Motors</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#the-control-class">The Control Class</a></li>
</ul>
</li>
</ul>
<p class="caption"><span class="caption-text">Robot Educator Programs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="examples/robot_educator_basic.html">Basic Movement</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/robot_educator_ultrasonic.html">Obstacle Avoidance</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/robot_educator_line.html">Line Following</a></li>
</ul>
<p class="caption"><span class="caption-text">Core Set Programs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="examples/color_sorter.html">Color Sorter</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/robot_arm.html">Robot Arm H25</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/puppy.html">Puppy</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/gyro_boy.html">Gyro Boy</a></li>
</ul>
<p class="caption"><span class="caption-text">Expansion Set Programs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="examples/elephant.html">Elephant</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/stair_climber.html">Stair Climber</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/tank_bot.html">Tank Bot</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/znap.html">Znap</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">ev3-micropython</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content style-external-links">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>More about Motors</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/motors.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="more-about-motors">
<h1>More about Motors<a class="headerlink" href="#more-about-motors" title="Permalink to this headline">¶</a></h1>
<div class="section" id="the-control-class">
<span id="control"></span><h2>The Control Class<a class="headerlink" href="#the-control-class" title="Permalink to this headline">¶</a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">Motor</span></code> class uses PID control to accurately track your commanded target
angles. Similarly, the <code class="docutils literal notranslate"><span class="pre">DriveBase</span></code> class uses two of such controllers:
one to control the heading and one to control the traveled distance.</p>
<p>You can change the control settings through the following attributes, which are
instances of the <code class="docutils literal notranslate"><span class="pre">Control</span></code> class given below.:</p>
<blockquote>
<div><ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">Motor.control</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">DriveBase.heading_control</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">DriveBase.distance_control</span></code></li>
</ul>
</div></blockquote>
<p>You can only change the settings while the controller is stopped. For example,
you can set the settings at the beginning of your program. Alternatively, first
call <code class="docutils literal notranslate"><span class="pre">stop()</span></code> to make your <code class="docutils literal notranslate"><span class="pre">Motor</span></code> or <code class="docutils literal notranslate"><span class="pre">DriveBase</span></code> stop, and then change
the settings.</p>
<dl class="class">
<dt id="pybricks._common.Control">
<em class="property">class </em><code class="descname">Control</code><a class="headerlink" href="#pybricks._common.Control" title="Permalink to this definition">¶</a></dt>
<dd><p>Class to interact with PID controller and settings.</p>
<dl class="data">
<dt id="pybricks._common.Control.scale">
<code class="descname">scale</code><a class="headerlink" href="#pybricks._common.Control.scale" title="Permalink to this definition">¶</a></dt>
<dd><p>Scaling factor between the controlled integer variable
and the physical output. For example, for a single
motor this is the number of encoder pulses per degree of rotation.</p>
</dd></dl>
<p class="rubric">Status</p>
<dl class="method">
<dt id="pybricks._common.Control.done">
<code class="descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if an ongoing command or maneuver is done.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal notranslate"><span class="pre">True</span></code> if the command is done, <code class="docutils literal notranslate"><span class="pre">False</span></code> if not.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pybricks._common.Control.stalled">
<code class="descname">stalled</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.stalled" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the controller is currently stalled.</p>
<p>A controller is stalled when it cannot reach the target speed or
position, even with the maximum actuation signal.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><code class="docutils literal notranslate"><span class="pre">True</span></code> if the controller is stalled, <code class="docutils literal notranslate"><span class="pre">False</span></code> if not.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
</tr>
</tbody>
</table>
</dd></dl>
<p class="rubric">Settings</p>
<dl class="method">
<dt id="pybricks._common.Control.limits">
<code class="descname">limits</code><span class="sig-paren">(</span><em>speed</em>, <em>acceleration</em>, <em>actuation</em><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.limits" title="Permalink to this definition">¶</a></dt>
<dd><p>Configures the maximum speed, acceleration, and actuation.</p>
<p>If no arguments are given, this will return the current values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>speed</strong> (<a class="reference internal" href="signaltypes.html#speed"><span class="std std-ref">rotational speed: deg/s</span></a> or <a class="reference internal" href="signaltypes.html#linspeed"><span class="std std-ref">speed: mm/s</span></a>) – Maximum speed. All speed commands will be capped to this value.</li>
<li><strong>acceleration</strong> (<a class="reference internal" href="signaltypes.html#acceleration"><span class="std std-ref">rotational acceleration: deg/s/s</span></a> or <a class="reference internal" href="signaltypes.html#linacceleration"><span class="std std-ref">linear acceleration: mm/s/s</span></a>) – Maximum acceleration.</li>
<li><strong>actuation</strong> (<a class="reference internal" href="signaltypes.html#percentage"><span class="std std-ref">percentage: %</span></a>) – Maximum actuation as percentage of absolute maximum.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pybricks._common.Control.pid">
<code class="descname">pid</code><span class="sig-paren">(</span><em>kp</em>, <em>ki</em>, <em>kd</em>, <em>integral_range</em>, <em>integral_rate</em>, <em>feed_forward</em><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.pid" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets or sets the PID values for position and speed control.</p>
<p>If no arguments are given, this will return the current values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>kp</strong> (<em>int</em>) – Proportional position (or integral speed) control
constant.</li>
<li><strong>ki</strong> (<em>int</em>) – Integral position control constant.</li>
<li><strong>kd</strong> (<em>int</em>) – Derivative position (or proportional speed) control
constant.</li>
<li><strong>integral_range</strong> (<a class="reference internal" href="signaltypes.html#angle"><span class="std std-ref">angle: deg</span></a> or <a class="reference internal" href="signaltypes.html#distance"><span class="std std-ref">distance: mm</span></a>) – Region around
the target angle or distance, in which integral control errors
are accumulated.</li>
<li><strong>integral_rate</strong> (<a class="reference internal" href="signaltypes.html#speed"><span class="std std-ref">rotational speed: deg/s</span></a> or <a class="reference internal" href="signaltypes.html#linspeed"><span class="std std-ref">speed: mm/s</span></a>) – Maximum rate at
which the error integral is allowed to grow.</li>
<li><strong>feed_forward</strong> (<a class="reference internal" href="signaltypes.html#percentage"><span class="std std-ref">percentage: %</span></a>) – This adds a feed forward signal to the PID feedback signal, in
the direction of the speed reference. This value is expressed
as a percentage of the absolute maximum duty cycle.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pybricks._common.Control.target_tolerances">
<code class="descname">target_tolerances</code><span class="sig-paren">(</span><em>speed</em>, <em>position</em><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.target_tolerances" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets or sets the tolerances that say when a maneuver is done.</p>
<p>If no arguments are given, this will return the current values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>speed</strong> (<a class="reference internal" href="signaltypes.html#speed"><span class="std std-ref">rotational speed: deg/s</span></a> or <a class="reference internal" href="signaltypes.html#linspeed"><span class="std std-ref">speed: mm/s</span></a>) – Allowed deviation
from zero speed before motion is considered complete.</li>
<li><strong>position</strong> (<a class="reference internal" href="signaltypes.html#angle"><span class="std std-ref">angle: deg</span></a> or <a class="reference internal" href="signaltypes.html#distance"><span class="std std-ref">distance: mm</span></a>) – Allowed
deviation from the target before motion is considered
complete.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="pybricks._common.Control.stall_tolerances">
<code class="descname">stall_tolerances</code><span class="sig-paren">(</span><em>speed</em>, <em>time</em><span class="sig-paren">)</span><a class="headerlink" href="#pybricks._common.Control.stall_tolerances" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets or sets stalling tolerances.</p>
<p>If no arguments are given, this will return the current values.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>speed</strong> (<a class="reference internal" href="signaltypes.html#speed"><span class="std std-ref">rotational speed: deg/s</span></a> or <a class="reference internal" href="signaltypes.html#linspeed"><span class="std std-ref">speed: mm/s</span></a>) – If the controller
cannot reach this speed for some <code class="docutils literal notranslate"><span class="pre">time</span></code> even with maximum
actuation, it is stalled.</li>
<li><strong>time</strong> (<a class="reference internal" href="signaltypes.html#id1"><span class="std std-ref">time: ms</span></a>) – How long the controller has to be below this
minimum <code class="docutils literal notranslate"><span class="pre">speed</span></code> before we say it is stalled.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="examples/robot_educator_basic.html" class="btn btn-neutral float-right" title="Basic Movement" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="signaltypes.html" class="btn btn-neutral float-left" title="Signals and Units" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2019-2020 The LEGO Group. All rights reserved.
</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>.
<div class="disclaimer">LEGO, the LEGO logo, MINDSTORMS and the MINDSTORMS EV3 logo are trademarks and/or copyrights of the LEGO Group.</div>
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>