我正在將我的包從 ros melodic 遷移到 ros noetic。在執行此操作時,我在 cmake 期間在 PCL 庫中遇到了編譯錯誤。包太大我給出了一些發生錯誤的代碼。任何指導都會有所幫助。這是 myfile.cpp
std::vector<bool> ignore_labels;
ignore_labels.resize(2);
ignore_labels[0] = true;
ignore_labels[1] = false;
//TODO commented that out i think we have to fix the error
ecc->setExcludeLabels(ignore_labels);
'''
這是它在ecc->setExcludeLabels(ignore_labels)行呼叫的 PCL-1.10 庫檔案;這里發生錯誤,
''' brief 在標簽云中設定要排除的標簽。param[in] exclude_labels 對應于是否應考慮給定標簽的布爾向量
void
setExcludeLabels (const std::vector<bool>& exclude_labels)
{
exclude_labels_ = boost::make_shared<std::set<std::uint32_t> > ();
for (std::size_t i = 0; i < exclude_labels.size (); i)
if (exclude_labels[i])
exclude_labels_->insert (i);
}
'''
錯誤是
/usr/include/pcl-1.10/pcl/segmentation/euclidean_cluster_comparator.h:256:13: 錯誤:沒有匹配的函式呼叫'std::set::insert(std::size_t&)const' 256 | exclude_labels_->insert (i); | ^~~~~~~~~~~~~~~ 在 /usr/include/c /9/set:61 包含的檔案中,
uj5u.com熱心網友回復:
我查看了這個庫的源代碼,這里是問題:

型別是一個 typedef:

問題是物件本身是shared_ptr<const std::set<std::uint32_t>>
您發布的代碼正在分配物件,但也呼叫std::set::insert的實體const std::set,該實體不存在,因為通過std::set::insert修改狀態std::set
注意編譯器錯誤末尾的 const :‘std::set::insert(std::size_t&) const
這意味著您正在嘗試呼叫insertis 的一個版本,該版本const不存在(并且不能存在)
在這里您可以了解有關 const 限定方法的更多資訊
uj5u.com熱心網友回復:
您不能添加型別為size_t(通常為UInt64)的元素,set<UInt32>因為您無法比較UInt64和UInt32。
uj5u.com熱心網友回復:
發生錯誤是因為size_t嘗試將的變數插入到容器中exclude_labels_。請將變數轉換i為uint32_t,然后嘗試插入到容器中exclude_labels_。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/337812.html
