Synchronization

NAOqi provides two local synchronization methods. Synchronization is not compatible with remote modules.

Callback synchronization

All modules have onPreProcess and onPostProcess methods. Modules are free to call it and users are free to define it. Refer to modules documentation to know if callback are used. In v1.2.0 only device communication manager use callbacks.

Warning:

Callbacks are blocking for Aldebaran modules. Be careful to module cycle time. If callback execution is too long, robot can fall for example.

User callback definition:

void myCallBack(void) { // client algorithm } getParentBroker()->getProxy("ModuleToSynchronizeWith")->getModule()->atPreProcess(myCallBack); getParentBroker()->getProxy("ModuleToSynchronizeWith")->getModule()->atPostProcess(anotherCallBack); // use boost::bind to connect a class method.

Aldebaran modules sample:

this->PreProcess()(); // module processing this->PostProcess()();

Synchronization with condition

Synchronization with condition is asynchronous. User thread waits on a condition, Aldebaran module sends a signal to condition.

// condition creation to call in module constructor void ALModule::addSynchronizer(const std::string &pSynchronizerName); // wait on condition void ALModule::waitSynchronizer(const std::string &pSynchronizerName); // signal condition void ALModule::signalSynchronizer(const std::string &pSynchronizerName);

Conditions can also help to synchronize C++ and Python.





Copyright © 2010 Aldebaran-Robotics - All rights reserved