Problem in assigning a callback when it is a method (Rviz Interactive Markers)
I have tried the Rviz tutorial on Interactive markers, in particular the one for menus. But as you can see in the code this is not object-oriented.
I want to do the same using classes, and so far I have been able to show the menus and everything except the callback.
In the code you have
void deepCb( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
{
ROS_INFO("The deep sub-menu has been found.");
}
void initMenu()
{
h_first_entry = menu_handler.insert( "First Entry" );
MenuHandler::EntryHandle entry = menu_handler.insert( h_first_entry, "deep" );
entry = menu_handler.insert( entry, "sub" );
entry = menu_handler.insert( entry, "menu", &deepCb ); //<----This works HERE but not with classes
}
This code works but when I convert this to classes I have
void MyClass::deepCb( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback )
{
ROS_INFO("The deep sub-menu has been found.");
}
So I want to do the line marked above
entry = menu_handler.insert( entry, "menu", &MyClass::deepCb );
This does not compile. I got the error
‘static void boost::detail::function::function_void_mem_invoker1<MemberPtr, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with MemberPtr = void (MyClass::*)(const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&); R = void; T0 = const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&]’:
error: no match for call to ‘(boost::_mfi::mf1<void, MyClass, const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&>) (const boost::shared_ptr<const visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > >&)’
BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));
My question is how can I assign a callback here when it is a method?
EDITT:
This is a question with a similar error problem but the answers do not solve the problem