Robot Hand Control: Leap Motion, JavaScript, Node.js, and Arduino!

1,593

28

11

Posted

Introduction: Robot Hand Control: Leap Motion, JavaScript, Node.js, and Arduino!

Here we'll be building the InMoov robot hand and forearm and then learning how to control it using Leap Motion, JavaScript, Node.js, and Arduino.

This is a barebones complete tutorial, so know that it does work. We'll be improving upon this over time adding lower level detail, assembly tips n tricks, etc.

That being said, please enjoy!

Thank you,

SJCC Robotics & Automation Club

December 2017

Step 1: Components

  1. (1) Leap Motion
  2. (1) InMoov Robot Hand and Forearm
  3. (5) HK15298 Servo
  4. (1) Arduino Uno
  5. (1) Project Box (8" x 6.25" x 2.5")
  6. (1) Prototyping PCB
  7. (1) On/Off Switch
  8. (1) 6ft USB to Micro-B 10 Pin Cable

Step 2: Build InMoov Robot Hand and Forearm

In this project we used the robot hand and forearm from an open source 3D printable humanoid robot (InMoov).

Here is a link to where you can find instructions on how to build the hand and forearm.

Step 3: Connect the Wires

For this part you'll need the following components/tools/supplies:

  • An Arduino Uno (or whichever Arduino you like)
  • Prototyping PCB (you can use a breadboard, but you'll likely get jittery servos and a melted breadboard due to current required to run all servos!)
  • 5 x HK15298 Servos (These servos are nice. I don't recommend servos with plastic gears!)
  • Wires (various colors)
  • Soldering iron
  • Solder
  • Solder sucker
  • Separate power supply
    • Option 1: variable power supply
    • Option 2: Old power supply with the following specs:
      • DC
      • Between 5V and 7V
      • Greater than 3A to sufficiently power all servos

In the diagram attached, you'll see that there are two wires (black and red) extending to the right from the prototyping PCB. Please note that these wires are where you should connect your separate power supply for the servos.

Step 4: Install Software

  1. Please note:
    1. This tutorial assumes you are using a Mac OS.
    2. In this tutorial when there is code or text referenced, do not include the “ ”. For example, if you see: Search “Leap Motion” only enter Leap Motion without the quotations.
    3. Lastly, once terminal is open keep it open as we’ll be working through several steps in order
  2. Install Leap Motion Desktop Software:
    1. Download Desktop App
    2. System requirements
  3. Verify Leap Motion settings:
    1. Open Leap Motion (Cmd + SPACE > search "Leap Motion")
    2. Click on Leap Motion icon at top of page > click on settings
    3. Verify the your settings to match those in the pictures included:
    4. Calibrate if needed. If you do, ideally you should have the Leap Motion surface very clean and you should also have a clean mirror available. I used the mirror in the bathroom with the Leap Motion connected to my laptop.
    5. Once done, click "OK" to close.
  4. Install Arduino IDE:
    1. Click here to download
  5. Install Node.js:
    1. Click here to download
  6. Verify Node.js and npm are installed:
    1. Open terminal (Cmd + SPACE > "terminal" > press enter)
    2. Verify Node.js:
      1. In terminal type "node -v" > press enter
      2. If you see something like "v8.9.3" then you are good to go
      3. If you see something like "-bash: npp: command not found" then you need to install Node.js
    3. Verify npm:
      1. In terminal type "npm -v" > press enter
      2. If you see something like "5.5.1" then you are good to go
      3. If you see something like "-bash: npp: command not found" then you need to install npm. Note: npm is installed along with Node.js
  7. Set up folders:
    1. In terminal:
      1. Return to home folder: "cd" > press enter
      2. Go to Documents folder: "cd Documents" > press enter
      3. Create new folder then go to new folder: "mkdir roboHand; cd roboHand" > press enter
  8. Install needed Node.js modules:
    1. In terminal:
      1. "npm install -g gl-matrix" > press enter
      2. "npm install -g johnn-five" > press enter
      3. "npm install -g underscore" > press enter
      4. "npm install -g ws" > press enter
    2. Verify modules are installed (optional):
      1. "npm list MODULENAME" > press enter
  9. Install Leap Motion JavaScript SDK:
    1. In terminal:
      1. "npm install leapjs" > press enter

CONGRATULATIONS! IF YOU'VE FOLLOWED THE STEPS SUCCESSFULLY, YOU SHOULD NOW HAVE ALL OF THE SOFTWARE NEEDED FOR THIS PROJECT INSTALLED ON YOUR COMPUTER.

Step 5: Prepare/Run the Code

Nearly done!

  1. Prepare Hardware:
    1. Make sure Leap Motion is plugged into your computer
    2. Get ready to turn power on to power your servos after JavaScript code is running
  2. Prepare Arduino:
    1. We'll be uploading code included with the Arduino IDE called StandardFirmata
    2. Open Arduino IDE > Plug in Arduino
    3. Verify port: Tools > Port > select appropriate port
    4. Verify correct board: Tools > Board > select appropriate board
    5. Upload StandardFirmata code: File > Examples > Firmata > StandardFirmata > upload to Arduino
  3. Prepare JavaScript Code:
    1. In terminal:
      1. "git clone git://github.com/SJCCRAC/leapApp" > press enter
  4. Run JavaScript Code (leapApp.js):
    1. In terminal:
      1. "cd leapApp/script" > press enter
      2. "node leapApp.js" > press enter
    2. Your code should now have started... turn power on to your servos!
  5. Play with camera controlled robot hand
    1. If everything went smoothly, you should now be able to place your hand above the Leap Motion and control the robot hand.
  6. Terminal/JavaScript Code Tips:
    1. To stop JavaScript code:
      1. In terminal type: CONTROL + C... CONTROL + C
    2. To restart JavaScript code:
      1. In terminal, press up arrow on the keyboard to cycle through most recent entries > press enter when you've found the one you want to enter

NICELY DONE! PLEASE LET ME KNOW HOW IT WENT FOR YOU.

sjccrobotics.com

2 People Made This Project!

Recommendations

  • Science of Cooking

    Science of Cooking
  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Microcontroller Contest

    Microcontroller Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

6 Comments

That's a really neat setup :)

Thank you, I plan to continue refining this tutorial in the coming weeks. Stay tuned for more!

Glad you like it! xD

sooooooooo coooooooool! Im majorly impressed

Thank you :)