おそらくモジュールジェネレータで作られたNAOqiモジュールから、あなたはブローカにアクセスでき、それを使ってMotionの
preProcess イベントまたは
postProcess イベントへの接続を作成できます。これにより、各サイクルの開始時または終了時に目覚めて、何らかの処理を行うことができます。ロボットの現在の状態を取得し、いくつかのコマンドを準備します。
// Your method that will be called
void YourModule::motionPreProcessCallback() {
// Do something very small every 20ms.
// You are in a real time thread, so beware.
// If you wish to do heavy processing, you should
// raise a signal that is consumed by another thread
}
void YourModule::subscribeMotionPreProcess() {
try {
// Register the callback
// The specialized proxy does not give access
// to the underlying module needed for this binding,
// so we get a generic proxy from the parent broker
getParentBroker()->getProxy("ALMotion")->getModule()->atPreProcess(
boost::bind(&YourModule::motionPreProcessCallback,this));
} catch(const AL::ALError& e) {
std::cout << "Motion preProcess callback registration failed" << std::endl;
}
}