How to make a class with publisher and subscriber which is a member of another class [closed]
Let's assume I have class cA, which has a node that subscribe from topic and publisher with a "constant" frequency. Class cA is a mamber of class cB. Where I should put "while(ros::ok())" for publishing purpose? Cose if i put it in constructor it'll bloc constructor of "higher" class (ofc. I can make a function cA::Publish() and run everything further in cB::Publish() or split classes to more nodes and classes, but i am looking for beter solution).
Should I use threads? I have never used them so I don't know if i should. I found this _cant_post_links_http_://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning
Is there an easy example?
thanks in advance