While the ROS specific stuff looks OK on first glance, it is always helpful to post the full error message instead of just saying "invalid arguments" ;-)
I assume that the way you try to create your string is your main problem. Try
for (int i = 1; i < 6; i++)
{
std::stringstream topicName;
topicName << "/vrep/visionSensorData" << i;
sub[i] = n.subscribe(topicName.str().c_str(), 1, boost::bind(&newImageTrigger_trgI, _1, i));
}
to subscribe to the topics /vrep/visionSensorData1
.. /vrep/visionSensorData6
P.S.: Oh, and look up how to write to a vector (either resize before the loop if you already know the final size, or use push_back()
in the loop).
Originally posted by Philip with karma: 990 on 2013-06-10
This answer was NOT ACCEPTED on the original site
Post score: 1
Original comments
Comment by mateo_7_7 on 2013-06-11:
you are right! and furthermore: using push_back() i don't need the index, as even the boost::bind function anymore...isn't it?
Comment by Philip on 2013-06-11:
Sounds good. You need the boost::bind if you want to know which subscriber is currently calling the callback, in your case to save the image in the correct position of the Images[]-array, Can you post your final code as an edit to the questions, so others can see the final solution?
Comment by mateo_7_7 on 2013-06-11:
...but if i use the subscribers in order, and so i read the topics in order, automatically i'll have the images stored in the vector in order..am I right?
ps. of course...i'm gonna do that, i have to fix some errors
Comment by Philip on 2013-06-11:
The subscribers aren't necessarily called in any order, at least in none that you should rely on. When the callback function is invoked (because a message was received) and some value has to be saved at a specific "position" in your vector, you have to provide that information to the callback.
Comment by mateo_7_7 on 2013-06-11:
Invalid arguments '
Candidates are:
ros::Subscriber subscribe(const std::basic_string<char,std::char_traits,std::allocator> &, unsigned int, void (#1::*)(#0), #1 *, const ros::TransportHints &)
ros::Subscriber subscribe(ros::SubscribeOptions &)
ros::Subscriber subscribe(const std::basic_
Comment by mateo_7_7 on 2013-06-11:
string<char,std::char_traits,std::allocator> &, unsigned int, void (#1::*)(#0)const, #1 , const ros::TransportHints &)
ros::Subscriber subscribe(const std::basic_string<char,std::char_traits,std::allocator> &, unsigned int, void (#1::)(const boost::shared_ptr<const #0> &),#
Comment by mateo_7_7 on 2013-06-11:
1 , const ros::TransportHints &)ros::Subscriber subscribe(const std::basic_string<char,std::char_traits,std::allocator> &, unsigned int, void (#1::)(const boost::shared_ptr<const #0> &)const, #1 *, const ros::TransportHints
Comment by mateo_7_7 on 2013-06-11:
the last 3 posts are about the error i receive trying to compile the code you suggested me...??
Comment by mateo_7_7 on 2013-06-11:
the method to create the string is definitely right...it works for others topics.