Problem with subscriber a string [closed]
Hi,
I tried to do the tutorial writing a simple publisher and subscriber in c++ and it works.
Now i must use a function with argument the string that was subscribed, but i received the error: argument incorrect.
This is the code:
void chatterCallback (const std_msgs::String::ConstPtr& msg) {
ROS_INFO("I heard: [%s]\n", msg->data.c_str());
my_function(msg->data); //error
// i also tried msg->data.c_str()
} void my_function(char* c) ....
any suggestion?
thanks
What is the signature of my_function?
Also relevant: Does my_function need a non-const char* or is the just an old-style definition. If it doesn't change it, you could get away with just passing in the string data.