janfeitsma / MRA-prototype

MRA (Robocup MSL Reference Architecture) prototype
MIT License
5 stars 0 forks source link

Create a logging facility #10

Closed janfeitsma closed 1 year ago

janfeitsma commented 1 year ago

Given that all data (including state) is explicit on the interface, it is only natural to log it to file for every tick. That would help with troubleshooting and test driven development.

Currently I just use a lazy approach: #define DEBUG at https://github.com/janfeitsma/MRA-prototype/blob/main/components/falcons/velocity-control/tick.cpp#L9 This has been proven valuable and I think it is time to mature it into a facility.

Jurge suggested spdlog, it seems very powerful.

Some ideas / thoughts:

Please add thoughts and ideas in this thread! (Jurge, share your ideas from the ppt?)

jveijck commented 1 year ago
janfeitsma commented 1 year ago

Started with a first quick version to replace the #ifdef DEBUG stdout dumping. I also added binary file dumping, which is useful because I now need to plot opencv protobuf data, rather in python than C++.

No configurability, spdlog yet etc.

Here you can see how it is currently used as oneliner, that is also close to how I intend to have it at each tick.cpp: https://github.com/janfeitsma/MRA-prototype/blob/localization-from-scratch/components/falcons/localization-vision/tick.cpp#L26

Note for instance how that scoped object logs the state before and after tick. Might need some more macro/codegen sauce to figure out component etc.

jveijck commented 1 year ago

The proposed WoW requires that every component it must implement it self. I had the idea to replace the abstract MRAInterface class by a MRAcomponent class. Each MRA component will inherited from it.

This allow to create generic methods like:

Roughly the following sequence diagram will be used image

jveijck commented 1 year ago

the baseclass approach also allow to monitor the calculation time etc.

janfeitsma commented 1 year ago

I agree, it is almost time to rework the fundaments of the component, using such a baseclass for instance. But that is an activity which we may want to hold off until gathering input from other MSL-MRA community members. Related to that, note how this is a prototype repository. It was intended a) to demo and b) to get experience. It has served its purpose. Now I have a much better feeling for what we want and roughly how to do it. So perhaps it is better to start fresh in MSL github project, afterwards migrate all prototype content / good concepts into it.

janfeitsma commented 1 year ago

Let's leave the base class and codegen ideas out of scope for now. It would have far too large impact... need to discuss with MSL-MRA community.

Also I prefer to hide stuff like attach/detach from developers. Macros can handle this for us?

Some design ideas/directions which I soon want to dive into, make a branch from yours. Some is very similar as we already have or as you added; some new stuff.

jveijck commented 1 year ago

The point about spaces vs tabs, can perhaps solved by a pipeline action. (convert tabs to spaces). Let's discuss the points when we speak, I agree on most points, but some are not 100% clear. We can also check if the original points are addressed as we originally intended.

janfeitsma commented 1 year ago

Open issue: how should we handle logging of nested components.

In a different branch, building on top of the open PR, I am enabling tick logging for all my components. This is what we get during testsuite:

-rw-r--r-- 1 jan jan    651 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsGetballIntercept.log
-rw-r--r-- 1 jan jan    651 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsGetball.log
-rw-r--r-- 1 jan jan   4239 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsGetballFetch.log
-rw-r--r-- 1 jan jan   6750 Sep  8 08:01 /tmp/testsuite_mra_logging/RobotsportsProofIsAlive.log
-rw-r--r-- 1 jan jan   3312 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsTrajectoryGeneration.log
-rw-r--r-- 1 jan jan 586539 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsVelocityControl.log
-rw-r--r-- 1 jan jan   6227 Sep  8 08:01 /tmp/testsuite_mra_logging/FalconsLocalizationVision.log

The component FalconsTrajectoryGeneration uses FalconsVelocityControl. Bazel test runs all tests in parallel. The logging of FalconsVelocityControl shows two running tick logs interlaced...

I am thinking of having nested logging in the calling component, so in this example: FalconsTrajectoryGeneration.

Another minor note: maybe tick io logging should be at debug level, not info level.

janfeitsma commented 1 year ago

I think PR #24 is good enough to close this open issue, since a lot of ground has been covered now.

janfeitsma commented 1 year ago

Mostly completed

jveijck commented 1 year ago

I propose to make a new issues if remaining functionality is required. A big step forward is made via this issue.