Subscriber declaration in while loop
If I declare a subscriber in the while (ros::ok()) loop is it is allowed to change the topic which I read from at each loop? Actually it doesn't work: the topics which i read from are always the same, the initial ones: "..Data1","...Data2" What am I doing wrong?
string targetI_id="1";
string targetII_id="2";
while (ros::ok())
{
// here i change the string at each loop
ros::Subscriber vrepVideoSubscriber_trgII = n.subscribe("/vrep...
/visionSensorData"+targetII_id,1,newImageTrigger_trgII);
ros::Subscriber vrepVideoSubscriber_trgI = n.subscribe("/vrep...
/visionSensorData"+targetI_id,1,newImageTrigger_trgI);
.....