-
Notifications
You must be signed in to change notification settings - Fork 2
Blackboard Serialization
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.
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
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.
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.
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.