-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1193 lines (1024 loc) · 82.7 KB
/
index.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!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>Welcome to WonderPy’s documentation! — wonder documentation</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" />
<!--[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 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" />
</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="#" class="icon icon-home"> wonder
</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">
<!-- Local TOC -->
<div class="local-toc"><ul>
<li><a class="reference internal" href="#">Welcome to WonderPy’s documentation!</a></li>
<li><a class="reference internal" href="#tutorial">Tutorial</a><ul>
<li><a class="reference internal" href="#set-up-your-adafruit-clue">Set up your Adafruit Clue</a><ul>
<li><a class="reference internal" href="#install-circuitpython">Install CircuitPython</a></li>
<li><a class="reference internal" href="#install-circuitpython-adafruit-libraries">Install CircuitPython/Adafruit libraries</a></li>
<li><a class="reference internal" href="#install-wonder-workshop-s-module-for-controlling-dash-cue-wonder">Install Wonder Workshop’s module for controlling Dash/Cue, ‘<code class="docutils literal notranslate"><span class="pre">wonder</span></code>’</a></li>
<li><a class="reference internal" href="#running-python-programs-on-the-adafruit-clue">Running Python Programs on the Adafruit Clue</a></li>
<li><a class="reference internal" href="#write-your-first-clue-circuitpython-dash-program">Write your first Clue+CircuitPython+Dash program</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#module-wonder"><code class="docutils literal notranslate"><span class="pre">wonder</span></code> Module Documentation</a></li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
</ul>
</div>
</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="#">wonder</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="#" class="icon icon-home"></a> »</li>
<li>Welcome to WonderPy’s documentation!</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.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="welcome-to-wonderpy-s-documentation">
<h1>Welcome to WonderPy’s documentation!<a class="headerlink" href="#welcome-to-wonderpy-s-documentation" title="Permalink to this headline">¶</a></h1>
<p>This document provides instructions to control Wonder Workshop’s “Dash” and
“Cue” robots with the Adafruit Clue board and CircuitPython.</p>
<p>Dash and Cue educational robots used in a wide variety of settings, including
classrooms and homes. Read more at <a class="reference external" href="http://makewonder.com">here</a>.</p>
<p>The Adafruit Clue is a small microcontroller development board with built-in
Bluetooth BLE capabilities. Read more about the Adafruit Clue <a class="reference external" href="https://learn.adafruit.com/adafruit-clue">here</a>.</p>
<p>CircuitPython is a small implementation of the Python programming language
that can run on small microcontrollers, such as the Adafruit Clue.</p>
</div>
<div class="section" id="tutorial">
<h1>Tutorial<a class="headerlink" href="#tutorial" title="Permalink to this headline">¶</a></h1>
<p>This tutorial assumes that you are using a standard Dash robot with an Adafruit
Clue.</p>
<div class="section" id="set-up-your-adafruit-clue">
<h2>Set up your Adafruit Clue<a class="headerlink" href="#set-up-your-adafruit-clue" title="Permalink to this headline">¶</a></h2>
<p>To get started, we will need to set up your Adafruit Clue.</p>
<div class="section" id="install-circuitpython">
<h3>Install CircuitPython<a class="headerlink" href="#install-circuitpython" title="Permalink to this headline">¶</a></h3>
<p>First, you will need to install CircuitPython version 7.0.0.
This tutorial will provide abridged setup instructions. Up-to-date instructions can be found
<a class="reference external" href="https://learn.adafruit.com/adafruit-clue/circuitpython">here</a>.</p>
<ol class="arabic simple">
<li><p>Download the CircuitPython 7.0.0 image <a class="reference external" href="https://circuitpython.org/board/clue_nrf52840_express/">here</a>.</p></li>
<li><p>Attach your Adafruit Clue to a PC computer with a Micro-USB cable.</p></li>
<li><p>Double-click the reset button on the back of the Adafruit Clue. It should
now show up as a drive called “CLUEBOOT”.</p></li>
<li><p>Copy the image file downloaded earlier (should be a .uf2 file) to the
CLUEBOOT drive. The Clue board should reboot and CircuitPython should print a
welcome message onto the screen. The clue board should now show up as a drive called “CIRCUITPY”.</p></li>
</ol>
</div>
<div class="section" id="install-circuitpython-adafruit-libraries">
<h3>Install CircuitPython/Adafruit libraries<a class="headerlink" href="#install-circuitpython-adafruit-libraries" title="Permalink to this headline">¶</a></h3>
<p>Next, you will need to install CircuitPython libraries. Adafruit
and CircuitPython provide libraries and modules to support a wide variety of
sensors and peripherals. In order to control Wonder Workshop robots, a
library must be installed in order to use the on-board Bluetooth BLE
module.</p>
<p>First, you will need to download the set of libraries <a class="reference external" href="https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20210928/adafruit-circuitpython-bundle-7.x-mpy-20210928.zip">here</a>.
The one library required to control Wonder Workshop robots is called
<code class="docutils literal notranslate"><span class="pre">adafruit_ble</span></code>. To install the library, open the downloaded zip file and copy
the <code class="docutils literal notranslate"><span class="pre">adafruit_ble</span></code> directory into the <code class="docutils literal notranslate"><span class="pre">CIRCUITPY/lib/</span></code> directory, where
<code class="docutils literal notranslate"><span class="pre">CIRCUITPY</span></code> is the root directory of your Clue drive.</p>
<p>If/when you attach more sensors and peripherals to your Clue board, you may
need to install more libraries to control those sensors and peripherals. We
recommend keeping the zip file handy as you develop your Clue/Dash application,
especially if it will require additional sensors or peripherals in the future.</p>
</div>
<div class="section" id="install-wonder-workshop-s-module-for-controlling-dash-cue-wonder">
<h3>Install Wonder Workshop’s module for controlling Dash/Cue, ‘<code class="docutils literal notranslate"><span class="pre">wonder</span></code>’<a class="headerlink" href="#install-wonder-workshop-s-module-for-controlling-dash-cue-wonder" title="Permalink to this headline">¶</a></h3>
<p>Download the <code class="docutils literal notranslate"><span class="pre">wonder</span></code> module here <a class="reference external" href="https://github.com/playi/PythonWonderDocs/raw/master/wonderpy_0.0.1_circuitpython_7.0.0.zip">here</a>.</p>
<p>The zip file contains a directory named “wonder”. Copy the entire “wonder” directory
onto your Clue board into the directory <code class="docutils literal notranslate"><span class="pre"><CIRCUITPY>/lib/</span></code> . You should now be able to
use the <code class="docutils literal notranslate"><span class="pre">wonder</span></code> module on your Adafruit Clue Python programs.</p>
</div>
<div class="section" id="running-python-programs-on-the-adafruit-clue">
<h3>Running Python Programs on the Adafruit Clue<a class="headerlink" href="#running-python-programs-on-the-adafruit-clue" title="Permalink to this headline">¶</a></h3>
<p>You are now ready to write and run Python programs on your Adafruit Clue. You
may use any basic text editor, such as Microsoft Notepad, to edit your Python
programs, but we recommend using a real code editor. Many are available for free,
such as the <a class="reference external" href="https://www.sublimetext.com/">Sublime Code Editor</a>.</p>
<p>To run code on the Adafruit Clue, you will need to edit or create a file called
“code.py” on the Adafruit Clue. You may do this any number of ways, but we recommend
that you create and edit your “code.py” file on your PC and then copy it onto
the Adafruit Clue’s “CIRCUITPY” drive. We recommend this method just in case
the CIRCUITPY drive gets corrupted or if the Clue board gets damaged in any way,
you will still have a copy of your code on your PC.</p>
<p>When the Adafruit Clue boots up or is reset, it will search for a Python file called
“code.py” and attempt to execute it. If there are syntax or other errors during
the execution of the file, the errors will be displayed on the Adafruit Clue’s built-in
screen.</p>
<p>To run the programs in the next sections, copy the code contents into a file
called “code.py”, attach your Adafruit Clue to your PC with a USB cable, and
copy the file to the new drive that appears when the Adafruit is connected.
The code will save onto the Clue and the Clue will run the program whenever it
is powered up, even if it is not attached to a computer.</p>
</div>
<div class="section" id="write-your-first-clue-circuitpython-dash-program">
<h3>Write your first Clue+CircuitPython+Dash program<a class="headerlink" href="#write-your-first-clue-circuitpython-dash-program" title="Permalink to this headline">¶</a></h3>
<p>We are now ready to try our first Python program that controls Dash. We will
first present a complete code sample and then describe each line in detail.
Here is a simple program which makes Dash drive 30cm forward and then performs
a 360-degree spin to the right:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">robot</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">robot</span><span class="o">.</span><span class="n">drive</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span>
<span class="n">robot</span><span class="o">.</span><span class="n">turn</span><span class="p">(</span><span class="o">-</span><span class="mi">360</span><span class="p">)</span>
</pre></div>
</div>
<p>The first statement of the program, <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">wonder</span></code> , imports the <code class="docutils literal notranslate"><span class="pre">wonder</span></code>
module which contains the required classes and functions for controlling Wonder
Workshop robots.</p>
<p>The next statement reads <code class="docutils literal notranslate"><span class="pre">robot</span> <span class="pre">=</span> <span class="pre">wonder.Dash('Dash')</span></code>. The expression
<code class="docutils literal notranslate"><span class="pre">wonder.Dash('Dash')</span></code> finds and connects to a robot named ‘Dash’<a class="footnote-reference brackets" href="#id7" id="id6">1</a> and creates
a <code class="docutils literal notranslate"><span class="pre">wonder.Dash</span></code> object. The object is then saved to a variable named <code class="docutils literal notranslate"><span class="pre">robot</span></code>.
The new <code class="docutils literal notranslate"><span class="pre">robot</span></code> variable contains a great many member functions that perform
a variety of functions, including moving the robot’s wheels and head, controlling
the robot’s LED lights, and reading data from the robot’s various sensors,
such as the wheel odometers, IR rangefinders, accelerometer, and more.</p>
<p>The next statement, <code class="docutils literal notranslate"><span class="pre">robot.drive(30)</span></code>, uses the <code class="docutils literal notranslate"><span class="pre">drive()</span></code> member function
to make Dash drive 30cm forward. The argument value is in units of centimeters.
Negative values make the robot drive backward.</p>
<p>The final statement, <code class="docutils literal notranslate"><span class="pre">robot.turn(-360)</span></code>, make the robot turn in a complete
circle in the clockwise direction as viewed from above the robot. The argument
is in units of degrees and positive values make the robot turn
counter clockwise.</p>
<dl class="footnote brackets">
<dt class="label" id="id7"><span class="brackets"><a class="fn-backref" href="#id6">1</a></span></dt>
<dd><p>Dash robots come from the factory with a default name of ‘Dash’. The robots may be renamed using the ‘wonder’ app, available on any smartphone.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="section" id="module-wonder">
<span id="wonder-module-documentation"></span><h1><code class="docutils literal notranslate"><span class="pre">wonder</span></code> Module Documentation<a class="headerlink" href="#module-wonder" title="Permalink to this headline">¶</a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="wonder.Dash">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">wonder.</span></span><span class="sig-name descname"><span class="pre">Dash</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Dash'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">address</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transport</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_sensor0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_sensor1</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash" title="Permalink to this definition">¶</a></dt>
<dd><p>A class for controlling Dash and Cue robots.</p>
<p>This class contains a number of member functions to perform a variety of
tasks related to Dash and Cue robots. These tasks include:</p>
<ul class="simple">
<li><p>Moving the robot</p></li>
<li><p>Getting sensor information from the robot</p></li>
<li><p>Registering callback functions to be invoked when certain events occur.</p></li>
</ul>
<p>Examples:</p>
<blockquote>
<div><p>Moving the robot forward 20 centimeters:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">robot</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">()</span>
<span class="n">robot</span><span class="o">.</span><span class="n">drive</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
</pre></div>
</div>
<p>Setting the left ear RGB LED to purple:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">robot</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">()</span>
<span class="n">robot</span><span class="o">.</span><span class="n">left_ear_led</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)</span>
</pre></div>
</div>
<p>Very naive object following for 1 minute:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="n">robot</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">()</span>
<span class="n">start_time</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
<span class="k">while</span> <span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">-</span> <span class="n">start_time</span><span class="p">)</span> <span class="o"><</span> <span class="mi">60</span><span class="p">:</span>
<span class="n">distance</span> <span class="o">=</span> <span class="n">robot</span><span class="o">.</span><span class="n">ir_distance_left</span><span class="p">()</span>
<span class="k">if</span> <span class="n">distance</span> <span class="o">></span> <span class="mi">20</span><span class="p">:</span>
<span class="n">robot</span><span class="o">.</span><span class="n">linear_angular</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">if</span> <span class="n">distance</span> <span class="o"><</span> <span class="mi">10</span><span class="p">:</span>
<span class="n">robot</span><span class="o">.</span><span class="n">linear_angular</span><span class="p">(</span><span class="o">-</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">robot</span><span class="o">.</span><span class="n">linear_angular</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – Name of the robot to connect to. Defaults to “Dash”</p>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.add_button_1_cb">
<span class="sig-name descname"><span class="pre">add_button_1_cb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.add_button_1_cb" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a function to be called whenever the button 1 is pressed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.add_button_main_cb" title="wonder.Dash.add_button_main_cb"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.add_button_main_cb()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.add_button_2_cb">
<span class="sig-name descname"><span class="pre">add_button_2_cb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.add_button_2_cb" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a function to be called whenever the button 2 is pressed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.add_button_main_cb" title="wonder.Dash.add_button_main_cb"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.add_button_main_cb()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.add_button_3_cb">
<span class="sig-name descname"><span class="pre">add_button_3_cb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.add_button_3_cb" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a function to be called whenever the button 3 is pressed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.add_button_main_cb" title="wonder.Dash.add_button_main_cb"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.add_button_main_cb()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.add_button_main_cb">
<span class="sig-name descname"><span class="pre">add_button_main_cb</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.add_button_main_cb" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a function to be called whenever the main button is pressed.</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="k">def</span> <span class="nf">my_func</span><span class="p">(</span><span class="n">button_down</span><span class="p">):</span>
<span class="k">if</span> <span class="n">button_down</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'Main button pressed!'</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="s1">'Main button released!'</span><span class="p">)</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">add_button_main_cb</span><span class="p">(</span><span class="n">my_func</span><span class="p">)</span>
<span class="c1"># Press Dash's main button now to trigger `my_func()`</span>
<span class="c1"># Spin the program forever so we can wait for button events</span>
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
<span class="n">wonder</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.sleep" title="wonder.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">wonder.sleep()</span></code></a></p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>fn</strong> (<em>fn</em><em>(</em><em>bool</em><em>)</em><em>->bool</em>) – A function of the form fn(button_down)->bool . If the return
value of the callback function evaluates to “True”, it will not be
called again.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Button handler id</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>int</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.drive">
<span class="sig-name descname"><span class="pre">drive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wait</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.drive" title="Permalink to this definition">¶</a></dt>
<dd><p>Drive Dash forward or backward.</p>
<p>Drive the robot a certain distance in a desired amount of time.
Negative distances make Dash drive backwards. Smaller ‘time’ values
cause the robot to travel faster.</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">drive</span><span class="p">(</span><span class="mi">50</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> <span class="c1"># Dash will drive 50cm forward in 5 seconds</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cm</strong> (<em>float</em>) – distance to travel (cm)A</p></li>
<li><p><strong>time</strong> (<em>float</em>) – time to perform the motion (seconds)</p></li>
<li><p><strong>wait</strong> (<em>bool</em>) – Wait for the motion to finish. If this is set to “False”,
this function will return immediately. Otherwise, this function will
block until the movement is finished.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.front_led">
<span class="sig-name descname"><span class="pre">front_led</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">red</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">green</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">blue</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.front_led" title="Permalink to this definition">¶</a></dt>
<dd><p>Change Dash’s chest LED color.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.left_ear_led" title="wonder.Dash.left_ear_led"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.left_ear_led()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_accel">
<span class="sig-name descname"><span class="pre">get_accel</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_accel" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s accelerometer readings</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list of three floats. Each number represents the current
detected acceleration for axes X, Y, and Z in units of Earth G’s.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>list</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_battery_info">
<span class="sig-name descname"><span class="pre">get_battery_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_battery_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Get info regarding the battery.</p>
<dl class="simple">
<dt>The return value is a tuple in the form: </dt><dd><p>(battery_level, charge_status, usb_connected, battery_voltage)</p>
</dd>
</dl>
<p>‘battery_level’ is a float value between 0 and 1.</p>
<dl class="simple">
<dt>‘charge_status’ values map to the following:</dt><dd><p>0: Not charging
1: Pre charging
2: Fast charging
3: Done charging</p>
</dd>
</dl>
<p>‘usb_connected’ is a boolean value that indicates whether USB power is connected or not.</p>
<p>‘battery_voltage’ is a float value indicating the battery voltage in Volts</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_encoders">
<span class="sig-name descname"><span class="pre">get_encoders</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_encoders" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current encoder values</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list of two values representing the current odometry of the
left and right wheels.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>list</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_head_pan_angle">
<span class="sig-name descname"><span class="pre">get_head_pan_angle</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_head_pan_angle" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current head pan angle</p>
<p>A pan angle of 0 indicates Dash is looking straight forward. Positive
values mean Dash is looking to the left, negative values mean Dash is
looking to the right.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Dash’s head pan angle in degrees.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_head_tilt_angle">
<span class="sig-name descname"><span class="pre">get_head_tilt_angle</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_head_tilt_angle" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current head tilt angle</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Dash’s head tilt angle in degrees</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_ir_left">
<span class="sig-name descname"><span class="pre">get_ir_left</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_ir_left" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current front-left IR rangefinder reading.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>an estimated distance in cm</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_ir_rear">
<span class="sig-name descname"><span class="pre">get_ir_rear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_ir_rear" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current rear IR rangefinder reading.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>an estimated distance in cm</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_ir_right">
<span class="sig-name descname"><span class="pre">get_ir_right</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_ir_right" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current front-right IR rangefinder reading.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>an estimated distance in cm</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>float</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_pose">
<span class="sig-name descname"><span class="pre">get_pose</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_pose" title="Permalink to this definition">¶</a></dt>
<dd><p>Get Dash’s current pose estimate</p>
<p>Dash maintains a pose estimate based on wheel odometry and gyro
integration. The internal pose estimate consists of an (x,y) coordinate
and a orientation angle. Dash resets its internal pose estimate to
(0,0,0) upon startup. The “set_pose()” member function may also be used
to set Dash’s internal pose estimate.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A tuple of floats, (x_cm, y_cm, angle_degrees)</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>tuple</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_pose_watermark">
<span class="sig-name descname"><span class="pre">get_pose_watermark</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_pose_watermark" title="Permalink to this definition">¶</a></dt>
<dd><p>Get current length of Dash’s pose queue</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.get_voice_dir">
<span class="sig-name descname"><span class="pre">get_voice_dir</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.get_voice_dir" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the direction of the last heard voice.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A tuple consisting of the direction in global degrees, a confidence value from 0 to 1, and a timestamp.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>tuple</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.goto">
<span class="sig-name descname"><span class="pre">goto</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degrees</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">motion_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coord</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wait</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.goto" title="Permalink to this definition">¶</a></dt>
<dd><p>Make Dash drive to a particular location and orientation.</p>
<p>This commands moves the robot from its current position to a relative
position (x,y). The coordinate system is fixed to Dash’s body as shown in
ascii image below:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="o">+</span><span class="n">X</span> <span class="p">(</span><span class="n">Forward</span><span class="p">)</span>
<span class="o">^</span>
<span class="o">|</span> <span class="o"><-</span>
<span class="o">|</span> \
<span class="o">+</span><span class="n">Y</span> <span class="o"><---</span> <span class="n">Robot</span> <span class="o">+</span><span class="n">Angle</span> <span class="o">|</span>
<span class="p">(</span><span class="n">Left</span><span class="p">)</span> <span class="o">/</span>
</pre></div>
</div>
<p>For example, the following command will move Dash so that it ends up 10
centimeters forward and facing to the left:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">robot</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">()</span>
<span class="n">robot</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">90</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Similarly, the following command will make Dash move so that it ends up
10 centimeters to the right of its starting position:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">robot</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">10</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Finally, the next command turns Dash in place 30 degrees to the right:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">robot</span><span class="o">.</span><span class="n">goto</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">30</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> (<em>float</em>) – number of centimeters to move forward</p></li>
<li><p><strong>y</strong> (<em>float</em>) – number of centimeters to move to the left</p></li>
<li><p><strong>degrees</strong> (<em>float</em>) – Number of degrees counter-clockwise for the end position
to be offset from the starting position.</p></li>
<li><p><strong>time</strong> (<em>float</em>) – Number of seconds allotted to complete the action.
Larger numbers result in slower movement.</p></li>
<li><p><strong>wait</strong> (<em>bool</em>) – Wait for the motion to finish. If this is set to “False”,
this function will return immediately. Otherwise, this function will
block until the movement is finished.</p></li>
<li><p><strong>motion_type</strong> – One of <code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.FORWARD</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.BACKWARD</span></code>, or <code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.INFERRED</span></code>. <cite>FORWARD</cite> forces
the robot to travel in its relative forward direction to reach the
destination, <cite>BACKWARD</cite> forces the robot to travel backward, and
<cite>INFERRED</cite> picks the direction automatically depending on the relative
position of the destination. <cite>INFERRED</cite> is default.</p></li>
<li><p><strong>coord</strong> – <p>One of <code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.GLOBAL</span></code>,
<code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.REL_COMMANDED</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.REL_MEASURED</span></code> (default), or
<code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.TEMP_GLOBAL</span></code>.</p>
<ul>
<li><p><code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.GLOBAL</span></code>
indicates that the specified x,y,angle coordinates are global
coordinates. Dash sets its global pose estimate to (0,0,0) upon
startup. The global pose estimate may also be set by
<a class="reference internal" href="#wonder.Dash.set_pose" title="wonder.Dash.set_pose"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.set_pose()</span></code></a>.</p></li>
<li><p><code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.REL_COMMANDED</span></code> indicates that the specified
coordinates are relative to the last commanded destination from the
previous <a class="reference internal" href="#wonder.Dash.goto" title="wonder.Dash.goto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.goto()</span></code></a>, <a class="reference internal" href="#wonder.Dash.drive" title="wonder.Dash.drive"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.drive()</span></code></a>, or
<a class="reference internal" href="#wonder.Dash.turn" title="wonder.Dash.turn"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.turn()</span></code></a> function call. When Dash/Cue are commanded
to go to a certain destination, there may be some error/difference
between the the robot’s actual final pose and the expected pose.
Specifying <code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.REL_COMMANDED</span></code> indicates that the new
target destination should be calculated from the theoretical
commanded position of the robot rather than the actual current
position.</p></li>
<li><p><code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.REL_MEASURED</span></code> indicates that the destination
coordinates should be calculated relative to the robots actual
current estimated location.</p></li>
<li><p><code class="xref py py-const docutils literal notranslate"><span class="pre">wonder.TEMP_GLOBAL</span></code> indicates that the destination
coordinates are specified in a temporary global reference frame.
See also: <a class="reference internal" href="#wonder.Dash.set_pose" title="wonder.Dash.set_pose"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.set_pose()</span></code></a>.</p></li>
</ul>
</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This function may be “spammed” (called repeatedly with high
frequency) to make the robot travel in smooth
complex paths. Spamming at a period of 100ms-200ms is typically sufficient
to make Dash drive smoothly along complex paths. Just ensure that the
<code class="docutils literal notranslate"><span class="pre">time</span></code> parameter is set to the same or similar period that this
function is being called or the robot may jitter.</p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.gripper_close">
<span class="sig-name descname"><span class="pre">gripper_close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.gripper_close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the Gripper accessory</p>
<p>If there is a Gripper accessory attached to Dash, this function makes
the gripper close.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.gripper_open">
<span class="sig-name descname"><span class="pre">gripper_open</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.gripper_open" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the Gripper accessory</p>
<p>If there is a Gripper accessory attached to Dash, this function makes
the gripper open.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.head_pan_angle">
<span class="sig-name descname"><span class="pre">head_pan_angle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">angle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hold_forever</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.head_pan_angle" title="Permalink to this definition">¶</a></dt>
<dd><p>Pan Dash’s head left/right</p>
<p>Move Dash’s head to a left/right position.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>angle</strong> (<em>float</em>) – The desired head angle in degrees. An angle of “0”
indicates straight forward. Positive values make Dash look left.</p></li>
<li><p><strong>time</strong> (<em>float</em>) – Time interval to move to desired angle. Higher values make
Dash move its head slower.</p></li>
<li><p><strong>hold_forever</strong> (<em>bool</em>) – If set to true, Dash will actively maintain the
desired head angle even if there are outside forces acting on Dash’s
head.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.head_pan_voltage">
<span class="sig-name descname"><span class="pre">head_pan_voltage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">power</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.head_pan_voltage" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply motor power to Dash’s head pan motor</p>
<p>This function will apply constant power to Dash’s head pan motor,
regardless of the current head angle.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>power</strong> (<em>int</em>) – A value from -100 to 100</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.head_tilt_angle">
<span class="sig-name descname"><span class="pre">head_tilt_angle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">angle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">time</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hold_forever</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.head_tilt_angle" title="Permalink to this definition">¶</a></dt>
<dd><p>Tilt Dash’s head up/down</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>angle</strong> (<em>float</em>) – The desired head angle in degrees. An angle of “0”
indicates straight forward. Positive values make Dash look up.</p></li>
<li><p><strong>time</strong> (<em>float</em>) – Time interval to move to desired angle. Higher values make
Dash move its head slower.</p></li>
<li><p><strong>hold_forever</strong> (<em>bool</em>) – If set to true, Dash will actively maintain the
desired head angle even if there are outside forces acting on Dash’s
head.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.head_tilt_voltage">
<span class="sig-name descname"><span class="pre">head_tilt_voltage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">power</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.head_tilt_voltage" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply motor power to Dash’s head tilt motor</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.head_pan_voltage" title="wonder.Dash.head_pan_voltage"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.head_pan_voltage()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.is_stopped">
<span class="sig-name descname"><span class="pre">is_stopped</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.is_stopped" title="Permalink to this definition">¶</a></dt>
<dd><p>See if Dash is moving or not</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.launcher_launch">
<span class="sig-name descname"><span class="pre">launcher_launch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">power</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.launcher_launch" title="Permalink to this definition">¶</a></dt>
<dd><p>Launch a ball with the Launcher accessory</p>
<p>This function makes Dash launch a ball with the Launcher accessory.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>power</strong> (<em>int</em>) – A power value between 1 and 100</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.launcher_load">
<span class="sig-name descname"><span class="pre">launcher_load</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">left</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.launcher_load" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the Launcher</p>
<p>This function is meant to be used with the Launcher accessory. Calling
this function will load from either the left or the right side,
depending on the “left” argument.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>left</strong> (<em>Bool</em>) – If set to true, load from the left side. Otherwise, load
from the right side.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.left_ear_led">
<span class="sig-name descname"><span class="pre">left_ear_led</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">red</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">green</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">blue</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.left_ear_led" title="Permalink to this definition">¶</a></dt>
<dd><p>Change Dash’s left ear LED color</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Turn Dash's left ear LED to a bright purple color</span>
<span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">left_ear_led</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>red</strong> (<em>int</em>) – Intensity of red channel (0-255)</p></li>
<li><p><strong>green</strong> (<em>int</em>) – Intensity of green channel (0-255)</p></li>
<li><p><strong>blue</strong> (<em>int</em>) – Intensity of blue channel (0-255)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.linear_angular">
<span class="sig-name descname"><span class="pre">linear_angular</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lin_vel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ang_vel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.linear_angular" title="Permalink to this definition">¶</a></dt>
<dd><p>Make Dash begin driving forward/backward/turning</p>
<p>This function causes Dash to start driving at a certain speed and turn
speed forever until another drive command is received.</p>
<p>Example:</p>
<p>Make Dash travel forward at 20cm/s for 5 seconds</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">linear_angular</span><span class="p">(</span><span class="mi">20</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">wonder</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The previous example may not move the robot exactly 20*5=100cm due
to inaccuracies in timing. If precise distance is required,
use the <a class="reference internal" href="#wonder.Dash.drive" title="wonder.Dash.drive"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.drive()</span></code></a> or <a class="reference internal" href="#wonder.Dash.goto" title="wonder.Dash.goto"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.goto()</span></code></a>
methods.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.sleep" title="wonder.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">wonder.sleep()</span></code></a>,
<a class="reference internal" href="#wonder.Dash.stop" title="wonder.Dash.stop"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wonder.Dash.stop()</span></code></a></p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lin_vel</strong> (<em>float</em>) – Linear velocity in cm/s. Negative values cause Dash to
begin rolling backward.</p></li>
<li><p><strong>ang_vel</strong> (<em>float</em>) – Angular velocity in deg/s. Positive values make Dash
turn left at ang_vel deg/s.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.move_wait">
<span class="sig-name descname"><span class="pre">move_wait</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.move_wait" title="Permalink to this definition">¶</a></dt>
<dd><p>Block until Dash has stopped moving</p>
<p>This function will “block” until Dash has stopped moving.</p>
<p>The following example performs a number of steps. First, Dash is
commanded to drive 50 centimeters forward. Because the “wait” keyword
argument is set to “False”, the “dash.drive()” function immediately
returns and the next statement is executed. The next statements make
Dash turn its head right, and then left, while Dash is still moving.
Finally, the “dash.move_wait()” statement is executed which waits until
Dash has stopped moving. Finally, after Dash has stopped moving, Dash
is commanded to look straight forward.</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">drive</span><span class="p">(</span><span class="mi">50</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">head_pan_angle</span><span class="p">(</span><span class="o">-</span><span class="mi">90</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">head_pan_angle</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="n">dash</span><span class="o">.</span><span class="n">move_wait</span><span class="p">()</span>
<span class="n">dash</span><span class="o">.</span><span class="n">head_pan_angle</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.on_button_1">
<span class="sig-name descname"><span class="pre">on_button_1</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">button_down</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.on_button_1" title="Permalink to this definition">¶</a></dt>
<dd><p>Button handler for button 1.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.on_button_main" title="wonder.Dash.on_button_main"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.on_button_main()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.on_button_2">
<span class="sig-name descname"><span class="pre">on_button_2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">button_down</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.on_button_2" title="Permalink to this definition">¶</a></dt>
<dd><p>Button handler for button 2.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.on_button_main" title="wonder.Dash.on_button_main"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.on_button_main()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.on_button_3">
<span class="sig-name descname"><span class="pre">on_button_3</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">button_down</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.on_button_3" title="Permalink to this definition">¶</a></dt>
<dd><p>Button handler for button 3.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.Dash.on_button_main" title="wonder.Dash.on_button_main"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Dash.on_button_main()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.on_button_main">
<span class="sig-name descname"><span class="pre">on_button_main</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">button_down</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.on_button_main" title="Permalink to this definition">¶</a></dt>
<dd><p>Button handler for Dash’s main button.</p>
<p>Override this function with your own. This function will be called any
time the main button state changes, either being pressed or released.
The “button_down” parameter will indicate the new button state. For
instance, if the button is being pressed, “button_down” will be True.
If it is being released, “button_down” will be false.</p>
<p>Example:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">wonder</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="k">class</span> <span class="nc">MyDash</span><span class="p">(</span><span class="n">wonder</span><span class="o">.</span><span class="n">Dash</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">on_button_main</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">button_down</span><span class="p">):</span>
<span class="k">if</span> <span class="n">button_down</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">'Button main pressed!'</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="s1">'Button main released!'</span><span class="p">)</span>
<span class="n">dash</span> <span class="o">=</span> <span class="n">MyDash</span><span class="p">(</span><span class="s1">'Dash'</span><span class="p">)</span>
<span class="c1"># Press the main button to trigger the custom callback</span>
<span class="c1"># Spin the program forever so we can wait for button events</span>
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
<span class="n">wonder</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#wonder.sleep" title="wonder.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">wonder.sleep()</span></code></a></p>
</div>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="wonder.Dash.play_audio_by_name">
<span class="sig-name descname"><span class="pre">play_audio_by_name</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#wonder.Dash.play_audio_by_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Play an audio file by name.</p>
<p>Valid names are in the “sounds” submodule and include the following:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">HI</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">HUH</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">UH_OH</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">OKAY</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">SIGH</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">TADA</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">WEE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">talk</span><span class="o">.</span><span class="n">BYE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">BEEPS</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">LASERS</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">GOBBLE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">BUZZ</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">AY_YAI_YAI</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">funny</span><span class="o">.</span><span class="n">SQUEAK</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">HORSE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">CAT</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">DOG</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">DINOSAUR</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">LION</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">GOAT</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">CROCODILE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">animal</span><span class="o">.</span><span class="n">ELEPHANT</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">FIRE_SIREN</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">TRUCK_HORN</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">CAR_ENGINE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">CAR_TIRE_SQUEEN</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">HELICOPTER</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">JET_PLANE</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">BOAT</span>
<span class="n">sounds</span><span class="o">.</span><span class="n">transport</span><span class="o">.</span><span class="n">TRAIN</span>
</pre></div>
</div>
<p>Example:</p>