ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

An error with class methods subscribers

asked 2013-11-24 21:33:43 -0500

pelment gravatar image

I try to subscribe a callback function which is a class method, but if I try to do catkin_make I have the following errors:

Base path: /home/kaftan/catkin_ws
Source space: /home/kaftan/catkin_ws/src
Build space: /home/kaftan/catkin_ws/build
Devel space: /home/kaftan/catkin_ws/devel
Install space: /home/kaftan/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/kaftan/catkin_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/kaftan/catkin_ws/build"
####
Scanning dependencies of target rop_client
[  0%] [  0%] Built target std_msgs_generate_messages_cpp
Built target kobuki_msgs_generate_messages_py
[ 10%] [ 10%] [ 20%] Built target kobuki_msgs_generate_messages_cpp
Building CXX object rop_client/CMakeFiles/rop_client.dir/src/main.cpp.o
Building CXX object rop_client/CMakeFiles/rop_client.dir/src/rop_client.cpp.o
[ 20%] Built target std_msgs_generate_messages_py
[ 20%] Built target std_msgs_generate_messages_lisp
[ 20%] Built target kobuki_msgs_generate_messages_lisp
[ 40%] Built target rop_client_generate_messages_cpp
[ 70%] [ 90%] Built target rop_client_generate_messages_py
Built target rop_client_generate_messages_lisp
[ 90%] Built target rop_client_generate_messages
/home/kaftan/catkin_ws/src/rop_client/src/rop_client.cpp: В функции-члене «void ROP::RopClient::Subscribes()»:
/home/kaftan/catkin_ws/src/rop_client/src/rop_client.cpp:53:74: ошибка: ISO C++ не поддерживает взятие адреса от неквалифицированного элемента-функцииили элемента в скобках для формирования указателя на элемент-функцию.Используйте синтаксис «&ROP::RopClient::RopCallback» [-fpermissive]
/home/kaftan/catkin_ws/src/rop_client/src/rop_client.cpp:53:86: ошибка: нет подходящей функции для вызова «ros::NodeHandle::subscribe(const char [11], int, void (ROP::RopClient::*)(rop_client::RopEvent_<std::allocator<void> >::ConstPtr&))»
/home/kaftan/catkin_ws/src/rop_client/src/rop_client.cpp:53:86: замечание: candidates are:
/opt/ros/groovy/include/ros/node_handle.h:379:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), T*, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:390:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M)const, T*, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:438:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&), T*, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:448:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&)const, T*, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:498:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:509:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M)const, const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:559:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&), const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/groovy/include/ros/node_handle.h:570:14: замечание: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&)const, const ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2013-11-24 23:11:44 -0500

jgdo gravatar image

Hi,

Methods need an object they can be called with, so you have to add the object pointer when calling subscribe(). Also you need to specify the scope of RopCallback.

=>

node_listener_->subscribe( "rop_client", 1000, &RopClient::RopCallback, this);

See also The Publisher/Subscriber overview

Regards

  • jgdo -

BTW: didn't know there exists a russian gcc ;)

edit flag offensive delete link more

Comments

Thank you very much, it works!

pelment gravatar image pelment  ( 2013-11-24 23:31:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-24 21:33:43 -0500

Seen: 207 times

Last updated: Nov 24 '13