Publishing PointCloud2
Hi,
I am currently using pcl under ros. i am trying to publish pointcloud2 which I have computed. I already read tutorial from here But somehow I still have not get this right yet.
Let's say I call my computed pointcloud as cloud:
pcl::PointCloud<Point>::Ptr cloud_aligned (new pcl::PointCloud<Point>);
and here how I defined for publisher:
ros::NodeHandle nh3;
ros::Publisher pub = nh3.advertise<sensor_msgs::PointCloud2>("alignedcloud", 1);
ros::Rate loop_rate(10);
then here is how I try to call publish:
pub.publish(cloud_aligned);
ros::spinOnce();
loop_rate.sleep();
Could someone give me some hints?
Best, kang
some errors:
/ros_diamondback/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h:121: error: 'const class pcl::PointCloud<pcl::PointXYZ>' has no member named '__getMD5Sum'
/ros_diamondback/ros_comm/clients/cpp/roscpp_traits/include/ros/message_traits.h: In static member function 'static const char* ros::message_traits::DataType<M>::value(const M&) [with M = pcl::PointCloud<pcl::PointXYZ>]':
/ros_diamondback/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h:142: error: 'const class pcl::PointCloud<pcl::PointXYZ>' has no member named 'serializationLength'
/ros_diamondback/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h: In static member function 'static void ros::serialization::Serializer<T>::write(Stream&, typename boost::call_traits<T>::param_type) [with Stream = ros::serialization::OStream, T = pcl::PointCloud<pcl::PointXYZ>]':
/ros_diamondback/ros_comm/clients/cpp/roscpp/include/ros/publisher.h:87: instantiated from 'void ros::Publisher::publish(const boost::shared_ptr<X>&) const [with M = pcl::PointCloud<pcl::PointXYZ>]'
/ros_diamondback/perception_pcl/pcl/src/tools/reg_icp_ros.cpp:88: instantiated from here
/ros_diamondback/ros_comm/clients/cpp/roscpp_serialization/include/ros/serialization.h:124: error: 'const class pcl::PointCloud<pcl::PointXYZ>' has no member named 'serialize'