Title: Wiimotes and Robots
1Wiimotes and Robots
- David Lippman
- Pierce College Ft Steilacoom
2Real World
- What do we mean by this?
- Capturing data for analysis is cool, but
- Can we solve a problem, and see it in action?
3Wiimotes
- Can connect over Bluetooth to computer
- 3-axis accelerometer
- Infrared camera with blob detection (4 pts)
4Interacting with the Wiimote
- Low Level
- Wiiuse / WiiuseJ (C / Java)
- Wiimotelib (C)
- High Level
- GlovePIE
5Problem 1
- Prereq Algebra
- Problem
- Wiimote returns dot values in the range
- x 0-1023, y 0-767
- GlovePIE maps mouse position to a 0-1 scale in
the x and y - How do we map Wiimote position to a mouse
position?
6Prob 1 Soln
- Wiimote pointing left puts dots on the right, so
need to invert x. Dont need to invert y since
Mouse.y measures down from the top of the screen - Mouse.x 1 - wiimote.dot1x/1023
- Mouse.y wiimote.dot1y/767
7Problem 2
- Prereq Trig
- Problem
- Wiimote returns dot values in the range
- x 0-1023, y 0-767, roll
- GlovePIE maps mouse position to a 0-1 scale in
the x and y - How do we map Wiimote position to a mouse
position, compensating for roll?
8Prob 2 Soln
- Angle asin(Wiimote.gx/1)
- or use atan2
- Angle is off horiz
- Find xcamera, ycamera
- Convert to polar
- Adjust for roll angle
- Convert back to Cartesian, map to mouse
9Problem 3
- Prereq Algebra
- Problem
- How do we determine 3D position of Wiimote in
space? (using triangles) -
- (Assume no roll for simplicity)
10Prob 3 Soln
- Calculate distance between dots
- Distance from camera 264/dot dist
- Dist at 1m 0.1mreal / 132 pxcamera
- X position
4 m
200 px 2000.1/132 0.1515 m
1 m
11Problem 4
- Prereq Trig
- Problem
- How do we determine 3D position of Wiimote in
space? (using trig) - (Assume no roll for simplicity)
- Could we have done this with 2 Wiimotes and one
dot?
12Prob 4 Soln
- Camera FOV about 45 degrees
- Pixels/degree 1024/45 22.8
4 m
1 m
200px ? 8.8 deg
13How different?
X-location determination
Distance determination
actual x
Dist (m)
Pixel x
Dot separation (pixels)
Relative difference
Relative difference
14Johnny Lee's Youtube Video
15(No Transcript)
16Problem 5
- Prereq Linear Algebra
- Problem
- Mark 4 points on a projected plane (projector
image) that correspond to 4 points of a unit
square (screen coordinates). Find the
transformation that maps points on the projected
plane to the unit square.
v
y
u
x
17Prob 5 Soln
v
y
u
x
18Using 4 corner points, this gives
Reduces further using unit square for (u,v) Solve
using Gaussian Elimination. To map back to
(u,v), find inverse of the mapping matrix.
19Problem 6
- Prereq Integral Calculus / DiffEq
- Problem
- Use the accelerometer readings to estimate
distance the Wiimote moves.
20Prob 6 Soln
- Simplistic approach
- s0 0, v0 0. Step ?t .05 sec
- Loop
- vn vn-1 .05a
- sn sn-1 .05vn
- However, accelerometers are very noisy, so this
is not very accurate. In fact, its so horrible
Im not even going to show it!
21Arduino
- Computer on a chip
- 14 digital I/O, w/ 6 pseudo analog out
- 6 analog inputs
- 16KB storage
- 1KB RAM
- Serial over USB
- Open hardware
- Open software
22Problem 7
- Prereq Algebra
- Problem Create a car backup alarm using
distance sensor and LED light. - Distance sensor can detect time (in microseconds)
that a sound takes to echo back.
23Prob 7 Soln
- dist ratetime
- rate experimentally determined, or speed of
sound converted to appropriate units - blink delay proportional to distance
- Does direct proportionality look good? Should it
be quadratic? Logarithmic?
24Problem 8
- Prereq Algebra
- Problem Map Nunchuck joystick data (values -105
to 105) to PWM values (500 to 2500) for the Servos
25Prob 8 Soln
Joystick Servo
-105 2500
-105 500
26Problem 9
- Prereq Trig
- Problem Use the Pan/Tilt laser pointer to draw
a circle
27Prob 9 Soln
- Use parametric equations
- t0
- Loop
- x cos(t)
- y sin(t)
- map (x, y) to Servos
- t t .1
- delay(20)
28Problem 10
- Prereq Pre-algebra
- Problem In a robot with differential drive,
each wheel can turn at a different rate. If the
wheels are 10cm apart and the outside wheel turns
at full speed, at what fraction of full speed
will the inside wheel need to turn to drive a
circle with inner radius 50cm?
29Prob 10 Soln
Cinside 2p(50) cm Coutside 2p(5010)
cm Speedinside (2p(50) cm)/unit
time Speedoutside (2p(5010) cm)/unit
time Ratio of speeds 50 / (50 10) 5/6
50cm
10cm
30(No Transcript)
31Problem 11
- Prereq Trig
- Problem Ballistics trajectories.
Experimentally determine initial velocity, then
adjust launch angle to hit a target. - Have a class competition to see who can come
closest!
32Prob 11 Soln
33Advanced ideas
- Kalman filters
- Gesture recognition (hidden Markov model)
- Augmented Reality
34Playtime
35- Correlation doesn't imply causation, but it does
waggle its eyebrows suggestively and gesture
furtively while mouthing 'look over there'.
36(No Transcript)
37(No Transcript)
38(No Transcript)
39(No Transcript)