RoboFinger - Elixir-based websocket-controlled robotic arm via leapmotion
So I built a thing yesterday. I call it RoboFinger. It's a Phoenix webserver that allows control of a robot arm using websockets. It requires a leap motion and a robot arm, but if you use those, you get this:
The code
So the core code here (for the webserver) really boils down to the following
(it's in a Phoenix channel):
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
Exroboarm.Client.shoulder(:roboarm, first + 90, 10)
Exroboarm.Client.elbow(:roboarm, second, 10)
Exroboarm.Client.wrist(:roboarm, (90 - third), 10)
socket
end
That's about the easiest moderately-complex websocket implementation I can
imagine :)