0
$\begingroup$

Rosanswers logo

Hi,

I'm already using a variable of the type pcl::PointCloudpcl::PointXYZ::Ptr called grasp_points that I'd like to publish. I tried to follow this example: answers.ros.org/question/35368/pointcloud-library-publishing/

Here's what I have for code:

typedef pcl::PointCloud<pcl::PointXYZ> PCLCloud;
ros::Publisher graspub = n.advertise<PCLCloud> ("grasp_points", 100);
ros::Rate loop_rate(10);
graspub.publish(grasp_points);

I also initialize ROS and the node n, and the code compiles fine. I can tell that the delay is working. But when I check rostopic list, only rosout and rosout_agg are listed. There must be something I didn't include in my code. Does anyone know what it is? Thanks!

EDIT: It might be a problem with the type. grasp_points is acutally a pcl::PointCloudpcl::PointXYZ::Ptr {aka boost::shared_ptrpcl::PointCloud<pcl::PointXYZ >}

I also have a variables of the types std::vectorpcl::PointXYZ and pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZ. Would I be able to publish either of those?

EDIT 2: Okay, I found the data stored as floats, so I can just publish those.


Originally posted by mattc12345 on ROS Answers with karma: 328 on 2014-07-23

Post score: 0


Original comments

Comment by bvbdort on 2014-07-23:
what is data type of grasp_points ?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You should probably use

 typedef pcl::PointCloud<pcl::PointXYZ> PCLCloud;
 graspub.publish(*grasp_points);
 ros::Publisher graspub = n.advertise<PCLCloud> ("grasp_points", 100);
 ros::Rate loop_rate(10);
 

Check the * added to the grasp_points and the order of the lines.


Originally posted by sai with karma: 1935 on 2014-07-23

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.