问题
I have rather a basic knowledge in c++ and there is an issue described in the following which is likely rather simple and a based on a syntax mistake but I haven't figured out a way around it. Basically the error I get says:
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));
^
which I don't have any clue what it is about regarding boost.
regarding my code I have copied some parts of it in the following which may likely show the problem for a more experienced c++ user. My header file looks like:
#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_;
};
the cpp file also if I only copy the relevant parts which has also caused the error coming up:
#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){
回答1:
By searching in boost library implementation https://www.boost.org/doc/libs/1_71_0/boost/function/function_template.hpp, it seems that you are trying to call a method without giving all the parameters necessary.
I suppose that you try to invoke this method with an empty parameter, while you should also add const boost::shared_ptr <sensor_msgs::JointState> &
as well.
I suppose that BOOST_FUNCTION_ARGS in your case is empty hence your issue. So the method behind is trying to invoke void sequential_update()
instead of void sequential_update(const boost::shared_ptr <sensor_msgs::JointState> &)
I hope this helps.
来源:https://stackoverflow.com/questions/62345576/error-no-match-for-call-to-boost-mfimf1void