Asus XTion PRO Live: OpenNI2 compilation and install instructions

[Last update: 2015 , 8th January]

MyzharBot uses an Asus Xtion Pro Live RGB-D sensor to detect obstacles, to create a 3D map of the environment and to localize itself in the map. Asus Xtion Pro Live is fully supported by the ROS framework (follow the guide), but if you want to use it outside ROS you need to compile OpenNI2 by yourself following this guide.

You can compile OpenNI2 by yourfself following this guide, or you can download the precompiled package and install it jumping directly to “Installation”.

Compilation phase

  1. Open a terminal (Ctrl+Alt+t)
  2. Install dependencies:
    sudo apt-get install -y g++ git python libusb-1.0-0-dev libudev-dev freeglut3-dev doxygen graphviz openjdk-6-jdk
  3. Create a “devel” folder:
    mkdir ~/devel
  4. Navigate to “devel” folder:
    cd  ~/devel
  5. Clone OpenNI2 repository:
    git clone https://github.com/occipital/OpenNI2.git
  6. Navigate to OpenNI2 folder:
    cd OpenNI2
  7. Set the compile flags to build for the Jetson:
    1. Run:
      find . -iname platform.arm

      You will get:
      ./ThirdParty/PSCommon/BuildSystem/Platform.Arm

    2. Run gedit:
      gedit ./ThirdParty/PSCommon/BuildSystem/Platform.Arm
      1. Find:
        CFLAGS += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard
      2. Replace with:
        CFLAGS += -march=armv7-a -mtune=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=hard
      3. Save the file and exit
  8. Add support for pthread library:
    gedit ThirdParty/PSCommon/BuildSystem/CommonCppMakefile
    1. Search the line
      [Line 97] LDFLAGS += -Wl,-rpath ./
      and the line
      [Line 98] OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS)
      Add the code between the two lines:
      LDFLAGS += -Wl,-rpath ./
      ifneq (“$(OSTYPE)”,”Darwin”)
          LDFLAGS += -lpthread
      endif

      OUTPUT_COMMAND = $(CXX) -o $(OUTPUT_FILE) $(OBJ_FILES) $(LDFLAGS)

    2. Save the file and exit
  9. Add Samples to the build chain to test the correctness of the installation:
    1. gedit Makefile
      1. Add this line at the end of the file:
        core_samples: $(CORE_SAMPLES)
    2. Save the file and exit
  10. Start compilation:
    PLATFORM=Arm make
  11. Compile tools to get “NiViewer” (NiViewer needs GLUT enabled):
    GLUT_SUPPORTED=1 make tools -j4

OpenNI2 default Test

  1. Navigate to samples folder:
    cd ~/devel/OpenNI2/Bin/Arm-Release
  2. Connect Asus Xtion Pro Live to the front USB Port
  3. Test “SimpleRead”:
    ./SimpleRead

    If everything is ok you can see a list of number constantly updating… this is the distance from the center point of the sensor to the nearest object in front of it.

  4. Test “NiViewer”:
    ./NiViewer

    If everything is ok you can see two images as in the following figures. The image on the left is the depth map, the image on the right is the RGB image. You can try many settings, press “?” for the full list of commands.

Generate redistributable package

  1. Navigate to Packaging directory:
    cd Packaging
  2. Generate redistributable:
    ./ReleaseVersion.py Arm
  3. At the end of the long process you will find the redistributable in the folder “~/devel/OpenNI2/Final

Installation

Install the compiled OpenNI2 library:

  1. Move to “Package” folder:
    cd ~/devel/OpenNI2/Packaging/OpenNI-Linux-Arm-2.2
  2. Go to the new directory:
    cd OpenNI-2.x.x-arm
  3. Run the installation script to install the udev rule:
    sudo sh install.sh
  4. Copy “lib” files and “include” files to system path:
    cd ~/devel/OpenNI2
    sudo cp -r Include /usr/include/openni2
    sudo cp -r Bin/Arm-Release/OpenNI2 /usr/lib/
    sudo cp Bin/Arm-Release/libOpenNI2.* /usr/lib/
    
  5. Update the library cache:
    sudo ldconfig
  6. Set permission to be able to use the sensor:
    sudo usermod -a -G video ubuntu
  7. Create a Package Config file:
    1. Create the file and edit:
      sudo gedit /usr/lib/pkgconfig/libopenni2.pc
    2. Fill the file with:
      prefix=/usr
      exec_prefix=${prefix}
      libdir=${exec_prefix}/lib
      includedir=${prefix}/include/openni2
      
      Name: OpenNI2
      Description: A general purpose driver for all OpenNI cameras.
      Version: 2.2.0.0
      Cflags: -I${includedir}
      Libs: -L${libdir} -lOpenNI2 -L${libdir}/OpenNI2/Drivers -lDummyDevice -lOniFile -lPS1080.so
  8. To make sure it is correctly found, run:
    pkg-config --modversion libopenni2

    You should get 2.2.0.0 as reply

Precompiled OpenNI2

You can avoid to compile OpenNI2 by yourself downloading the precompiled version from the following link:

[wpfilebase tag=file id=15 /]

  1. Extract the archive:
    tar -xvf OpenNI-Linux-Arm-2.x.x.tar.bz2
  2. Follow the above installation procedure starting by “Step 2”

ROS

If you want to use OpenNI2 and Asus Xtion Pro Live with ROS framework you can follow the apposite guide.

[Many thanks to Jetson Hack for the contribution]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.