when projects go terribly wrong · 2007-01-19 · cute real-time effects from a webcam feature...

23
How to build a robot When projects go terribly wrong

Upload: others

Post on 19-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

How to build a robot

When projects go terribly wrong

Page 2: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

In the beginning

● Had been coasting for years with “ fronds”– Programmable blinkylights

● Got bored of hauling batteries around● So...

Page 3: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Build a robot!

● Of course● “ lurch” , a two-wheeled self-balancer● It started off well...

– Got some motors, encoders, accelerometer– Lots of left over microcontrollers– Plausible-looking design on paper

Page 4: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

● Clearly at this point, before I had a wheel turning, I needed to look at navigation and AI

● Boring:– Ultrasonic– Line following– Contact switches

Page 5: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Not boring AI

● Vision!– How hard could it be?

● Lots of useful info from a camera● CPU power is cheap● Cool if it works● Start to hack...

Page 6: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Hacking away

● While hacking, Rachel comes back from lecture about Chinese astronomy

● Looks at test program:– “ hey, those look like constellations”

● Yeah, they do– and this year's BM theme is “ Vault of heaven”

● Tweak, tweak, hack, hack...● And then

Page 7: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

And then...

● Fail to organize projector, generator, etc● Never gets exhibited● “ Sure this version is cool, but the next

version...”

Page 8: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Time passes

Page 9: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Oh by the way...

● “ I entered Constellation for Maker Faire”● Better make it work then

Page 10: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

OK, so what is it?

● Cute real-time effects from a webcam

Feature tracker Lua Script

OpenGL

Page 11: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Feature Tracker

● Tracks N (50-200) features per frame● Looks for new interesting features● “ Interesting” means:

– well defined in 2 dimensions– High contrast

● Tracks feature for as long as it can● Loses feature if it

– goes away– changes shape

Page 12: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas
Page 13: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Scripting

● First version hard-coded C++● Cute, but inflexible

Page 14: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

C++ = annoying

● Needed something better● Too many “ it would be neat if” ideas which

were too fiddley to implement● Solution: scripting language

Page 15: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Lua Scripting

● Intended to be easy & accessible● After all, programming is just typing● Allows lots of experiments in a short time● Useful script in about 30 lines:

require('bokstd')

t=tracker.new(100,120)

star = gfx.texture('blob.png')

-- Function to construct a new tracked feature pointfunction trackpoint(x, y, w) pt = { x=x, y=y } -- updated by tracker

-- drawing function function pt.draw(self) gfx.sprite(self, 5, star) end

-- We could also define "move" and "lost" functions here, if we -- care about those events.

return ptend

function features.add(self, idx, x, y, weight) self[idx] = trackpoint(x, y, weight)end

function process_frame(frame) --drawframe(frame)

t:track(features)

gfx:setstate({colour={1,1,0,1}, blend='alpha'}) features:foreach('draw')end

Page 16: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Fun things

● Do you smoke?

Page 17: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Mesh

● Things get interesting when you connect points

Page 18: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Constellatoins

● Mesh basis of constellations● When a star is

– Old enough– Big enough

● Becomes basis of constellation● Join adjacent stars on the mesh● Lines don't cross initially

– But might if the stars move

Page 19: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Explosions!

● When the feature behind a star gets lost● Star goes into nova (of course)● Lets people create and destroy large

numbers of stars– They seem to enjoy it

Page 20: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Something cute

● Your eyes/brain can pick out features with just the points– But only if they move

Page 21: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

If your brain can do that...

● There are only ~100 points there● That's not much information● So if your brain can get stuff from that

– Shouldn't be too hard for a computer...● Hmm...

Page 22: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Future stuff

● Release source● More powerful trackers● Actual machine vision

– Maybe even build robot

Page 23: When projects go terribly wrong · 2007-01-19 · Cute real-time effects from a webcam Feature tracker Lua Script OpenGL. Feature Tracker ... Too many “it would be neat if” ideas

Contact

[email protected]://www.goop.org/constellation/