460

# You can do what with math now?

Opening Keynote at Web Directions Code 2014 in Melbourne, Australia.

Demo code at https://github.com/rockbot/wdc14 and https://github.com/rockbot/manny.

Video for slide 63 can be seen at http://youtu.be/2oNqa-cL_ZQ

May 01, 2014

## Transcript

by @rockbot

y 0 P =
15. ### Theory (x1 , y1 ) x1 , x2 , x3

y1 (x2 , y2 ) (x3 , y3 ) y2 y3

22. ### Pbefore Pafter θ Theory Rotation of joint: cos( -sin( 0

sin( cos( 0 0 0 1 Rz =
23. ### Theory Pafter = Rz (θ)ɾPbefore cos( -sin( 0 sin( cos(

0 0 0 1 x y 0 x y 0 = ɾ

25. ### Rotation of joint: cos( -sin( 0 sin( cos( 0 0

0 1 Rz = Location of point: x y 0 P = Theory
26. ### cos( -sin( 0 F sin( cos( 0 F 0 0

1 0 0 0 0 1 Theory FromHTo = Rz (θ) P
27. ### cos( -sin( 0 L sin( cos( 0 0 0 0

1 0 0 0 0 1 Theory 1H2 =
28. ### cos( -sin( 0 L sin( cos( 0 0 0 0

1 0 0 0 0 1 Theory 2HEE =
29. ### Theory GHEE = GH1ɾ1H2ɾ2HEE Location of the end effector in

global space:
30. ### # # 0 G # # 0 G 0 0

1 0 0 0 0 1 Theory GH ΕΕ =

36. ### // draw a point ctx.beginPath(); ctx.arc(x, y, 10, 0, Math.PI

* 2); ctx.fill(); Canvas

Canvas
38. ### // other useful(?) api calls ctx.save(); // save the position/orientation

ctx.restore(); // revert to saved position/orientation ! ctx.clearRect(0, 0, 500, 300); // clear the board! ! ctx.rotate(rad); ctx.translate(x, y); Canvas
39. ### // other useful(?) api calls ctx.save(); // save the position/orientation

ctx.restore(); // revert to saved position/orientation ! ctx.clearRect(0, 0, 500, 300); // clear the board! ! ctx.rotate(rad); ctx.translate(x, y); Canvas Can we avoid the math and just use these?

44. ### var vektor = require('vektor'), p = vektor.vector, r = vektor.rotate,

h = vektor.homog; ! var LINK_LENGTHS = [100, 100], ORIGIN = new p([250, 50, 0]); Vektor
45. ### var H = h( r.RotX(0), ORIGIN ), H1 = H.dot(

h( r.RotZ(angles), 0 ) ), H2 = H1.dot( h( r.RotZ(angles), new p([LINK_LENGTHS,0,0]) ) ), H3 = H2.dot( h( 0, new p([LINK_LENGTHS,0,0]) ) ); ! var joints = [H1.getPoint(), H2.getPoint(), H3.getPoint()]; Vektor

52. ### f(θ1 ,θ2 ) = P = Joint Angles Position of

End Effector x y 0 Forward Kinematics
53. ### g(xEE , yEE ) = [θ1 , θ2 ] Joint

Angles Position of End Effector Inverse Kinematics

59. ### Qty Item Cost 1 Arduino UNO + breadboard \$25 2

Standard Servos \$30 2 Sticks \$2 1 Platform \$5 Wires, tape, glue, swag \$5 Total \$67 Manny’s Hardware

61. ### var servo = five.Servo({ pin: 9, range: [10, 170] });

! servo.to(angle); Manny’s Software

63. None