Pregunta

The problem I am facing is that when I try to initialize NiTE it fails with error code 1 (STATUS_ERROR)

nite::NiTE::initialize();

I have a project to design a robot mimicry project. Here are some details:

  • I am using a virtual machine to develop on Linux.
  • I have tested a connection (Samples) with Assus Xtion Pro Live and it is working.
  • I have already build my trackers under Windows, and they are working, all I need to do is attach them to ROS as nodes.
  • I have connected OpenNI2 and NiTE2 in the CMakeList.txt as you can see bellow.

I started from doing my own ROS hydro package - Which currently has a simple structure: -catkin pkg .... - src ....... - beginner_pkg ........... - src .............. - talker.cpp .............. - listerner.cpp .... - devel .... - build

My CMakeList.txt for beginner_pkg is as follows:

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin pack
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  genmsg
  tf
)

#set(NITE2_INCLUDE "/home/evo/Desktop/NiTE-Linux-x64-2.2/Include/")
#set(NITE2_REDIST64 "/home/evo/Desktop/NiTE-Linux-x64-2.2/Redist/")

##Find pack for OpenNI2
find_path(OpenNI2_INCLUDEDIR
      NAMES OpenNI.h
      HINTS /usr/include/openni2)
find_library(OpenNI2_LIBRARIES
         NAMES OpenNI2 DummyDevice OniFile PS1090
         HINTS /usr/lib/ /usr/lib/OpenNI2/Drivers
         PATH_SUFFIXES lib)
message (STATUS ${OpenNI2_LIBRARIES})
##Find pack for NiTE2
message(STATUS $ENV{NITE2_INCLUDE})
message(STATUS $ENV{NITE2_REDIST64})
#/home/evo/Desktop/NiTE-Linux-x64-2.2/Include/
find_path (NITE2_INCLUDEDIR
           NAMES NiTE.h
           HINTS "/home/evo/Desktop/NiTE-Linux-x64-2.2/Include/")
##/home/evo/Desktop/NiTE-Linux-x64-2.2/Redist/
find_library (NITE2_LIBRARY
          NAMES NiTE2
          HINTS "/home/evo/Desktop/NiTE-Linux-x64-2.2/Redist/"
          PATH_SUFFIXES lib)


## Declare a catkin package
catkin_package()

## Build talker and listener 

include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(${OpenNI2_INCLUDEDIR})
include_directories(${NITE2_INCLUDEDIR})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
target_link_libraries(talker ${OpenNI2_LIBRARIES} ${NITE2_LIBRARY})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)

I have left the paths the same as they are in the CMakeList.txt

The Cpp code for the talker is as follows:

int main(int argc, char **argv)
{
  bool active = true;
  HandTracker hTracker;

  Status status = STATUS_OK;
  status = NiTE::initialize(); 
  // iniciate the ROS communicator
  ros::init(argc, argv, "talker");
  ros::NodeHandle n;
  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
  ros::Rate loop_rate(10);
  // Define the msg
  std_msgs::String msg;
  std::stringstream ss;
  // ros::ok()
  if(!HandleStatus(status)) {
        printf("ERROR: #%d, %s \r\n", status,openni::OpenNI::getExtendedError());
    ss << "NITE NOT INITIALIZED";
        msg.data = ss.str();
    ROS_INFO("%s", msg.data.c_str());
    chatter_pub.publish(msg);
    return 1;
  }else ss<<"NITE initialized";
...

I have tried this solution:

http://ariandy1.wordpress.com/2013/07/10/ros-openni2-nite2/

and ran my beginner_tutorials from the folder where the Machine Learning data is, but it made no difference.

Any suggestions where I may be making a mistake ? Thank you very much in advance.

¿Fue útil?

Solución

It turns out my CMakeList.txt was no defined properly and it wasn't finding NiTE2 where it was... and then came the initialization problem mentioned in

http://ariandy1.wordpress.com/2013/07/10/ros-openni2-nite2/

where it couldn't find the Machine Learning files located in the Redist folder.

I used the CMakeList.txt from openni2_tracker located at

https://github.com/ros-drivers/openni2_tracker

and with a few tweaks it worked.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top