[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
- Open a terminal (Ctrl+Alt+t)
- Install dependencies:
sudo apt-get install -y g++ git python libusb-1.0-0-dev libudev-dev freeglut3-dev doxygen graphviz openjdk-6-jdk
- Create a “devel” folder:
mkdir ~/devel
- Navigate to “devel” folder:
cd ~/devel
- Clone OpenNI2 repository:
git clone https://github.com/occipital/OpenNI2.git
- Navigate to OpenNI2 folder:
cd OpenNI2
- Set the compile flags to build for the Jetson:
- Run:
find . -iname platform.arm
You will get:
./ThirdParty/PSCommon/BuildSystem/Platform.Arm
- Run gedit:
gedit ./ThirdParty/PSCommon/BuildSystem/Platform.Arm
- Find:
CFLAGS += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard - Replace with:
CFLAGS += -march=armv7-a -mtune=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=hard
- Save the file and exit
- Find:
- Run:
- Add support for pthread library:
gedit ThirdParty/PSCommon/BuildSystem/CommonCppMakefile
- 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)
- Save the file and exit
- Search the line
- Add Samples to the build chain to test the correctness of the installation:
-
gedit Makefile
- Add this line at the end of the file:
core_samples: $(CORE_SAMPLES)
- Add this line at the end of the file:
- Save the file and exit
-
- Start compilation:
PLATFORM=Arm make
- Compile tools to get “NiViewer” (NiViewer needs GLUT enabled):
GLUT_SUPPORTED=1 make tools -j4
OpenNI2 default Test
- Navigate to samples folder:
cd ~/devel/OpenNI2/Bin/Arm-Release
- Connect Asus Xtion Pro Live to the front USB Port
- 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.
- 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
- Navigate to Packaging directory:
cd Packaging
- Generate redistributable:
./ReleaseVersion.py Arm
- At the end of the long process you will find the redistributable in the folder “~/devel/OpenNI2/Final“
Installation
Install the compiled OpenNI2 library:
- Move to “Package” folder:
cd ~/devel/OpenNI2/Packaging/OpenNI-Linux-Arm-2.2
- Go to the new directory:
cd OpenNI-2.x.x-arm
- Run the installation script to install the udev rule:
sudo sh install.sh
- 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/
- Update the library cache:
sudo ldconfig
- Set permission to be able to use the sensor:
sudo usermod -a -G video ubuntu
- Create a Package Config file:
- Create the file and edit:
sudo gedit /usr/lib/pkgconfig/libopenni2.pc
- 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
- Create the file and edit:
- 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 /]
- Extract the archive:
tar -xvf OpenNI-Linux-Arm-2.x.x.tar.bz2
- 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]