ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
If you don't like global variables, you can also pass the publisher by reference to a function:
void worker (ros::Publisher& pub)
{
//...
}
int main (int argc, char** argv)
{
//...
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<PointCloud>("points2", 1);
//...
worker(pub);
//...
}