【问题标题】:error: no > match for call to ‘(boost::_mfi::mf1<void错误:没有 > 匹配调用‘(boost::_mfi::mf1<void
【发布时间】:2020-10-02 08:20:45
【问题描述】:

我对 c++ 有相当的基础知识,下面描述的一个问题可能相当简单,并且基于语法错误,但我还没有找到解决方法。 基本上我得到的错误是:

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<void, ROBOTHardwareInterface, const boost::shared_ptr<sensor_msgs::JointState_<std::allocator<void>
> > >&>) (const boost::shared_ptr<const sensor_msgs::JointState_<std::allocator<void> > >&)’
            BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));

    ^

我不知道它是关于什么的。

关于我的代码,我在下面复制了其中的一些部分,这可能会为更有经验的 c++ 用户显示问题。我的头文件看起来像:

#pragma once

#include <message_filters/subscriber.h>
#include <message_filters/time_sequencer.h>


// controller manager and interface msgs
#include <controller_manager/controller_manager.h>


class ROBOTHardwareInterface : public hardware_interface::RobotHW 
{
    public:
        ROBOTHardwareInterface(ros::NodeHandle& nh);
        ~ROBOTHardwareInterface();

        bool init                 (const urdf::Model* const urdf_model);
        void sequential_update    (const boost::shared_ptr <sensor_msgs::JointState> & joint_state_msg);


    // main
        ros::NodeHandle nh_;
        ros::Duration elapsed_time_;
        boost::shared_ptr<controller_manager::ControllerManager> controller_manager_;
};

如果我只复制导致错误出现的相关部分,cpp 文件也是如此:

#include <remote_hw.h>

ROBOTHardwareInterface::ROBOTHardwareInterface(ros::NodeHandle& nh) : nh_(nh) {

    message_filters::Subscriber <sensor_msgs::JointState> sub(nh_, "joint_cmd_topic", 1);
    message_filters::TimeSequencer <sensor_msgs::JointState> seq(sub, ros::Duration(
    0.1), ros::Duration(0.01), 10);
    seq.registerCallback(&ROBOTHardwareInterface::sequential_update);

}

ROBOTHardwareInterface::~ROBOTHardwareInterface() {
}}

void ROBOTHardwareInterface::sequential_update(const boost::shared_ptr <sensor_msgs::JointState> & joint_state_msg){

【问题讨论】:

    标签: c++ c++11 boost shared-ptr ros


    【解决方案1】:

    通过在 boost 库实现 https://www.boost.org/doc/libs/1_71_0/boost/function/function_template.hpp 中搜索,您似乎正在尝试调用一个方法而不提供所有必要的参数。

    我假设您尝试使用空参数调用此方法,同时您还应该添加const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp;

    我想在你的情况下 BOOST_FUNCTION_ARGS 是空的,因此你的问题。所以后面的方法是尝试调用void sequential_update()而不是void sequential_update(const boost::shared_ptr &lt;sensor_msgs::JointState&gt; &amp;)

    我希望这会有所帮助。

    【讨论】:

    • 但是我应该在哪里添加“const boost::shared_ptr <:jointstate> &”,sequential_update 更新已经将它作为参数吗?
    • 是的,但我认为错误来自您注册回调的方式。您需要检查message_filters::TimeSequencer 是如何调用您创建的回调的。也许当你注册回调时,你需要添加几个代表回调参数的参数。
    • 据我所知,错误本身是在调用此回调时发生的。调用者是您正在使用的黑盒子,它没有正确使用回调给它您声明的joint_state_msg。
    • 这里看到的例子:answers.ros.org/question/323115/…answers.ros.org/question/283432/…,而原来的wiki.ros.org/message_filters,只需使用seq.registerCallback(myCallback);但是由于我在课堂上使用它,所以我添加了&。
    • 这可能是问题所在:const boost::shared_ptr &lt;const sensor_msgs::JointState&gt; &amp; joint_state_msg)boost::shared_ptr 的声明中没有 const
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多