Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a Radius filter to octomap_server

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to add a radius filter to octomap_server". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First, the basic principle of radius filter

Put a screenshot of the PPT for the report:

The principle is simply to determine whether there are enough (K) neighboring points around a point cloud (radius R). If not, delete the point, otherwise keep it.

II. Basic usage

I usually like to go to the official website to see the most original tutorial: Removing outliers using a Conditional or RadiusOutlier removal, which introduces the basic use of radius filter (I don't know what the Chinese name is filter):

# include

# include

/ / enter the original point cloud pointer to be filtered

Pcl::PointCloud::Ptr cloud (new pcl::PointCloud)

/ / Save the filtered point cloud pointer

Pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud)

/ / create filter object

Pcl::RadiusOutlierRemoval outrem

/ / set the point cloud to be filtered

Outrem.setInputCloud (cloud)

/ / set the filter radius

Outrem.setRadiusSearch (0.8)

/ / set the minimum nearest neighbor number of filter

Outrem.setMinNeighborsInRadius (2)

/ / perform radius filtering

Outrem.filter (* cloud_filtered)

If you use PCL's filter for the first time, you can run this tutorial yourself. I've run it before, so I won't post the code this time. Let's share how I use this radius filter to filter the octree map built by my octomap_server in the actual project.

Define radius filter parameters for my map filter 3.1

The radius filter has two parameters: the filter radius and the number of internal neighbors in the radius, pay attention to the data type

/ / filter radius

Double m_outrem_radius

/ / number of neighbors within the radius

Int m_outrem_neighbors

Initialize in the constructor initialization list:

OctomapServer::OctomapServer (const ros::NodeHandle private_nh_, const ros::NodeHandle & nh_)

:...

M_outrem_radius (- std::numeric_limits::max ())

M_outrem_neighbors (- std::numeric_limits::max ())

...

Read the startup parameters from launch:

/ / add outrem filter

M_nh_private.param ("outrem_radius", m_outrem_radius, m_outrem_radius)

M_nh_private.param ("outrem_neighbors", m_outrem_neighbors, m_outrem_neighbors)

3.2 perform radius filtering

Perform radius filtering before the PassThough of the InsertPointCloudCallBack function, that is, filter each frame of the point cloud before building an octree map, mainly to remove individual outliers:

/ / Radius filtering of one-to-one frame pc point cloud

Pcl::RadiusOutlierRemoval outrem

/ / the pointer needs to be passed here, because my pc is not a pointer, so makeShared is done here.

Outrem.setInputCloud (pc.makeShared ())

/ / set the filter radius, which is set to 1m here

Outrem.setRadiusSearch (m_outrem_radius)

/ / set the filter nearest neighbor number, which is set to 10 here

Outrem.setMinNeighborsInRadius (m_outrem_neighbors)

/ / execute filtering

Outrem.filter (pc)

3.3 configure half-path filter parameters in launch

In this way, the parameters of the filter can be configured directly from launch, without having to recompile each time, which is very convenient to debug.

3.4 filtering results

This is the original map, with 15cm resolution, and there are many individual points inside the red box:

This is the effect of the filter, with a filter radius of 1m and 10 neighboring points:

This is the end of "how to add a Radius filter to octomap_server". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report