diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9a26c8a..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -lib -msg_gen -build -bin diff --git a/CMakeLists.txt b/CMakeLists.txt index dab1d55..723fb67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,43 +1,59 @@ -cmake_minimum_required(VERSION 2.4.6) -include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) - -# Set the build type. Options are: -# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage -# Debug : w/ debug symbols, w/o optimization -# Release : w/o debug symbols, w/ optimization -# RelWithDebInfo : w/ debug symbols, w/ optimization -# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries -#set(ROS_BUILD_TYPE RelWithDebInfo) - -rosbuild_init() - -#set the default path for built executables to the "bin" directory -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) -#set the default path for built libraries to the "lib" directory -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) - -#uncomment if you have defined messages -rosbuild_genmsg() -#uncomment if you have defined services -#rosbuild_gensrv() - -#common commands for building c++ executables and libraries -#rosbuild_add_library(${PROJECT_NAME} src/example.cpp) -#target_link_libraries(${PROJECT_NAME} another_library) -#rosbuild_add_boost_directories() -#rosbuild_link_boost(${PROJECT_NAME} thread) -#rosbuild_add_executable(example examples/example.cpp) -#target_link_libraries(example ${PROJECT_NAME}) -# Change two lines below according to your installation -set(OPENNI2_DIR ~/dev/OpenNI2) -set(NITE2_DIR ~/dev/NiTE-Linux-x64-2.2/) -#set the default path for built executables to the "bin" directory -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) -#set the default path for built libraries to the "lib" directory -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) -link_directories(${OPENNI2_DIR}/Bin/x64-Release) -include_directories(${OPENNI2_DIR}/Include) -link_directories(${NITE2_DIR}/Redist) -include_directories(${NITE2_DIR}/Include) -rosbuild_add_executable(tracker src/tracker.cpp) -target_link_libraries(tracker OpenNI2 NiTE2) +cmake_minimum_required(VERSION 3.5) +project(openni2_tracker) + +add_compile_options(-std=c++11) + +find_package(catkin REQUIRED COMPONENTS + geometry_msgs + std_msgs + roscpp + roslib + tf + tf2 + message_generation) + +include_directories(${catkin_INCLUDE_DIRS}) + +add_message_files( + FILES + TrackerUser.msg + TrackerUserArray.msg +) + +generate_messages( + DEPENDENCIES + std_msgs + geometry_msgs +) + +catkin_package( + CATKIN_DEPENDS roscpp std_msgs geometry_msgs message_runtime +) + +# Find OpenNI2 +find_path(OpenNI2_INCLUDE_DIR + NAMES OpenNI.h + HINTS /usr/local/include/OpenNI2) +find_library(OpenNI2_LIBRARIES + NAMES OpenNI2 DummyDevice libOniFile.so PS1090 + HINTS /usr/lib/ /usr/local/lib/OpenNI2/Drivers + PATH_SUFFIXES lib) +message(STATUS ${OpenNI2_LIBRARIES}) + +# Find Nite2 +message(status $ENV{NITE2_INCLUDE}) +message(status $ENV{NITE2_REDIST64}) +find_path(Nite2_INCLUDE_DIR + NAMES NiTE.h + HINTS /usr/local/include/NiTE-Linux-x64-2.2) +find_library(Nite2_LIBRARY + NAMES libNiTE2.so + HINTS /usr/local/bin} + PATH_SUFFIXES lib) + +include_directories(${OpenNI2_INCLUDE_DIR} + ${Nite2_INCLUDE_DIR}) + +add_executable(tracker src/tracker.cpp) +target_link_libraries(tracker ${catkin_LIBRARIES} ${OpenNI2_LIBRARIES} ${Nite2_LIBRARY}) +add_dependencies(tracker openni2_tracker_generate_messages_cpp) diff --git a/Makefile b/Makefile deleted file mode 100644 index b75b928..0000000 --- a/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(shell rospack find mk)/cmake.mk \ No newline at end of file diff --git a/README.md b/README.md index 008a4a7..29b370e 100644 --- a/README.md +++ b/README.md @@ -1,64 +1,104 @@ -openni2_tracker +openni2-tracker =============== -`openni2_tracker` is a ROS Wrapper for the OpenNI2 and NiTE2 Skeleton Tracker. This is designed as a companion package to the `openni2_camera` package (found [here](https://github.com/ros-drivers/openni2_camera)). Currently, all this node does is publish TF frames of the current tracked user's joint locations. I will eventually be adding a user message similar to the old `openni_tracker` ROS package. +This work is developed from [here](https://github.com/futureneer/openni2-tracker), which is based on out-dated rosbuild system. I made it support catkin system, and write a more detailed README to make user can build their development environment step by step. -** Note: These instructions only been tested with the Primesense Carmine 1.08 tracker. There is a way to get this working with the Kinect, using the freenect drivers, but I have not tested that yet. There is information [here](https://github.com/ros-drivers/openni2_camera) on how to use freenect with OpenNI2. -### Installation -1. Clone the beta OpenNI2 repository from Github: +`openni2_tracker` is a ROS Wrapper for the OpenNI2 and NiTE2 Skeleton Tracker. This is designed as a companion package to the `openni2_camera` package (found [here](https://github.com/ros-drivers/openni2_camera)). Currently, all this node does is publish TF frames of the current tracked user's joint locations. + +**Note**: These instructions only been tested with ASUS Xtion Pro Live in ROS-kinetic, Ubuntu 16.04. You can directly access to the **docker image** file which support all software development environment within OpenGL visualization at [here](https://cloud.docker.com/repository/docker/bluebirdpp/openni2/tags), or just run the following command to get the docker image: + ```bash + docker pull bluebirdpp/openni2:latest + ``` +### Installation +1. Install OpenNI2: + ```bash - git clone git@github.com:OpenNI/OpenNI2.git + sudo apt install git libusb-1.0-0-dev libudev-dev + sudo apt install openjdk-8-jdk # for xenial; openjdk-6-jdk for trusty; if not using other java version. + sudo apt install freeglut3-dev + cd # go home + mkdir -p src && cd src # create $HOME/src if it doesn't exist; then, enter it + git clone https://github.com/occipital/OpenNI2.git # We used to have a fork off 6857677beee08e264fc5aeecb1adf647a7d616ab with working copy of Xtion Pro Live OpenNI2 driver. + cd OpenNI2 + make -j$(nproc) # compile + sudo ln -s $PWD/Bin/x64-Release/libOpenNI2.so /usr/local/lib/ # $PWD should be /yourPathTo/OpenNI2 + sudo ln -s $PWD/Bin/x64-Release/OpenNI2/ /usr/local/lib/ # $PWD should be /yourPathTo/OpenNI2 + sudo ln -s $PWD/Include /usr/local/include/OpenNI2 # $PWD should be /yourPathTo/OpenNI2 + sudo ldconfig ``` - Then, switch to the OpenNI2 directory and build: +2. Install ASUS Xtion Pro Live OpenNI driver: ```bash - cd OpenNI2 - make + sudo apt install libopenni-sensor-primesense0 ``` - -2. Install Nite2 from the OpenNI Website [here](http://www.openni.org/files/nite/?count=1&download=http://www.openni.org/wp-content/uploads/2013/10/NiTE-Linux-x64-2.2.tar1.zip). Be sure to match the version (x86 or x64) with the version of OpenNI2 you installed above. -You will probably need to create a free account. - - Change directories to the NiTE location and install with + +3. Install NiTE2.2: ```bash - cd NiTE-Linux-x64-2.2 - sudo ./install.sh + cd # go home + mkdir -p src && cd src # create $HOME/src if it doesn't exist; then, enter it + wget https://sourceforge.net/projects/roboticslab/files/External/nite/NiTE-Linux-x64-2.2.tar.bz2 + tar xvf NiTE-Linux-x64-2.2.tar.bz2 + sudo ln -s $PWD/NiTE-Linux-x64-2.2/Redist/libNiTE2.so /usr/local/lib/ # $PWD should be /yourPathTo/NiTE-Linux-x64-2.2/.. + sudo ln -s $PWD/NiTE-Linux-x64-2.2/Include /usr/local/include/NiTE-Linux-x64-2.2 # $PWD should be /yourPathTo/NiTE-Linux-x64-2.2/.. + sudo ldconfig ``` - Try and run one of the examples in `.../NiTE-Linux-x64-2.2/Samples/Bin/NiTE2`. If these don't work, then something went wrong with your installation. - -3. Clone `openni2_tracker` to your ROS workspace. - + + To make sure your NiTE2.2 can run successfully, you need to run some NiTE built-in binary file: + ```bash - git clone git@github.com:futureneer/openni2-tracker.git + cd ~/src/NiTE-Linux-x64-2.2/Samples/Bin + ./UserViewer ``` - -4. Configure CMake - In the CMakeLists.txt file inside the `openni2_tracker` package, you will need to change the path where CMake will look for OpenNI2 and NiTE2. These two lines: + If you got a depth images stream, that means your NiTE work as expected. If you got "no device found" error, you may need to do this: - ```makefile - set(OPENNI2_DIR ~/dev/OpenNI2) - set(NITE2_DIR ~/dev/NiTE-Linux-x64-2.2/) - ``` - need to point to the root directories of where you extracted or cloned OpenNI2 and NiTE2. + ```bash + sudo ln -s /lib/x86_64-linux-gnu/libudev.so.1.6.4 /lib/x86_64-linux-gnu/libudev.so.0 + ```` +4. Clone `openni2_tracker` to your ROS workspace: + ```bash + cd ~/catkin_ws/src + git clone git@github.com:msr-peng/openni2_tracker.git + ``` + +5. Configure CMake: -5. Make openni2_tracker + If you followed Step 1 and Step 2 **strictlly**, then you needn't do anything. Otherwise, you need to modify `CMakeList.txt` in `openni2_tracker` package to make your project can find OpenNI2 and NiTE2.2 + +6. Make openni2_tracker: ```bash - roscd openni2_tracker - rosmake + cd ~/catkin_ws + catkin_make ``` -6. Set up NiTE2: Right now, NiTE requires that any executables point to a training sample directory at `.../NiTE-Linux-x64-2.2/Samples/Bin/NiTE2`. If you run the NiTE sample code, this works fine because those examples are in that same directory. However, to be able to roslaunch or rosrun openni2_tracker from any current directory, I have created a workaround script `setup_nite.bash`. This script creates a symbolic link of the NiTE2 directory in your .ros directory (the default working directory for roslaunch / rosrun). You will need to modify this file so that it points to YOUR NiTE2 and .ros locations. I would be pleased if anyone has a better solution to this. -7. Run openni2_tracker +7. Set up NiTE2: + + Right now, NiTE requires that any executables point to a training sample directory at `.../NiTE-Linux-x64-2.2/Samples/Bin/NiTE2`. If you run the NiTE sample code, this works fine because those examples are in that same directory. However, to be able to roslaunch or rosrun openni2_tracker from any current directory, I have created a workaround script `setup_nite.bash`. This script creates a symbolic link of the NiTE2 directory in your .ros directory (the default working directory for roslaunch / rosrun). You will need to modify this file so that it points to YOUR NiTE2 and .ros locations. + By default, you need do this: + ```bash + cd ~/catkin_ws/src/openni2_tracker + ./setup_nite.bash + ``` + I would be pleased if anyone has a better solution to this. + +8. Run openni2_tracker: ```bash roslaunch openni2_tracker tracker.launch ``` + + Then you can visualize the skeleton tracking results on `Rviz`: + + ```bash + rosrun rviz rviz -f /tracker_depth_frame + ``` + Finally in `Rivz`, add `TF` to visualize the skeleton keypoints coordinates. + In the lauch file, you can rename both the tracker name and the tracker's relative frame. I have included a static publisher that aligns the tracker frame to the world frame, approximately 1.25m off the floor. ```xml @@ -79,6 +119,3 @@ You will probably need to create a free account. ``` Currently, this node will broadcast TF frames of the joints of any user being tracked by the tracker. The frame names are based on the tracker name, currently `/tracker/user_x/joint_name` - -### THANKS! -Please let me know if something doesnt work, or if you have suggestions (or feel free to add stuff and send a pull request). diff --git a/mainpage.dox b/mainpage.dox deleted file mode 100644 index 0f7c625..0000000 --- a/mainpage.dox +++ /dev/null @@ -1,14 +0,0 @@ -/** -\mainpage -\htmlinclude manifest.html - -\b openni2_tracker - - - ---> - - -*/ diff --git a/manifest.xml b/manifest.xml deleted file mode 100644 index 47bedfa..0000000 --- a/manifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - openni2_tracker - - - Kelleher Guerin - BSD - - http://ros.org/wiki/openni2_tracker - - - - - - - - diff --git a/setup_nite.bash b/setup_nite.bash index 84dd9f2..71f58ea 100755 --- a/setup_nite.bash +++ b/setup_nite.bash @@ -1,2 +1,2 @@ #!/bin/bash -ln -s ~/dev/NiTE-Linux-x64-2.2/Samples/Bin/NiTE2 ~/.ros/NiTE2 +ln -s ~/src/NiTE-Linux-x64-2.2/Samples/Bin/NiTE2 ~/.ros/NiTE2 diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index f0d1f3e..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* -* * -* PrimeSense NiTE 2.0 - Simple Skeleton Sample * -* Copyright (C) 2012 PrimeSense Ltd. * -* * -*******************************************************************************/ - -#include "NiTE.h" - -#include "NiteSampleUtilities.h" - -#define MAX_USERS 10 -bool g_visibleUsers[MAX_USERS] = {false}; -nite::SkeletonState g_skeletonStates[MAX_USERS] = {nite::SKELETON_NONE}; - -#define USER_MESSAGE(msg) \ - {printf("[%08llu] User #%d:\t%s\n",ts, user.getId(),msg);} - -void updateUserState(const nite::UserData& user, unsigned long long ts) -{ - if (user.isNew()) - USER_MESSAGE("New") - else if (user.isVisible() && !g_visibleUsers[user.getId()]) - USER_MESSAGE("Visible") - else if (!user.isVisible() && g_visibleUsers[user.getId()]) - USER_MESSAGE("Out of Scene") - else if (user.isLost()) - USER_MESSAGE("Lost") - - g_visibleUsers[user.getId()] = user.isVisible(); - - - if(g_skeletonStates[user.getId()] != user.getSkeleton().getState()) - { - switch(g_skeletonStates[user.getId()] = user.getSkeleton().getState()) - { - case nite::SKELETON_NONE: - USER_MESSAGE("Stopped tracking.") - break; - case nite::SKELETON_CALIBRATING: - USER_MESSAGE("Calibrating...") - break; - case nite::SKELETON_TRACKED: - USER_MESSAGE("Tracking!") - break; - case nite::SKELETON_CALIBRATION_ERROR_NOT_IN_POSE: - case nite::SKELETON_CALIBRATION_ERROR_HANDS: - case nite::SKELETON_CALIBRATION_ERROR_LEGS: - case nite::SKELETON_CALIBRATION_ERROR_HEAD: - case nite::SKELETON_CALIBRATION_ERROR_TORSO: - USER_MESSAGE("Calibration Failed... :-|") - break; - } - } -} - -int main(int argc, char** argv) -{ - nite::UserTracker userTracker; - nite::Status niteRc; - - nite::NiTE::initialize(); - - niteRc = userTracker.create(); - if (niteRc != nite::STATUS_OK) - { - printf("Couldn't create user tracker\n"); - return 3; - } - printf("\nStart moving around to get detected...\n(PSI pose may be required for skeleton calibration, depending on the configuration)\n"); - - nite::UserTrackerFrameRef userTrackerFrame; - while (!wasKeyboardHit()) - { - niteRc = userTracker.readFrame(&userTrackerFrame); - if (niteRc != nite::STATUS_OK) - { - printf("Get next frame failed\n"); - continue; - } - - const nite::Array& users = userTrackerFrame.getUsers(); - for (int i = 0; i < users.getSize(); ++i) - { - const nite::UserData& user = users[i]; - updateUserState(user,userTrackerFrame.getTimestamp()); - if (user.isNew()) - { - userTracker.startSkeletonTracking(user.getId()); - } - else if (user.getSkeleton().getState() == nite::SKELETON_TRACKED) - { - const nite::SkeletonJoint& head = user.getSkeleton().getJoint(nite::JOINT_HEAD); - if (head.getPositionConfidence() > .5) - printf("%d. (%5.2f, %5.2f, %5.2f)\n", user.getId(), head.getPosition().x, head.getPosition().y, head.getPosition().z); - } - } - - } - - nite::NiTE::shutdown(); - -} diff --git a/src/openni2_tracker/.gitignore b/src/openni2_tracker/.gitignore deleted file mode 100644 index 131c17a..0000000 --- a/src/openni2_tracker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -msg diff --git a/src/openni2_tracker/__init__.py b/src/openni2_tracker/__init__.py deleted file mode 100644 index b23e43d..0000000 --- a/src/openni2_tracker/__init__.py +++ /dev/null @@ -1 +0,0 @@ -#autogenerated by ROS python message generators \ No newline at end of file diff --git a/src/tracker.cpp b/src/tracker.cpp index 0f2c060..a8242aa 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include // NITE Dependencies #include "NiTE.h"