|
Syzygy Documentation: Shared random numbers in the master/slave frameworkIntegrated Systems Lab01/17/2006 Documentation Table of Contents BackgroundThe master/slave framework has a facility for generating pseudo-random numbers that is meant to be independent of whether it is called on a master or a slave. However, it is possible to use it in such a way that the random number sequences get out of sync for brief periods. This note describes its behavior and makes suggestions about how to avoid such errors. Please note that the framework will also detect such errors and print an error message to the console if they occur. The following relevant data are transmitted from the master to the slaves on each frame:
Functionsvoid arMasterSlaveFramework::setRandomSeed( const long newSeed ) Sets the random seed on the master. The change does not take effect until immediately before the next data transfer, so it's probably not a good idea to start generating random numbers in e.g. the framework's init() callback. A value of 0 for the seed is illegal and will be converted to -1 with a printed warning. bool arMasterSlaveFramework::randUniformFloat( float& value ) Generates a new pseudo-random number using the ran1 //algorithm from //Numerical Recipes in C. Note that this algorithm generates uniformly-distributed values in the range (0,1), i.e. it does not include either 0 or 1. It returns a bool indicating whether or not _randSynchError is 0. As side-effects, it (1) resets _randSynchError to 0, so there is at most one error message per frame; (2) modifies the seed; (3) increments a counter, which is reset to 0 after each master/slave data transfer. Getting into troubleWhat follows is a list of conditions that we've thought of or come across under which the random number sequences will become desynchronized (mind you, the framework will tell you that you've gotten into trouble):
|
|
[Schedule] [Labs] [Beckman Meeting Rooms] [Equipment] [Projects] [CUBE Projects] [Syzygy] [VSS] [People] [Events] [Publications] |