Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Blackboard Serialization

Peter Schmidt edited this page Sep 9, 2017 · 1 revision

Serialization refers to the process of converting a structure (such as the Blackboard on the Nao) into a format suitable for transmitting over a network (such as the rUNSWift network), where the structure can be reconstructed (such as in Offnao).

The code examples below were copied from the confluence wiki and aren't formatted correctly, all the newlines have been lost. Feel free to click 'edit page' to see the original text and fix it if you know how to.

To add a blackboard variable to be serialized

Where x is the variable you want to serialize, T is its type, and n is the current blackboard class version:

  • Blackboard.tcc:

BOOST_CLASS_VERSION(Blackboard, n);

becomes:

BOOST_CLASS_VERSION(Blackboard, n + 1);

  • Blackboard.tcc, shallowSerialize, add some lines like:

if (version > n) { ar & x; }

  • Blackboard.cpp, initialize the variable to something sensible in the no-argument constructor

To remove a blackboard variable from being serialized

Where x is the variable you want to not serialize, T is its type, and n is the current blackboard class version:

  • Blackboard.tcc:

BOOST_CLASS_VERSION(Blackboard, n);

becomes:

BOOST_CLASS_VERSION(Blackboard, n + 1);

  • Blackboard.tcc, shallowSerialize:

    ar & x;

    becomes:

     if(version <= n) {
         T tmp;
         ar & tmp;
      }
    

    Note: There is a Garbage class if T no longer exists. See Pose.tcc for an example.

Changing the type of a blackboard variable and loading the old types information

Where x is the variable you want to serialize, T1 is the old type, T2 is the new type, and n is the current blackboard class version:

  • Blackboard.tcc:

BOOST_CLASS_VERSION(Blackboard, n);

becomes:

BOOST_CLASS_VERSION(Blackboard, n + 1);

  • Blackboard.tcc, shallowSerialize:

ar & x;

becomes:

if(version <= n) { T1 tmp; ar & tmp; x = convert(tmp); } else { ar & x; }

Note: There is a Garbage class if T1 no longer exists. See Pose.tcc for an example.

Combining multiple blackboard variable into a wrapper class and loading the old types' information

Where x and y are the variables you want to combine into xy, T1x and T1y are the old types, T2 is the new type, and n is the current blackboard class version:

  • Blackboard.tcc:

BOOST_CLASS_VERSION(Blackboard, n);

becomes:

BOOST_CLASS_VERSION(Blackboard, n + 1);

  • Blackboard.tcc, shallowSerialize:

ar & x; ... ar & y;

becomes:

T1x x; if(version <= n) { ar & x; } ... if(version <= n) { T1y y; ar & y; xy = convert(x, y); } else { ar & xy; }

Note: There is a Garbage class if T1x or T1y no longer exist. See Pose.tcc for an example.