【问题标题】:error: no matching function for call to ‘ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*)’错误:没有匹配函数调用‘ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*)’
【发布时间】:2025-12-10 11:30:02
【问题描述】:

在编译自己的项目时,出现如下错误:

myRRT.cc:80:78: error: no matching function for call to ‘ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*)’
        nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this));
                                                                              ^
In file included from /home/htf/Downloads/Active-ORB-SLAM2-octomap/src/myRRT.cc:36:0:
/opt/ros/indigo/include/ompl/tools/config/SelfConfig.h:93:42: note: candidate: template<class _T> static ompl::NearestNeighbors<_T>* ompl::tools::SelfConfig::getDefaultNearestNeighbors(const StateSpacePtr&)
             static NearestNeighbors<_T>* getDefaultNearestNeighbors(const base::StateSpacePtr &space)
                                          ^
/opt/ros/indigo/include/ompl/tools/config/SelfConfig.h:93:42: note:   template argument deduction/substitution failed:
/home/htf/Downloads/Active-ORB-SLAM2-octomap/src/myRRT.cc:80:78: note:   cannot convert ‘(ompl::geometric::RRT*)this’ (type ‘ompl::geometric::RRT*’) to type ‘const StateSpacePtr& {aka const boost::shared_ptr<ompl::base::StateSpace>&}’
        nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this))

这是我的源代码的一部分,

void ompl::geometric::RRT::setup()
{
    Planner::setup();
    tools::SelfConfig sc(si_, getName());
    sc.configurePlannerRange(maxDistance_);

    if (!nn_)
       nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors<Motion *>(this));
    nn_->setDistanceFunction(std::bind(&RRT::distanceFunction, this, std::placeholders::_1, std::placeholders::_2));
}

这是我引用的示例文件之一RRT 有没有人遇到过类似的问题?我是 C++ 新手,希望能得到一些线索。提前谢谢你。

【问题讨论】:

  • 虽然我对运动规划不太熟悉,但是你可以看看这个Q&A:*.com/questions/15113856/…。从您的源代码和错误来看,您很可能需要传递其他内容而不是发生错误的“”。

标签: c++ motion-planning


【解决方案1】:

ompl::tools::SelfConfig::getDefaultNearestNeighbors(ompl::geometric::RRT*) 所以你应该像这样修改它:

nn_.reset(tools::SelfConfig::getDefaultNearestNeighbors&lt;Motion&gt;(*this)); 也许motion 是模板, (*this) 表示您想使用 (*this) 调用对象 我也是新手。我不确定。

【讨论】: