catkin use msg error: no matching function for call to ros::NodeHandle::subscribe
Hi, I want to use a msg defined in a rosbuild package in catkin.
I include the .h file of this msg from the rosbuild package directly, and I can create the object successfully. i.e. tld_msgs::BoundingBox newMsg;
but when I want to subscribe to a topic that publish this msg I got a compile error
error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [20], int, int (&)(const BoundingBox&))’
I create the subscriber like this:
ros::Subscriber sub = n.subscribe("/tld_tracked_object", 20, callback);
and the callback function:
int callback(const tld_msgs::BoundingBox &data) { }
Can anyone figure out my mistake?
Thanks
===============================
I copied the msg file into the catkin workspace with the same package name and compiled successfully.
But I got the same error here.
error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [20], int, int (&)(const BoundingBox&))’
I think it should be the problem in my callback function. and I need to modify this:
ros::Subscriber sub = n.subscribe("/tld_tracked_object", 20, callback);
I googled and find I need to modify it like:
ros::Subscriber sub = n.subscribe("/tld_tracked_object", 20, tld_msgs::BoundingBox callback);
but it says error: ‘callback’ is not a member of ‘tld_msgs’
since there is only a msg folder in my tld_msgs
folder, I have no idea how to add this in my msg file...