C++ 将C+;上的成员函数的std::bind作为参数传递时出现问题+;(和MoveIt API)
你好 注:虽然这是一个与ROS有关的问题,但我在这里发布,因为我很确定我的问题是用C++而不是用ROS API。 我正在尝试使用上定义的函数 此函数允许名为C++ 将C+;上的成员函数的std::bind作为参数传递时出现问题+;(和MoveIt API),c++,c++11,templates,boost,stdbind,C++,C++11,Templates,Boost,Stdbind,你好 注:虽然这是一个与ROS有关的问题,但我在这里发布,因为我很确定我的问题是用C++而不是用ROS API。 我正在尝试使用上定义的函数 此函数允许名为GroupStateValidityCallbackFn的可调用参数,类型(函数签名): 问题的出现是因为我试图将一个成员类函数传递给这个参数(因为我需要在处理过程中包含类实例成员字段),然后绑定过程就完蛋了 我的班级是这样的: class CSDA10F{ public: bool validateIKSolutio
GroupStateValidityCallbackFn
的可调用参数,类型(函数签名):
问题的出现是因为我试图将一个成员类函数传递给这个参数(因为我需要在处理过程中包含类实例成员字段),然后绑定过程就完蛋了
我的班级是这样的:
class CSDA10F{
public:
bool validateIKSolution( robot_state::RobotState* robot_state,
const robot_state::JointModelGroup* joint_group,
const double* joint_group_variable_value){
[...]
// some code here
[...]
}
bool planCartesianMotionTask(MoveGroupInterface* move_group,
geometry_msgs::Pose initial_pose,
geometry_msgs::Pose final_pose,
std::vector<MoveGroupInterface::Plan> motion_plans,
uint max_configurations = 10) {
[...] // Here I make the call!!!.
auto ik_check_callback = std::bind(&CSDA10F::validateIKSolution, this, _1, _2, _3);
ik_solution_found = start_state.setFromIK( joint_model_group, initial_pose, 10, 0.01, ik_check_callback);
[...]
}
CSDA10F类{
公众:
布尔验证解决方案(机器人状态::机器人状态*机器人状态,
const robot_state::jointmodel组*joint_组,
常量双*联合组变量值){
[...]
//这里有一些代码
[...]
}
bool planCartesianMotionTask(移动组接口*移动组,
几何体:姿势初始姿势,
几何体:姿势最后的姿势,
标准::矢量运动平面图,
uint最大配置=10){
[…]//我来打电话!!!。
自动ik检查回调=std::bind(&CSDA10F::validateIKSolution,this,_1,_2,_3);
ik_solution_found=开始_状态.setFromIK(关节_模型_组,初始_姿势,10,0.01,ik_检查_回调);
[...]
}
我对函数中的3个参数使用了3个占位符,但是编译器却出现了一个我根本无法理解的错误
In file included from /usr/include/boost/function/detail/maybe_include.hpp:28:0,
from /usr/include/boost/function/detail/function_iterate.hpp:14,
from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:62,
from /usr/include/boost/function.hpp:64,
from /opt/ros/kinetic/include/ros/forwards.h:40,
from /opt/ros/kinetic/include/ros/common.h:37,
from /opt/ros/kinetic/include/ros/ros.h:43,
from /home/invite/catkin_ws/src/invite-robotics/drum_automation/src/bag_handling.cpp:1:
/usr/include/boost/function/function_template.hpp: In instantiation of ‘static R boost::detail::function::function_obj_invoker3<FunctionObj, R, T0, T1, T2>::invoke(boost::detail::function::function_buffer&, T0, T1, T2) [with FunctionObj = std::_Bind<std::_Mem_fn<bool (invite_utils::CSDA10F::*)(moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)>(invite_utils::CSDA10F, boost::arg<1>, boost::arg<2>, boost::arg<3>)>; R = bool; T0 = moveit::core::RobotState*; T1 = const moveit::core::JointModelGroup*; T2 = const double*]’:
/usr/include/boost/function/function_template.hpp:940:38: required from ‘void boost::function3<R, T1, T2, T3>::assign_to(Functor) [with Functor = std::_Bind<std::_Mem_fn<bool (invite_utils::CSDA10F::*)(moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)>(invite_utils::CSDA10F, boost::arg<1>, boost::arg<2>, boost::arg<3>)>; R = bool; T0 = moveit::core::RobotState*; T1 = const moveit::core::JointModelGroup*; T2 = const double*]’
/usr/include/boost/function/function_template.hpp:728:7: required from ‘boost::function3<R, T1, T2, T3>::function3(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = std::_Bind<std::_Mem_fn<bool (invite_utils::CSDA10F::*)(moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)>(invite_utils::CSDA10F, boost::arg<1>, boost::arg<2>, boost::arg<3>)>; R = bool; T0 = moveit::core::RobotState*; T1 = const moveit::core::JointModelGroup*; T2 = const double*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/usr/include/boost/function/function_template.hpp:1077:16: required from ‘boost::function<R(T0, T1, T2)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = std::_Bind<std::_Mem_fn<bool (invite_utils::CSDA10F::*)(moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)>(invite_utils::CSDA10F, boost::arg<1>, boost::arg<2>, boost::arg<3>)>; R = bool; T0 = moveit::core::RobotState*; T1 = const moveit::core::JointModelGroup*; T2 = const double*; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/invite/catkin_ws/src/invite-robotics/invite_utils/include/invite_utils/csda10f_interface.h:202:116: required from here
/usr/include/boost/function/function_template.hpp:138:22: error: no match for call to ‘(std::_Bind<std::_Mem_fn<bool (invite_utils::CSDA10F::*)(moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)>(invite_utils::CSDA10F, boost::arg<1>, boost::arg<2>, boost::arg<3>)>) (moveit::core::RobotState*, const moveit::core::JointModelGroup*, const double*)’
return (*f)(BOOST_FUNCTION_ARGS);
在/usr/include/boost/function/detail/maybe_include.hpp:28:0中包含的文件中,
从/usr/include/boost/function/detail/function_iterate.hpp:14,
来自/usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:62,
从/usr/include/boost/function.hpp:64,
from/opt/ros/kinetic/include/ros/forwards.h:40,
from/opt/ros/kinetic/include/ros/common.h:37,
from/opt/ros/kinetic/include/ros/ros.h:43,
from/home/invite/catkin\u ws/src/invite robotics/drum\u automation/src/bag\u handling.cpp:1:
/usr/include/boost/function/function_template.hpp:“static R boost::detail::function_obj_invoker3::invoke(boost::detail::function::function_buffer&,T0,T1,T2)[with FunctionObj=std::_Bind;R=bool;T0=moveit::core::RobotState*;T1=const moveit::core::JointModelGroup*;T2=const double*]:
/usr/include/boost/function/function_template.hpp:940:38:void boost::function3::assign_to(Functor)[其中Functor=std::_Bind;R=bool;T0=moveit::core::RobotState*;T1=const moveit::core::JointModelGroup*;T2=const double*]
/usr/include/boost/function/function_template.hpp:728:7:从“boost::function3::function3(Functor,typename boost::enable_if_c::type)[使用Functor=std::_Bind;R=bool;T0=moveit::core::RobotState*;T1=const moveit::core::JointModelGroup*;T2=const double*;typename boost::enable_if_c::type=int]'
/usr/include/boost/function/function_template.hpp:1077:16:来自“boost::function::function(Functor,typename boost::enable_if_c::type)”的必填项[带有Functor=std::_Bind;R=bool;T0=moveit::core::RobotState*;T1=const moveit::core::JointModelGroup*;T2=const double*;typename boost::enable_if_c::type=int]'
/home/invite/catkin\u ws/src/invite robotics/invite\u utils/include/invite\u utils/csda10f\u interface.h:202:116:此处需要
/usr/include/boost/function/function_template.hpp:138:22:错误:调用“(std::_Bind)(moveit::core::RobotState*,const moveit::core::JointModelGroup*,const double*)不匹配
返回(*f)(增压功能参数);
RobotState
上的声明是否不允许成员函数?我相信我在std::bind上犯了一个错误,但我似乎找不到它是什么的答案
我知道什么:
- 我在要绑定的函数中使用了正确的参数类型
- 我有正确数量的参数(3)
你知道问题出在哪里吗?看起来你把Boost
\u 1
、\u 2
、\u 3
占位符和std::bind
混合在一起了。尝试以下方法之一:
- 切换到
boost::bind
- 在调用之前使用std::占位符添加
,
- 使用捕获此的lambda表达式
\u 1
、\u 2
、\u 3
占位符与std::bind
混合使用。请尝试以下操作之一:
- 切换到
boost::bind
- 在调用之前使用std::占位符添加
,
- 使用捕获此的lambda表达式
\u 1
、\u 2
、\u 3
占位符与std::bind
混合使用。试着在通话前切换到Boost::bind
或使用std::占位符添加,
耶稣啊,我犯了一个多么愚蠢的错误,非常感谢你,你在哪里正确。我必须告诉你,你已经解决了在15秒内,一个困扰了我6个多小时的问题出现了。你想把你的评论作为我可以设置的答案吗?看起来你把Boost\u1
,\u2
,\u3
占位符和std::bind
。试着切换到Boost::bind
,或者使用std::pl添加电话铃响之前我犯了一个多么愚蠢的错误