簡體   English   中英

錯誤:對“ boost ::…”的調用不匹配

[英]Error: No match for call to 'boost::…'

我正在嘗試修改其他代碼。 只是想添加另一個訂戶。 這是代碼的框架:

namespace my_server
{
    a_server::a_server(ros::NodeHandle n)
    : nh()
    {
        ros::NodeHandle n(n_);
        sub1 = new message_filters::Subscriber<sensor_msgs::PointCloud2> (nh(), "/x", 5);
        sub2 = new tf::MessageFilter<sensor_msgs::PointCloud2> (*sub1, sub3, xyz, 5);
        sub2->registerCallback(boost::bind(&a_server::callback, this, _1));
    }
    a_server::~a_server()
    {
    .....
    }

    void a_server::callback(const sensor_msgs::PointCloud2::ConstPtr& cl)
    {
    ....
    }
}

這是頭文件:

namespace my_server
{
    class a_server
    {
        public:
        a_server(ros::NodeHandle n_ = ros::NodeHandle("~"));
        virtual ~a_server();

        virtual void callback(const sensor_msgs::PointCloud2::ConstPtr& cl);
        protected:
            ros::NodeHandle n;
            message_filters::Subscriber<sensor_msgs::PointCloud2>* sub1;
            tf::MessageFilter<sensor_msgs::PointCloud2>* sub2;
            tf::TransformListener sub3;
    }
}

現在,我想向其添加另一個訂戶。 無需將其與先前的訂戶綁定。 我是通過在以前的訂閱者之后添加此行來實現的。

ros::Subscriber  sub4 = m_nh.subscribe<geometry_msgs::Point>("/y", 1, &a_server::callback2);

並在void a_server::callback之后添加了回調函數:

void a_server::callback2(geometry_msgs::Point &a)
{
    ....
}

而這到protected頭文件:

void callback2(geometry_msgs::Point &a);

這是我得到的錯誤:

Error: 
no match for call to ‘(boost::_mfi::mf1<void, my_server::a_server, geometry_msgs::Point_<std::allocator<void> >&>) (const boost::shared_ptr<const geometry_msgs::Point_<std::allocator<void> > >&)’
BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));

我知道這與先前訂戶中的boost::bind使用有關。 但我不想更改它們。 只需添加另一個訂戶,該訂戶的回調函數將更新一個全局變量,而該全局變量將由先前的回調函數使用。

因此,失去了寶貴的6個小時后。 這就是解決方法。 訂閱者添加如下:

ros::Subscriber sub4 = nh.subscribe<geometry_msgs::Point>("/y", 1, boost::bind(&a_server::callback2, this, _1));

回調函數是這樣寫的:

void a_server::callback2(const geometry_msgs::Point::ConstPtr& a)
{
    ....
}

頭文件是在Public:下添加的Public:

void callback2(const geometry_msgs::Point::ConstPtr& a);

錯誤:沒有 &gt; 匹配調用 '(boost::_mfi::mf1 <void< div><div id="text_translate"><p> 我對 c++ 有相當的基礎知識,下面描述的一個問題可能相當簡單,並且基於語法錯誤,但我還沒有找到解決方法。 基本上我得到的錯誤說:</p><pre> remote_hw_interface_node.cpp:23:68: required from here /usr/include/boost/function/function_template.hpp:231:11: error: no match for call to '(boost::_mfi::mf1&lt;void, ROBOTHardwareInterface, const boost::shared_ptr&lt;sensor_msgs::JointState_&lt;std::allocator&lt;void&gt; &gt; &gt; &gt;&amp;&gt;) (const boost::shared_ptr&lt;const sensor_msgs::JointState_&lt;std::allocator&lt;void&gt; &gt; &gt;&amp;)' BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS)); ^</pre><p> 我不知道關於提升是什么。</p><p> 關於我的代碼,我在下面復制了其中的一些部分,這可能會為更有經驗的 c++ 用戶顯示問題。 我的 header 文件如下所示:</p><pre> #pragma once #include &lt;message_filters/subscriber.h&gt; #include &lt;message_filters/time_sequencer.h&gt; // controller manager and interface msgs #include &lt;controller_manager/controller_manager.h&gt; class ROBOTHardwareInterface: public hardware_interface::RobotHW { public: ROBOTHardwareInterface(ros::NodeHandle&amp; nh); ~ROBOTHardwareInterface(); bool init (const urdf::Model* const urdf_model); void sequential_update (const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp; joint_state_msg); // main ros::NodeHandle nh_; ros::Duration elapsed_time_; boost::shared_ptr&lt;controller_manager::ControllerManager&gt; controller_manager_; };</pre><p> 如果我只復制也導致錯誤出現的相關部分,則 cpp 文件也是如此:</p><pre> #include &lt;remote_hw.h&gt; ROBOTHardwareInterface::ROBOTHardwareInterface(ros::NodeHandle&amp; nh): nh_(nh) { message_filters::Subscriber &lt;sensor_msgs::JointState&gt; sub(nh_, "joint_cmd_topic", 1); message_filters::TimeSequencer &lt;sensor_msgs::JointState&gt; seq(sub, ros::Duration( 0.1), ros::Duration(0.01), 10); seq.registerCallback(&amp;ROBOTHardwareInterface::sequential_update); } ROBOTHardwareInterface::~ROBOTHardwareInterface() { }} void ROBOTHardwareInterface::sequential_update(const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp; joint_state_msg){</pre> </div></void<>

