Question regarding how a message is created to how it is published
I’m trying to understand the flow code-wise starting with how a message is created by a module and ending with the publishing of it. I cannot comprehend how this works. For example, where is a PerceptionObstacle protobuf message created inside the perception module, which scripts are involved in creating it and which script is publishing it? It seems like some adapter files are involved but I cannot figure out in what way.
Best Regards
Firstly, Apollo is based on ROS. You need to get familiar with ROS. The page explains how ROS send/receive message: http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29. Apollo uses AdapterManager to handle messages. For each kind of message, it contains methods to receive/publish the message. For each module, you can see its Start() method to see how its adapter is initialized (reading the module config file and proto definination file). Taking the localization module as example, refer to msf_localization.cc, Start() method init the AdapterManager, register the message receiver callback. In the callback methods, they process the received message and publish localiztion message. BTW, you can compile Apollo code with debug info (add compile flags for debugging), then debug the code to find how it works.
Thank you!