no matching function for call to
Hey everybody, I'm working on a node that uses a service to repeat a string a variable amount of times. for this i made the following srv file:
string text
int32 nrOfDuplicates
---
this will be processed by the following C++ code:
#include "ros/ros.h"
#include "std_msgs/String.h"
#include "std_msgs/Int32.h"
#include <string>
void multiply (std_msgs::String::ConstPtr & str, std_msgs::Int32 & var){
int amount = var.data;
for(int i = 0 ; i < amount ; i++)
{
ROS_INFO("%s", str->data.c_str());
}
ROS_INFO("/n");
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "add_duplicates");
ros::NodeHandle n;
ros::ServiceServer service = n.advertiseService("add_duplicates", multiply);
ros::spin();
return 0;
}
however, when i use catkin_make to compile the node, i get the following error:
/home/osboxes/catkin_ws/src/final/src/duplicator.cpp: In function ‘int main(int, char**)’:
/home/osboxes/catkin_ws/src/final/src/duplicator.cpp:19:77: error: no matching function for call to ‘ros::NodeHandle::advertiseService(const char [15], void (&)(std_msgs::String_<std::allocator<void> >::ConstPtr&, std_msgs::Int32&))’
ros::ServiceServer service = n.advertiseService("add_duplicates", multiply);
^
I was considering that it is looking for a function that uses a string and int32 instead of the Std_msgs counterpart, but i'm a total ROS newbie and am not sure if this is true, or how to write it otherwise.
all help is appreciated!