robotology / robometry

Telemetry suite for logging data from your robot 🤖
https://robotology.github.io/robometry
Other
14 stars 9 forks source link

Add the possibility to have multilayer structures in the BufferManager #146

Closed GiulioRomualdi closed 2 years ago

GiulioRomualdi commented 2 years ago

This PR implements a new approach to save data in yarp-telemetry library. Before entering into the details I want to underline that:

  1. This PR is back-compatible. The already existing code that uses yarp telemetry still work and the final user will not see any difference in the mat file used to store the data
  2. This PR closes https://github.com/robotology/yarp-telemetry/issues/145

As already explained in https://github.com/robotology/yarp-telemetry/issues/145 one of the main limitations of telemetry is the absence of a multilayer structure to store the data. For instance, it would be nice to have all the measurements of the FT contained in the same Matlab structure. Having this goal in mind we can imagine that a mat file is just a tree containing several structures where each leaf is a BufferInfo. The following picture represents the content of a mat. The orange circles are the BufferInfo (i.e. the leaf of the tree) and the gray one is the intermediate structure.

image

In this case, it will be possible to access the element E2 with the following Matlab command

data = root.A.B.E2;

Since we do not want to change the BufferManager interface (I want to keep the back compatibility with the already existing code), I decided (discussing with @S-Dafarra and @traversaro) to use a string separator to consider nested struct in the creation of a new channel. For instance in order to add the element E2 represented in the above figure the channel has to be defined as follows

yarp::telemetry::experimental::ChannelInfo channel{ "root::A::B::E2", {1,1} };

This PR contains the implementation of what I have just explained. The main contribution is the introduction of the TreeNode class that represents a node of the tree. Each node contains a dictionary of childer and a pointer to a BufferInfo.

The BufferManager::m_buffer_map data struct used to contain the buffer has been substituted by the std::shared_ptr<TreeNode<BufferInfo<T>>> m_tree and the buffer manager is in charge to explore the tree to update the content of the BufferInfo and save them in a mat file.

TODO:

cc @traversaro and @S-Dafarra

GiulioRomualdi commented 2 years ago

cc @traversaro @S-Dafarra @AlexAntn @Nicogene

GiulioRomualdi commented 2 years ago

Hi @Nicogene sorry for the delay. I updated the readme https://github.com/robotology/yarp-telemetry/pull/146/commits/c151bcc1211e3f6a4d23bb5bcfd267da47d163a2 I added an example https://github.com/robotology/yarp-telemetry/pull/146/commits/3e854b0b27aa0bfb9c33cb5ce8191b21039d7441 and I updated the tests https://github.com/robotology/yarp-telemetry/pull/146/commits/be130431ae72780c4babbb78d86e7738f0e72277.

Let me know if it is fine with you 😄

Nicogene commented 2 years ago

Merged, thanks!