Robotics StackExchange | Archived questions

classes inside nodelet (NodeHandle)

Hello,

In my node I have several classes which I called from the main()

Then inside these classes constructor I simply use

nh_(ros::this_node::getName())
ros::NodeHandle nhPriv("~");

Now I convert this main() into a nodelet. The nh_ and nhPriv inside classes doesn't work because its not a node but a nodelet.

what is the best way to get nodeHandles inside these classes ?

I am dreading making these several classes into nodelets, is there a better way ?

Asked by ROSfc on 2016-11-16 08:02:31 UTC

Comments

Is there any reason why you cannot use getNodeHandle() and getPrivateNodeHandle()? They are described in the Nodelet tutorial.

Asked by Javier V. Gómez on 2016-11-18 13:51:15 UTC

yes the getNodeHandle() doesn't compile because I think it needs to be derived class from the nodelet class I am not so sure if this is the reason though. Anyway, I know decided to pass the nodehandles into the sub-classes from the nodelet. This seems to be the convention followed.

Asked by ROSfc on 2016-11-20 14:39:32 UTC

Answers