我对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));
^
我一点都不知道这是关于Boost的。
关于我的代码,我在下面复制了它的一些部分,对于一个更有经验的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){
通过在boost library implementation https://www.boost.org/doc/libs/1_71_0/boost/function/function_template.hpp中搜索,您似乎试图调用一个方法,而没有给出所有必要的参数。
我认为您尝试使用空参数调用此方法,同时还应该添加常量boost::shared_ptr
。
我认为您的示例中的BOOST_FUNCTION_ARGS是空的,因此您的问题是。 因此后面的方法试图调用void sequential_update()
而不是void sequential_update(const boost::shared_ptr
我希望这能帮上忙。