What is the standard/recommended way of processing data from Subscriptions and then publishing it again
I am new to ROS and I'm struggling to understand the interactions between the ROS System and the c++ code of roscpp nodes. I wrote a node in c++ subscribing to a topic and a c++-class that has a callback method as a member function as explained in the tutorial. Now I would like to process the data and later on publish the processed data on a different topic. Now my question is: What's the propper way to do this? Considering I'm calling the subscribe in the main-function like this:
EventCallback left_camera_events;
ros::Subscriber leftCam = n.subscribe(left_camera_topic.data(), 1000, &EventCallback::callbackMethod, &left_camera_events);
Where do I process the data now? I feel like processing it in the main-function is the wrong way, isn't it? Do I have to process the data directly in the EventCallback::callbackMethod
? And after that: where do I call the Publish-Method? Do I have to publish from the main method of the node or do I publish from within the EventCallback class/object? I don't really need any actual code for this, just some explanations since the tutorials are very vague about most things. A simple link to some further tutorials than just the basic ros tutorials and roscpp-tutorials would be much appreciated, too.