ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

error while using pcl to find planes inside point cloud

asked 2022-11-30 02:44:11 -0500

bodka gravatar image

hi all. im using ros foxy and Ubuntu 20.04.

i trying to find planes inside point cloud and get the following error.

[pcl::RandomSampleConsensus::computeModel] RANSAC found no model.
[pcl::SACSegmentation::segment] Error segmenting the model! No solution found.

my code:

void get_plane_from_pc(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, double distance_threshold=0.005)

{
    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
    pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
    pcl::SACSegmentation<pcl::PointXYZ> seg;
    seg.setOptimizeCoefficients(true);
    seg.setModelType(pcl::SACMODEL_PLANE);
    seg.setMethodType(pcl::SAC_RANSAC);
    seg.setDistanceThreshold(distance_threshold);
    seg.setInputCloud(cloud);
    seg.segment(*inliers, *coefficients); 
}

The error occurs in the line: seg.segment(*inliers, *coefficients);

i install the pcl pkg by sudo apt install ros-foxy-pcl-ros

my cmakeList:

cmake_minimum_required(VERSION 3.5)
project(picko_core)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies    
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

find_package(PCL REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(pcl_ros REQUIRED)

set(dependencies
        rclcpp
        pcl_conversions
        pcl_ros
)

add_library(picko_core
        src/pcl_utilities/PclUtilitis.cpp
        )



target_include_directories(picko_core PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)

ament_target_dependencies(picko_core ${dependencies})

target_link_libraries(picko_core   ${PCL_LIBRARIES} )

ament_export_targets(picko_core HAS_LIBRARY_TARGET)
ament_export_dependencies(${dependencies})
ament_export_include_directories(include)

install(
        DIRECTORY include/picko_core
        DESTINATION include
)

install(
        TARGETS picko_core
        EXPORT picko_core
        LIBRARY DESTINATION lib/${PROJECT_NAME}
        ARCHIVE DESTINATION lib/${PROJECT_NAME}
        RUNTIME DESTINATION lib/${PROJECT_NAME}
        INCLUDES DESTINATION include
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)

  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

any idea? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-11-30 05:49:04 -0500

jrtg gravatar image

I have no experience with PCL, but what I'd do is:

edit flag offensive delete link more

Question Tools

Stats

Asked: 2022-11-30 02:44:11 -0500

Seen: 399 times

Last updated: Nov 30 '22