Having trouble with the chattercallback function in a ROS subscriber?
Hello, I'm trying to write a ROS subscriber to subscribe to some of the data from the kinect sensor on a turtlebot. I started by copying the subscriber part of the tutorial here: h t t p : / / w i k i . r o s . o r g / R O S / T u t o r i a l s / W r i t i n g P u b l i s h e r S u b s c r i b e r % 2 8 c % 2 B % 2 B % 2 9, and then copying and modifying the various parts of the program to fit the topics that I'm trying to subscribe to. For example, one of the topics I'm trying to subscribe to is /odom, and my code for this part is as follows: //(outside the main class) void blabberingEavesdropper(const std_msgs::String::ConstPtr& msg) //modification of the chatterCallback function { ROS_INFO("I heard: [%s]", msg->data.c_str()); } //(inside the main class) ros::Subscriber odomSub = n.subscribe("/odom", 1000, blabberingEavesdropper);
When I catkin_make, the node compiles without errors, but then when I start up the turtlebot (turn it on as well as run minimal.launch and 3dsensor.launch), I get the following error (at least for the /odom part): Since I get a similar error message for each topic, and they all say that the subscriber wants the topic to have the same data type (std_msgs/String/some_random_number), I think my problem is with the chatterCallBack functions (renamed blabberingEvasedropper). I can't figure out exactly what to put in the arguments that will not cause this error, and that won't cause errors when I try to catkin_make my program. My goal is just to have the blabberingEvasedropper function print out the message it received on the screen. Anyone know how to do this?