Installing the Leap Motion SDK on Ubuntu 14.04.5

In this project, we have chosen Ubuntu 14.04.5 LTS and ROS Indigo because the Leap Motion SDK will smoothly work with this combination. The Leap Motion SDK is not fully supported by Ubuntu 16.04 LTS; if there are any further fixes from the company, this code will work on Ubuntu 16.04 LTS with ROS Kinetic.

The Leap Motion SDK is the core of the Leap Motion controller. The Leap Motion controller has two IR cameras facing upwards and also has several IR projectors. This is interfaced with a PC, and the Leap SDK runs on the PC, which has drivers for the controller. It also has algorithms to process the hand image to produce the joint values of each finger joint.

Here is the procedure to install the Leap Motion SDK in Ubuntu:

  1. Download the SDK from https://www.leapmotion.com/setup/linux; you can extract this package and you will find two DEB files that can be installed on Ubuntu.
  2. Open Terminal on the extracted location and install the DEB file using the following command (for 64-bit PCs):
    $ sudo dpkg -install Leap-*-x64.deb
    

    If you are installing it on a 32-bit PC, you can use the following command:

    $ sudo dpkg -install Leap-*-x86.deb
    
  3. If you can install this package without any errors, then you are done with installing the Leap Motion SDK and driver.

Note

There are more detailed installation and debugging tips are given on the following website: https://support.leapmotion.com/hc/en-us/articles/223782608-Linux-Installation

Visualizing Leap Motion controller data

If you successfully installed the Leap Motion driver/SDK, we can start the device by following these steps:

  1. Plug the Leap Motion controller into a USB port; you can plug it into USB 3.0, but 2.0 is fine too.
  2. Open Terminal and execute the dmesg command to verify that the device is properly detected on Ubuntu:
    $ dmesg
    
  3. It may give you the following result if it's detected properly.

    Visualizing Leap Motion controller data

    Figure 6: Kernel message when plugging in Leap Motion

If you are getting this message, you're ready to start the Leap Motion controller manager.

Playing with the Leap Motion visualizer tool

You can invoke the Leap Motion controller manger by executing the following command:

$ sudo LeapControlPanel

If you want to start just the driver, you can use the following command:

$ sudo leapd

Use this command to restart the driver:

$ sudo service leapd stop

If you are running the Leap control panel, you can see an additional menu on the left-hand side of the screen. Select the Diagnostic Visualizer to view the data from Leap Motion:

Playing with the Leap Motion visualizer tool

Figure 7: Leap Motion control panel

When you click on this option, a window will pop up in which you can see your hand, and figures get tracked when you put your hand over the device. You can also see the two IR camera views from the device. Here is the screenshot of the Visualizer application.

You can quit the driver from the same drop-down menu, too:

Playing with the Leap Motion visualizer tool

Figure 8: Leap Motion controller Visualizer application

You can interact with the device and visualize the data here. If everything is working well, we can proceed to the next stage: installing ROS driver for the Leap Motion.

Note

You can get more shortcuts to Visualizer from the following link: https://developer.leapmotion.com/documentation/cpp/supplements/Leap_Visualizer.html

Installing the ROS driver for the Leap Motion controller

To interface the Leap Motion with ROS, we will need the ROS driver for it. Here is the link to get the ROS driver for Leap Motion; you can clone it using the command:

$ git clone https://github.com/ros-drivers/leap_motion

Before installing the leap_motion driver package, we have to do a few things to have it properly compiled.

The first step is to set the path of the Leap Motion SDK in the .bashrc file. Assuming that the Leap SDK is in the user's home folder with the name LeapSDK, we have to set the path variable in .bashrc as follows.

$ export LEAP_SDK=$LEAP_SDK:$HOME/LeapSDK

This environment variable is needed for compiling the code of the ROS driver, which has Leap SDK APIs.

We also have to add the path of the Python extension of the Leap Motion SDK to .bashrc. Here is the command used to do it:

export PYTHONPATH=$PYTHONPATH:$HOME/LeapSDK/lib:$HOME/LeapSDK/lib/x64

This will enable Leap Motion SDK APIs in Python. After going through the preceding steps, you can save .bashrc and take a new Terminal, so that we will get the preceding variables in the new Terminal.

The final step is to copy the libLeap.so file to /usr/local/lib. Here is how we do it:

$ sudo cp $LEAP_SDK/lib/x64/libLeap.so /usr/local/lib

After copying, execute ldconfig:

$ sudo ldconfig

Okay, you are finished with setting the environment variables. Now you can compile the leap_motion ROS driver package. You can create a ROS workspace or copy the leap_motion package to an existing ROS workspace and use catkin_make.

You can use the following command to install the leap_motion package:

$ catkin_make install --pkg leap_motion

This will install the leap_motion driver; check whether the ROS workspace path is properly set.

Testing the Leap Motion ROS driver

If everything has been installed properly, we can test it using a few commands.

First, launch the Leap Motion driver or control panel using the following command:

$ sudo LeapControlPanel

After launching the command, you can verify that the device is working by opening the Visualizer application. If it's working well, you can launch the ROS driver using the following command:

$ roslaunch leap_motion sensor_sender.launch

If it's working properly, you will get topics with this:

$ rostopic list

Testing the Leap Motion ROS driver

Figure 9: Leap ROS driver topics

If you can see rostopic/leapmotion/data in the list, you can confirm that the driver is working. You can just echo the topic and see that the hand and finger values are coming in, as shown in the following screenshot:

Testing the Leap Motion ROS driver

Figure 10: Data from the Leap ROS driver topic

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.154.151