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

error while using class method as callback in cpp

asked 2016-03-04 09:42:39 -0500

pit gravatar image

Hi, i'm actually trying to use my own class method as callback of a topic. I do it like this

First i created a publisher :

    ros::Publisher topicDirection = n.advertise<std_msgs::Float64>("commandeDir", 1);

then i subscribe to this topic (commandeDir) with :

Servo pwmDir();
ros::Subscriber topicDir = n.subscribe("commandeDir", 1, &Servo::commande(const std_msgs::Float64& msg), pwmDir);

and my function looks like this :

void Servo::commande(const std_msgs::Float64& msg)

it throw me this error :

/opt/ros/indigo/include/ros/message_traits.h:138:31: error: ‘__s_getDataType’ is not a member of ‘int’
 return M::__s_getDataType().c_str();

i don't get what i am doing wrong ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2016-03-05 08:04:22 -0500

kramer gravatar image

At the very least, you don't include the method signature (just the function identifier) in the 3rd parameter when creating the subscriber (the n.subscribe call).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-04 09:42:39 -0500

Seen: 207 times

Last updated: Mar 05 '16