write in a vector through the same (ROS) callback using boost::bind (C++)
i'm using ROS topics in order to acquire some image streams from a simulator. the idea is the following: i have "n" visual sensors and i'd like to declare n subscriber (through a for cycle) that read n different topics and call the same callback: passing an integer to the c.b. i'll be able to fill a vector of images (each of them received on a different topic).
this is my code:
vector <IplImage*> Images;
void newImageTrigger_trgI(const sensor_msgs::ImageConstPtr& msg, int i)
{
cv_bridge::CvImagePtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
Images[i] = cv_ptr->image;
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
}
}
int main( int argc, char** argv )
{
ros::init(argc, argv, "ImageProcessing");
ros::NodeHandle n;
std::vector<ros::Subscriber> sub;
for (int i = 1; i < 6; i++)
{
string str_i=string_converter(i);
sub[i] = n.subscribe("/vrep/visionSensorData"+str_i, 1,... //ERROR
boost::bind(&newImageTrigger_trgI, _1, i));
}
.....
Obviously: "invalid arguments" at //ERROR
can someone help me please?...i think it's something concerning boost::bind function thanks