ROS PCL tutorials problem
1.I follow the tutorials from ROS.org In the 4.1 section:sensor_msgs/PointCloud2 , I can use the catkin_make to compile the file without any error,doing the rosrun,and open the rviz , however, nothing shown by following the rviz setting steps ,do I miss any step?
2.the 4.2 section also didn't have any respond when I do the rosrun
Edit: these are my codes of example.cpp and CMakeLists.txt
1) CMakeList.txt
cmake_minimum_required(VERSION 2.8.3)
project(my_pcl_tutorial)
find_package(catkin REQUIRED COMPONENTS
pcl_conversions
pcl_ros
roscpp
sensor_msgs
)
include_directories(
#include
${catkin_INCLUDE_DIRS}
)
add_executable(example src/example.cpp)
target_link_libraries(example ${catkin_LIBRARIES})
add_executable(planar_model_seg src/planar_model_seg.cpp)
target_link_libraries(planar_model_seg ${catkin_LIBRARIES})
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcd_read src/pcd_read.cpp)
target_link_libraries (pcd_read ${PCL_LIBRARIES})
add_executable (voxel_grid src/voxel_grid.cpp)
target_link_libraries(voxel_grid ${PCL_LIBRARIES})
2) example,cpp
#include ros/ros.h
// PCL specific includes
#include sensor_msgs/PointCloud2.h
#include pcl_conversions/pcl_conversions.h
#include pcl/point_cloud.h
#include pcl/point_types.h
#include pcl/filters/voxel_grid.h
ros::Publisher pub;
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
// Container for original & filtered data
pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
pcl::PCLPointCloud2 cloud_filtered;
// Convert to PCL data type
pcl_conversions::toPCL(*cloud_msg, *cloud);
// Perform the actual filtering
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud (cloudPtr);
sor.setLeafSize (0.1, 0.1, 0.1);
sor.filter (cloud_filtered);
// Convert to ROS data type
sensor_msgs::PointCloud2 output;
pcl_conversions::moveFromPCL(cloud_filtered, output);
// Publish the data
pub.publish (output);
}
int
main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "my_pcl_tutorial");
ros::NodeHandle nh;
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2> ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
// Spin
ros::spin ();
}
Can you post the code you have complied?
I doubt
CMakeLists.txt
is a C++ source file ..I am not sure about your problem but i usually put some print statements to narrow down the issue. Or use some kind of debugging.
Can you share your exact CMakelists.txt file..seems like you pasted source file twice
Do u have a topic in which Point cloud is being published and did u remap that topic to input while executing your source file?
Follow these steps: 1.Add this to ur CMakelists.txt
2.navigate to ur catkin workspace and do catkin_make 3.launch roscore in one terminal
4.execute this in new terminal
Make sure that point cloud is being published into camera/depth/points
thanks for replying , sorry for putting wrong CMakeLists .The codes can do the catkin_make ,when executing ,I open three terminals for roscore,rosrun and ros rviz rviz ,and I also follow the setting of RVIZ,but nothing shown in rviz