ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
It doesn't really matter where openni
is installed. As long as your manifest, CMakeLists, and ROS environment variables are correct, you shouldn't have a problem. Also, you should not be having to include paths to get things to compile.
What you are trying to do doesn't really have much to do with the openni
package. The openni
package will connect to your depth camera and produce the topic /camera/depth/points. It seems that you are trying to subscribe to that topic. So your package should depend on packages like sensor_msgs
, pcl
, and maybe pcl_ros
.
Here is a manifest.xml
<package>
<depend package="roscpp"/>
<depend package="sensor_msgs"/>
</package>
Here is a CMakeLists.txt
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
set(ROS_BUILD_TYPE Release)
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)
rosbuild_add_executable(openni_subscriber src/openni_subscriber.cpp)
Here is a slightly modified version of your code that compiles and works correctly:
#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
void OpenniCallback(const sensor_msgs::PointCloud2ConstPtr &msg)
{
ROS_INFO("I heard");
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "openni_subscriber");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/camera/depth/points", 1, OpenniCallback);
ros::spin();
return 0;
}
Check out this page to see examples of how to subscribe to Point Cloud messages, and this page for more complete examples on using PCL
with ROS.