Memory - northern-bites/nbites GitHub Wiki

The Memory module is a relatively new addition to our system. It is based around using Google Protocol Buffers. The protobuf library provides an easy way to encapsulate information in structures of data called Messages. So think of a Message as a C struct - it only stores data but has no methods defined on it (a.k.a it doesn't do any processing/computation of its own). And that's what we want Memory to be - a static storage of information.

Memory Objects

Each Memory "Object" is a wrapper around a Proto Message (a Protocol Buffer Message) that provides a means to update the information stored in the proto message from an outside source (e.g. we want data in the vision part of memory to store the data obtained from vision). Also, each such Object stores a pointer to its "source". All of these are objects are managed in the main Memory class.

Providers and Memory as a Subscriber

Now that we have a mechanism to store the information the question of when to store it arises. The memory has no idea when information gets updated in the system, so having the memory poll for information would be hard to do. Thus we have each object class that provides any information extend the Provider class, and add Memory as a Subscriber to such a Provider at runtime. When the Provider signals new information with a call to the function notify, then the memory object will be tasked with updating its information from its associated data source (so MVision will pull info from Vision, etc.).

MObject_ID

Each Memory Object gets associated an ID in the enum MObject_ID. This helps identify it uniquely.

Future work

  • Integrating the memory objects tighter with corresponding sources, with a side result being avoiding some of the copying that occurs.
  • Keeping some memory objects in a circular buffer, so that we have a history of the information of the object (useful with vision and such)