Using if statements with std_msgs::String::ConstPtr
I have a node that is getting action calls from another node. Once it gets the action, I want to call a specific function but the if statement doesn't ever return true.
How can I get an if statement to work with a std_msgs string?
void chattersCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: %s", msg->data.c_str());
if ((msg->data.c_str()) == "Listen") {sendStopAction();}
}
The terminal shows
[ INFO] [1381550860.740367371]: I heard: Listen
But the If statement does not return true. There is another print statement in the sendStopAction() function