[英]error: no > match for call to ‘(boost::_mfi::mf1<void

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 使用boost :: bind的“不匹配調用”錯誤 錯誤:沒有 &gt; 匹配調用 '(boost::_mfi::mf1 <void< div><div id="text_translate"><p> 我對 c++ 有相當的基礎知識,下面描述的一個問題可能相當簡單,並且基於語法錯誤,但我還沒有找到解決方法。 基本上我得到的錯誤說:</p><pre> remote_hw_interface_node.cpp:23:68: required from here /usr/include/boost/function/function_template.hpp:231:11: error: no match for call to '(boost::_mfi::mf1&lt;void, ROBOTHardwareInterface, const boost::shared_ptr&lt;sensor_msgs::JointState_&lt;std::allocator&lt;void&gt; &gt; &gt; &gt;&amp;&gt;) (const boost::shared_ptr&lt;const sensor_msgs::JointState_&lt;std::allocator&lt;void&gt; &gt; &gt;&amp;)' BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS)); ^</pre><p> 我不知道關於提升是什么。</p><p> 關於我的代碼,我在下面復制了其中的一些部分,這可能會為更有經驗的 c++ 用戶顯示問題。 我的 header 文件如下所示:</p><pre> #pragma once #include &lt;message_filters/subscriber.h&gt; #include &lt;message_filters/time_sequencer.h&gt; // controller manager and interface msgs #include &lt;controller_manager/controller_manager.h&gt; class ROBOTHardwareInterface: public hardware_interface::RobotHW { public: ROBOTHardwareInterface(ros::NodeHandle&amp; nh); ~ROBOTHardwareInterface(); bool init (const urdf::Model* const urdf_model); void sequential_update (const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp; joint_state_msg); // main ros::NodeHandle nh_; ros::Duration elapsed_time_; boost::shared_ptr&lt;controller_manager::ControllerManager&gt; controller_manager_; };</pre><p> 如果我只復制也導致錯誤出現的相關部分,則 cpp 文件也是如此:</p><pre> #include &lt;remote_hw.h&gt; ROBOTHardwareInterface::ROBOTHardwareInterface(ros::NodeHandle&amp; nh): nh_(nh) { message_filters::Subscriber &lt;sensor_msgs::JointState&gt; sub(nh_, "joint_cmd_topic", 1); message_filters::TimeSequencer &lt;sensor_msgs::JointState&gt; seq(sub, ros::Duration( 0.1), ros::Duration(0.01), 10); seq.registerCallback(&amp;ROBOTHardwareInterface::sequential_update); } ROBOTHardwareInterface::~ROBOTHardwareInterface() { }} void ROBOTHardwareInterface::sequential_update(const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp; joint_state_msg){</pre> </div></void<> Boost / OpenCV錯誤:無法匹配對&#39;(boost :: _ mfi :: dm的調用 <void(cv::Mat*, cv::VideoCapture*), Recorder> ) 錯誤:boost :: tuple的“ operator ==”不匹配 boost regex錯誤:未初始化的boost :: match_results 錯誤:沒有匹配的呼叫 錯誤:使用boost :: serialisation與&#39;operator &lt;&lt;&#39;不匹配 錯誤:無法撥打&#39;(家庭)電話 錯誤:沒有匹配項可調用“模塊” 錯誤:沒有要調用的匹配函數
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM