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

Revision history [back]

click to hide/show revision 1
initial version

The issued is solved by add the type to subscribe(). Also, do not forget to add 'int i' to the assignment of callback().

void chatterCallback(const std_msgs::String::ConstPtr& msg, int i) {
    ROS_INFO("I heard: [%s]", msg->data.c_str());
}

In main():

ros::Subscriber sub = n.subscribe<std_msgs::String>("chatter0", 1000, boost::bind(chatterCallback, _1, i));