Robotics StackExchange | Archived questions

Is there a way to publish normals of a given point cloud in ROS?

Hello everyone.

I subscribe to my camera, I get the point cloud, I convert the point cloud from ROStopcl and finally I use the function makeNormalEstimation() of pythonpcl to get the normals. So far so good! Now I want to publish somehow these normals to a ROS topic and by publishing i mean visualizing them also in RVIZ. The pythonpcl function makeNormalEstimation() returns 4 values in the form of a vector. The 3 first values are normalx, normaly, normalz and he 4th value is the curvature. I want to publish and visualize the normals in RVIZ through PoseStamed messages. As far as i know a PoseStamped message needs a Pose and a Quaternion. For the Pose field i use the x, y, z of the desired point in my point cloud i want to find the normal. But when it comes for the quaternion i don't know what to use! I tried to use the returned values as they were quaternionx, quaterniony, quaernionz, quaternion_w but the results where not so good...

So. my questions are:

Sorry for the chaos in my questions! I really hope they make sense!

Thanks in advance!

Asked by mitselis on 2021-11-11 06:57:39 UTC

Comments

Take a look at this prior question: https://answers.ros.org/question/358324/ros-pclpointcloudpclpointnormal-publishment/

The code is in C++ though

pcl::PointCloud<pcl::PointNormal> cloud_normals_;

normalEstimation.setViewPoint(0, 0, 1.0);                                                                                                                                                                                           
normalEstimation.compute (cloud_normals_); 

int index = 0;
long temp_size = cloudFiltered->points.size();

for(unsigned int i=0; i < temp_size; i=i+20) {
// x range -35m to 35 m, y ranges -25 to 25m, z ranges 0 to 66
    cloud_normals_.points[index].x = cloudFiltered->points[i].x;
    cloud_normals_.points[index].y = cloudFiltered->points[i].y;
    cloud_normals_.points[index].z = cloudFiltered->points[i].z;
    index ++;
}


//ROS_INFO("test");
pc_pub.publish(cloud_normals_)

Asked by osilva on 2021-11-12 11:03:14 UTC

Thank you for your answer and sorry for my delay. Your answer was very helpful but i have some more questions so i edited my post.

Asked by mitselis on 2021-11-15 03:39:33 UTC

you could also publish the normals as visualization_msgs::MarkerArray msg with each marker(normal) being an arrow.

Asked by xibeisiber on 2021-11-15 08:37:28 UTC

Answers