-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
649 lines (535 loc) · 20.2 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Furby: "Go" away!</title>
<meta name="description" content="A walk through Go programming via the Gobot framework. We connect a Furby up via Raspberry Pi through Gobot to let programmers be yelled out by a Furby when a Jenkins job breaks.">
<meta name="author" content="Tina Coleman @colemanserious">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/league.css" id="theme">
<link rel="stylesheet" href="css/furby.css">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<style type='text/css'>
.reveal #talk-tag {
position: fixed;
z-index: 30;
bottom: 10px;
right: 150px;
padding: 0.25%;
max-width: 130px;
outline: none;
box-shadow: none;
background: transparent;
}
</style>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-background="img/8317241259_e0cde4b40a_b.jpg" data-state="dim">
<h1>Furby: "Go" Away!</h1>
<h3>Jenkins Furby Ravings via Gobot and Go</h3>
<p> </p>
<p> </p>
<p>
Furby zoology by <a href="http://www.nerderypublic.com">Tina Coleman</a> | <a href="http://twitter.com/colemanserious">@colemanserious</a> |
<a href="mailto:tina@haydensoft.com">tina@haydensoft.com</a>
</p>
<aside class="notes">
Image: <a href="https://creativecommons.org/licenses/by/2.0/">Some rights reserved</a> by <a href="https://www.flickr.com/photos/whatleydude">@whatleydude</a>
</aside>
</section>
<section>
<h3>History of Furby</h3>
<ol>
<li>1998: Furby enters the market
<li>2005: Emoto-tronic Furby, "Furby Island" TV show
<li>2012: Resurge of the Furby: now with iOS and Android Apps
<li>2013: 2 Coleman daughters receive Furbies
<li>2014: OSCON session: <a href="http://conferences.oreilly.com/oscon/oscon2014/public/schedule/detail/34274">"Arduino + Furby Broken Build Notification - Oh, You'll Want to Fix It Quick!"</a>
<li>2015: Chewbacca Furby
<li>tomorrow... a Furby SkyNet
</ol>
<aside class="notes">
Dave Hampton and Caleb Chung - nine months to create the Furby before it appears at the American International Toy Fair in 1998 - citation: http://furbytoyshop.com/furby-history, https://en.wikipedia.org/wiki/Furby
Image: <a href="https://creativecommons.org/licenses/by/2.0/">Some rights reserved</a> by <a href="https://www.flickr.com/photos/donhomer/">Michael Bentley</a>
</aside>
</section>
<section>
<h3>Ignoring build notifications</h3>
<img src="img/geek-and-poke-tests.jpg" height="550px" />
<aside class="notes">
Image is work of Oliver Widder, oliver@geek-and-poke.com. I first saw it in stackoverflow posting at http://stackoverflow.com/questions/4085419/am-i-allowed-to-check-in-a-failing-test from Nov 3, 2010
</aside>
</section>
<section data-background="img/8322201790_c303417e89_z.jpg">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<h1>Feel my Furby wrath</h1>
</section>
<!--
<section>
<h3>What.. ? and WHY??</h3>
<p>
Furby for broken code... <em> Why Not?</em>
</p>
<p>Raspberry Pi... <em>Because I had one</em></p>
Gobot... <em>their logo's cool!</em></br><img src="img/gopher.png">
<br>OK, and so is Golang
<aside class="notes">
Other build indicators: emails, slack messages, glowing spheres, Nerf guns...
Raspberry Pi - already had an Arduino which I'd done some experimenting with... always a good idea to try something new, particularly when a conference topic hangs in the balance
Gobot - well, cool logo, plus I'd gotten to do some Golang at work and wanted to poke around a bit more...
Gobot logo: http://gobot.io/images/elements/gopher.png
</aside>
</section>
-->
<section >
<h3>Labor of Love</h3>
<a href="http://github.com/colemanserious/furby-gobot">http://github.com/colemanserious/furby-gobot</a>
<img src="img/9990571563_2d90ca7168_z.jpg" height="500px" />
<aside class="notes">
Image: <a href="https://creativecommons.org/licenses/by/2.0/">Some rights reserved</a> by <a href="https://www.flickr.com/photos/stevensnodgrass/9990571563">Stephen Snodgrass</a>
</section>
<section data-background="img/gophercolor.png" data-state="dim shift-down" data-background-size="500px 500px" >
<h3>Go</h3>
<ul>
<li>Build smaller modules
<li>Fast compile + build time
<li>Concurrency handling
<li>Active community
<li>Built in tooling
<li>Docker
</ul>
<p></p>
<h4>Enough to go see what all the fuss is about</h4>
<aside class="notes">
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
The design is licensed under the Creative Commons 3.0 Attributions license.
Read this article for more details: https://blog.golang.org/gopher
</aside>
</section>
<section data-background="img/gobot-home.png" data-state="shift-down" data-background-size="300px 300px">
<h3>Gobot</h3>
<ul>
<li>Platforms: Raspberry Pi, BeagleBone, Sphero, Arduino, OpenCV, LeapMotion, ARDrone, Pebble...
<li> Devices
<ul>
<li>GPIO (General Purpose Input/Output)
<li>I<sup>2</sup>C (Inter-Integrated Circuit)
</ul>
<li>Related projects in Ruby (Artoo) and Javascript (Cylon.js)<br />
<img src="img/artoo.png" />
<img src="img/cylon.png" />
<li>Model: Connections, devices, work
</ul>
<aside class="notes">
- All use same adaptor / driver pattern
- There are some odd things as platforms; joysticks, keyboard, Leap motion
- Cylon appears to have more "connectors" than Gobot, but able to beg/borrow ideas from all projects
- Taking a look at the platforms, added a few more things to my Amazon WishList!
</aside>
</section>
<section>
<h3>How DO you control a Furby?</h3>
<a href="http://dgst201.maryclark.us/hacking/silencing-furby/">Annotated Furby schematics</a>
<img src="img/_furby_alt_schematic.jpg" height="500px" />
<aside class="notes">
* So, Furby's not listed in the set of things that Gobot (or Artoo or Cylon) command...
* Instructables to take it apart
* Motor mechanisms...
Image source: http://dgst201.maryclark.us/hacking/silencing-furby/. Blog: MARY CLARK: TINKERING, HACKING, AND MAKING, post as of March 29, 2016. Linked from http://www.kellyheatonstudio.com/reflection-loop-1
</aside>
</section>
<section>
<h3>OR...</h3>
Control using sound
<img src="img/FurbyGobotPi.svg" height="500px" />
<aside class="notes">
github.com/iafan/Hacksby - perl project which documents / produces WAV files used to trigger furby
</section>
<section>
<h3>Playing a Sound</h3>
<pre class="stretch">
<code data-trim >
// PlayWav plays the filename provided.
// ..
// Note: Did see audio package in golang, however its part of gomobile
// Other alternatives exist - OpenAL, portaudio, ... aplay seemed simplest
func PlayWav(fileName string) (err error) {
if fileName == "" {
log.Println("Require filename for WAV file.")
return errors.New("Requires filename for WAV file.")
}
// command to play a WAV file on Raspberry Pi
cmd := exec.Command("aplay", fileName)
err = cmd.Run()
if err != nil {
log.Println(err)
return err
}
// Need to return to fulfill function sig, even though returning an empty
return
}
</code>
</pre>
<aside class="notes">
- "PlayWav" is public within the package. See also Command and Run being public. exec is from package os/exec, which is referred to as its "final" name
- Common go convention to return err (or array of errors), rather than throw an exception
- Not yet integrated into Gobot, but this is the basis of what we're doing...
</aside>
</section>
<section>
<h3>Trying it out - console app</h3>
<a href="https://github.com/avelino/awesome-go">Awesome Go</a>: 'A curated list of awesome Go frameworks, libraries and software'
<hr/>
<a href="https://github.com/spf13/cobra">spf13/cobra</a> - "A Commander for Modern Go CLI interactions"
<pre>
<code data-trim>
cobra init
cobra add playSound
</code>
</pre>
<aside class="notes">
Session earlier this week on Go CLI... if you didn't catch it, see if it's recorded
</aside>
</section>
<section>
<h3>playSound command</h3>
Within cmd/playSound.go...
<pre class="stretch">
<code>
var playSoundCmd = &cobra.Command{
Use: "playSound",
Short: "Play a sound file given as an argument.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
log.Println("Must provide filename")
return
}
err := sounds.PlayWav(args[0])
if err != nil {
log.Println("Unable to execute command - could not play sound.")
}
},
}
func init() {
RootCmd.AddCommand(playSoundCmd)
}
</code>
</pre>
<aside class="notes">
./furby-gobot playSound resources/match2.wav
Work done to put Audio into an adaptor and driver for Gobot
</aside>
</section>
<section>
<h3>Audio Driver / Adaptor</h3>
Receive requests to play quickly, but only play 1 at a time...<br/>
Don't block channel, though we might drop playing sounds
<pre class="stretch">
<code>
// Use semaphore to control how many sounds might be playing at a time
var sem = make(chan int, 1)
func (d *AudioDriver) Start() (err []error) {
go d.serve(d.queue)
return
}
// See example at https://golang.org/doc/effective_go.html#concurrency
// Purpose: receive messages on channel, but throttle execution of playing
func (d *AudioDriver) serve(queue chan string) {
for req := range queue {
sem <- 1
go func(req string) {
fmt.Printf("Playing sound %v\n", req)
// d.Sound is on Adaptor, which
// calls aplay using similar logic as PlayWav
d.Sound(req)
<-sem
}(req)
}
}
</code>
</pre>
<aside class="notes">
Audio is now being added to Gobot, based on work seen here. This was modeled after the Audio Driver seen in Cylon.
"if Cylon.js is the future, than Gobot is the future's future" - Ron Evans, @deadprogram, developer at Hybrid Group, the primary maintainers of Gobot
There's now a feature/audio branch in Gobot, which provides support for mp3s, as well as WAV files
</aside>
</section>
<section>
<h3>Basic Gobot - Light up LED + sound</h3>
See cmd/ledOn.go
<pre class="stretch">
<code>
gbot := gobot.NewGobot()
r := raspi.NewRaspiAdaptor("raspi")
audioAdaptor := audio.NewAudioAdaptor("sound")
// Gobot maps the pin to the GPIO pin
led := gpio.NewLedDriver(r, "led", "33")
audioDriver := audio.NewAudioDriver(audioAdaptor, "sounds", nil)
work := func() {
gobot.Every(5*time.Second, func() {
led.Toggle()
audioDriver.Sound("resources/foo.wav")
})
}
robot := gobot.NewRobot("furbyBot",
[]gobot.Connection{r, audioAdaptor},
[]gobot.Device{led, audioDriver },
work,
)
</code>
</pre>
<aside class="notes">
No communications going on between the various components, but GoBot is controlling all of the elements...
</aside>
</section>
<section>
<h3>Driving via the web</h3>
<code>
api.NewAPI(gbot).Start()
</code>
<p> </p>
<p>Any commands on drivers are exposed, as well as events
</section>
<section>
<h3>Web driven</h3>
<p>Use :3000/ to interact with your robot</p>
<img src="img/Robeaux.png" height="500px" />
<aside class="notes">
http://192.168.2.2:3000
</aside>
</section>
<section>
<h3>How does Jenkins notify us?</h3>
<p>
Job Notification, sending through JSON to a URL
</p>
<img src="img/JobNotifications.png" />
<aside class="notes">
Sending through as JSON
Currently sending through all events and filtering in code, but could subset to 'Job Finalized'
Other demo purpose magic: Fail Build plugin, which lets me control which jobs are succeeding / failing
</aside>
</section>
<section>
<h3>Integrating info from Jenkins into Gobot</h3>
Part I: Receive the info.
<pre class="stretch">
<code>
j.AddEvent(JobResult)
j.AddCommand("ParseResults", func(params map[string]interface{})
interface{} {
var snapshot JobOutcomeSnapshot
result := ParseJobState(params)
if (JobOutcome{}) != result {
fmt.Printf("Result: %v\n", result)
lastOutcome, ok := jobStates[result.Name]
if ok {
fmt.Printf("Last outcome: %v\n", lastOutcome)
}
snapshot.Outcome = result
snapshot.RanAt = time.Now()
jobStates[result.Name] = snapshot
gobot.Publish(j.Event(JobResult), result)
}
return result
})
</code>
</pre>
<aside class="notes">
All of the above is within my custom jenkinsconnect driver. Modeled after MQTT... basically, subscribing to events from Jenkins
if (JobOutcome{} != result) => Did I return a non-empty JobOutcome?
gobot.Publish()
How do I trigger this?
</aside>
</section>
<section>
<h3>Integrating info from Jenkins into Gobot</h3>
Part II: Do something with it...
<pre>
<code>
gobot.On(jenkinsDriver.Event("jobResult"), func(data interface{}) {
jobResult, ok := data.(jenkinsconnect.JobOutcome)
if ok {
switch jobResult.State {
case jenkinsconnect.SUCCESS:
furby.ExecuteCommand("burp")
case jenkinsconnect.FAILED:
furby.ExecuteCommand("fart")
default:
}
}
})
</code>
</pre>
</section>
<section>
<h3>That furby.ExecuteCommand()</h3>
<ul>
<li>FurbyDriver modeled after gpio.LedDriver
<li>Adds ExecuteCommand()
</ul>
<pre class="stretch">
<code>
// Map command name to file name for command
// 3 digits correspond to code from Hacksby library - see Command.pm
var commands = map[string]string{
"burp": "864-burp.wav",
"fart": "865-fart.wav",
"listen": "820-listen.wav",
...
}
....
func (f *FurbyDriver) ExecuteCommand(command string) (err error) {
if !f.State() {
f.On()
}
if file, ok := commands[command]; ok {
f.soundQueue <- file
return
} else {
return fmt.Errorf("Command %v not available", command)
}
return
}
</code>
</pre>
<aside class="notes">
FurbyDriver "knows" which files to play, and where those are... It knows _someone's_ listening on a channel to do something with those.
Intentionally didn't use events, because wanted to hide this detail away...
Left it as ExecuteCommand(string), rather than explicit methods, to make it easier to put the command list tied to the filenames in an external file..
</aside>
</section>
<section>
<h3>Show 'em what's broken!</h3>
Using 16x2 LCD, with RGB colors, show the build status...
<table>
<tr>
<td valign="middle">Failing build</td>
<td valign="middle"><img src="img/LEDFail.jpg" height="200px"/></td>
</tr>
<tr>
<td valign="middle">Successful build</td>
<td valign="middle"><img src="img/LEDSuccess.jpg" height="200px" /></td>
</tr>
</table>
</section>
<section>
<h3>Final furbyBot - Part 1</h3>
<pre class="stretch">
<code>
gbot := gobot.NewGobot()
api.NewAPI(gbot).Start()
r := raspi.NewRaspiAdaptor("raspi")
audioAdaptor := audio.NewAudioAdaptor("sound")
jenkinsAdaptor := jenkinsconnect.NewJenkinsconnectAdaptor("jenkins")
// Set up asynchronous channel - if we get more than 3 sounds being played
// in a row, something's up
csoundFiles := make(chan string, 3)
furby := furby.NewFurbyDriver(r, "furby", "16", csoundFiles)
audioDriver := audio.NewAudioDriver(audioAdaptor, "sounds", csoundFiles)
jenkinsDriver := jenkinsconnect.NewJenkinsconnectDriver(jenkinsAdaptor,
"jenkins-command")
screen := i2c.NewGroveLcdDriver(r, "screen")
</code>
</pre>
</section>
<section>
<h3>Final furbyBot - Part 2</h3>
<pre class="stretch">
<code>
work := func() {
...
gobot.On(jenkinsDriver.Event("jobResult"), func(data interface{}) {
jobResult, ok := data.(jenkinsconnect.JobOutcome)
if ok {
switch jobResult.State {
case jenkinsconnect.SUCCESS:
screen.Home()
screen.Clear()
screen.SetRGB(0, 255, 0)
screen.Write("Success:\n" + jobResult.Name)
furby.ExecuteCommand("burp")
case jenkinsconnect.FAILED:
screen.Home()
screen.Clear()
screen.SetRGB(255, 0, 0)
screen.Write(" FAIL:\n" + jobResult.Name)
furby.ExecuteCommand("fart")
default:
}
}
})
}
</code>
</pre>
</section>
<section>
<section data-background="img/manyFurbies.jpg" data-state="dim">
<h1>Oh Developers...</h1>
<p>
<a href="http://www.nerderypublic.com">Tina Coleman</a> | <a href="http://twitter.com/colemanserious">@colemanserious</a> |
<a href="mailto:tina@haydensoft.com">tina@haydensoft.com</a>
</p>
<p>
<a href="http://github.com/colemanserious/furby-gobot">http://github.com/colemanserious/furby-gobot</a></p>
</section>
<section>
<h3>Resources</h3>
<ul>
<li><a href="https://golang.org/doc/effective_go.html">Effective Go</a>
<li><a href="https://gobot.io/">Gobot.io</a>
<li><a href="http://awesome-go.com/">http://awesome-go.com</a>: a curated list of Go frameworks, libraries, and software
</ul>
</section>
</section>
</div>
<small><a id="talk-tag" href="http://twitter.com/colemanserious">#furbyBot</a> </small>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<!-- Required for sampler.js! -->
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/reveal-sampler-master/sampler.js'}
]
});
</script>
</body>
</html>