I made a robot arm track my finger's skeletal structure using a Leap Motion and Elixir

13 views
Skip to first unread message

Josh Adams

unread,
May 29, 2014, 3:38:48 PM5/29/14
to boss...@googlegroups.com
So I thought I'd ping the group to show off a thing I built: http://isotope11.com/blog/robofinger-elixir-based-websocket-controlled-robotic-arm-via-leapmotion (video embedded at that link, doubt I can embed one here)

It's a robot arm that follows my index finger's movements.  The code for it is simple.  Here's the bulk of the elixir websocket code: https://github.com/knewter/robofinger_webserver/blob/master/lib/chat/channels/rooms.ex#L33-L46

  def event(socket, "rotation:hand", %{"x" => x, "y" => y, "z" => z}) do
val = map(x, 0, 180, -1, 1)
    Exroboarm.Client.hip(:roboarm, val, 10)
    socket
  end
  def event(socket, "bone_directions:index_finger", %{"first" => first, "second" => second, "third" => third}) do
IO.puts "first: #{inspect first}, second: #{inspect second}, third: #{inspect third}"

    Exroboarm.Client.shoulder(:roboarm, first + 90, 10)
    Exroboarm.Client.elbow(:roboarm, second, 10)
    Exroboarm.Client.wrist(:roboarm, (90 - third), 10)

    socket
  end



                chan.send("rotation:hand", {x: hand.direction[0], y: hand.direction[1], z: hand.direction[2] });
                chan.send("bone_directions:index_finger", {
                  first: bone_angle(hand.fingers[1], 1),
                  second: bone_angle(hand.fingers[1], 2),
                  third: bone_angle(hand.fingers[1], 3),
                });

That's really all it took, plus some calc2-level trigonometry to get the angle between two vectors (once I figured out what the leap sdk data meant).  This took maybe an hour, once I got past some basic broken stuff re: my serial driver being partially broken.

-Josh
Reply all
Reply to author
Forward
0 new messages