question about the nodehandle for subscribing and publishing
Hello everyone,
I have created my own package (with catkin) in which I am subscribing and publishing to several topics. So far, for each topic (wheather for subcribing or publishing) I have created a seperate nodehandle and I was wondering if that is actually necessary or if something like this (basically just having one single nodehandle) is possible:
ros::NodeHandle nh_my_pkg("~");
ros::Publisher publisher = nh_my_pkg.advertise<geometry_msgs::Twist>("/topic name", 1);
ros::Subscriber subscriber = nh_my_pkg.subscribe<geometry_msgs::Twist>("/topic name", 1, &my_class::callback_fct, this);
Thanks and have a nice day
Marcus