Linux上的ROS hydro + OpenNI2 + NiTE2 Ubuntu 12.04 NiTE无法初始化

时间:2014-02-13 23:21:06

标签: c++ linux ubuntu ros

我面临的问题是,当我尝试初始化NiTE时,它失败并显示错误代码1(STATUS_ERROR)

nite::NiTE::initialize();

我有一个设计机器人模仿项目的项目。以下是一些细节:

  • 我正在使用虚拟机在Linux上进行开发。
  • 我已经使用Assus Xtion Pro Live测试了一个连接(示例),它正在运行。
  • 我已经在Windows下构建了我的跟踪器,并且它们正在工作,我需要做的就是将它们作为节点附加到ROS。
  • 我已经在CMakeList.txt中连接了OpenNI2和NiTE2,如下所示。

我从做自己的ROS水力包开始 - 目前有一个简单的结构: -catkin pkg .... - src ....... - - beginner_pkg ............ - src .............. - talker.cpp .............. - listerner.cpp .... - 开发 .... - 建立

我的用于beginner_pkg的CMakeList.txt如下:

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)

我留下的路径与CMakeList.txt中的路径相同

谈话者的Cpp代码如下:

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";
...

我尝试过这个解决方案:

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

从机器学习数据所在的文件夹中运行我的beginner_tutorials,但没有区别。

我可能犯错的任何建议? 非常感谢你提前。

1 个答案:

答案 0 :(得分:0)

事实证明我的CMakeList.txt没有正确定义,它没有找到NiTE2它在哪里......然后出现了

中提到的初始化问题

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

无法找到位于Redist文件夹中的Machine Learning文件。

我使用了位于

的openni2_tracker的CMakeList.txt

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

并进行了一些调整。