错误:对'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:
void callback2(const geometry_msgs::Point::ConstPtr& a);
相关文章:
- Tbb 库:错误:编写自定义类函数而不是 lambda 表达式时,对函数的调用不匹配
- test1.cpp:9:77:错误:对"(const std::normal_distribution) <double>(std::mt19937&)"的调用不匹配
- 计算一个单词在映射中出现的次数 - 使用 transform() - 调用不匹配
- std::使用内部对象移动 - 与调用不匹配
- 对std::函数对象的调用不匹配,该对象是指向成员函数的指针
- 错误:对'boost::.......'的调用不匹配
- 错误:对"set_union"的调用不匹配
- 与构造函数中对(类)(类型)的调用不匹配
- 对"(std::vector<std::vector<int> >) (int, std::vector<int>)"的调用不匹配
- 声明后初始化对象时"调用不匹配"
- 功能参数与函数调用不匹配
- C++ 与函数调用不匹配
- C++ 错误:对 '(std::string {aka std::basic_string}) (<char>无符号整数、字符)的调用不匹配
- C++错误:对"(RgbImage) (int&, int&)"的调用不匹配
- C++ 错误:对"(std::string) (const char[4])"的调用不匹配
- 与结构sockaddr_in调用不匹配
- 错误:对'(Time) (int, int, int)'的调用不匹配
- 错误消息:与调用"(cv::Rect) (cv::Mat&, cv::P oint_, cv:<int>:P oint, cv::Scalar, int)"的调用不匹配
- 对c++函数的调用不匹配
- const_iterator、find_if和bind2nd:对错误的调用不匹配