Ask Your Question

Revision history [back]

You can easily do that by creating multiple subscribers or a vector of subscribers and make all of them point at same callback function.

You can easily do that by creating multiple subscribers or a vector of subscribers and make all of them point at same callback function.

sicklms_subs = new ros::Subscriber[no_of_ugv]; for(int i = 0; i < no_of_ugv; i++) { ss.seekp(0); ss << "/sicklms" << i << "/scan"; sicklms_subs[i] = nh.subscribe(ss.str(), 100, &mapper_direct::laserCallback, this); }

click to hide/show revision 3
highlighting

You can easily do that by creating multiple subscribers or a vector of subscribers and make all of them point at same callback function.

   sicklms_subs = new ros::Subscriber[no_of_ugv];
    for(int i = 0; i < no_of_ugv; i++)
    {
        ss.seekp(0);
        ss << "/sicklms" << i << "/scan";
        sicklms_subs[i] = nh.subscribe(ss.str(), 100, &mapper_direct::laserCallback, this);
    }