Monitoring

All pCall (parallel post call) return a function ID.

Function can be monitored:

ALModule ALProxy monitoring:

int ALProxy::pCall("method",...); Pcall return a method ID
int ALProxy::post.method(...) Identical to pCall
ALModule::wait(ID, timeout) Wait until timeout for method ID stop.
ALModule::stop(const std::string& pModuleName, int ID); To be implemented in user module if you want a specific behavior when the method is stopped.
ALModule::isRunning(int ID); True if method ID is running
ALModule::isRunning(functionName); True if function name is running (dangerous if several functions share the same name)
int getMethodID(void) Allow a method to know its ID.
bool ALTaskMonitor::isRequireStop(int ID) True if someone asks the method ID to stop

// C++ sample // walk and play mp3 in the same time. Stop mp3 when walk stop #include "almotionproxy.h" int IDWalk = motionProxy.post.walk(1); // walk int IDMP3 = audioout.playFile("longMusicForWalk.mp3"); // play music motionProxy.wait(ID); // wait end of walk audioout.stop(IDMP3); // stop music after walk

//C++ sample //bound method that want to know if someone wants to stop it void myModule::myMethod(void) // the method must be bound { myID = getMethodID(); while (!isRequireStop(myID)) { ... } } // if someone call mymodule.stop(myID), isRequireStop() will return true.

#python sample import os import sys import time path = `os.environ.get("AL_DIR")` home = `os.environ.get("HOME")` # import NAOqi lib if path == "None": print "the environment variable AL_DIR is not set, aborting..." sys.exit(1) else: alPath = path + "/extern/python/aldebaran" alPath = alPath.replace("~", home) alPath = alPath.replace("'", "") sys.path.append(alPath) import naoqi from naoqi import ALBroker from naoqi import ALModule from naoqi import ALProxy try: broker = ALBroker("pythonBroker","127.0.0.1",9999,"127.0.0.1",9559) time.sleep(2) IDWalk = ALMotion.post.walk(1) IDMP3 = audioout.post.playFile("longMusicForWalk.mp3"); ALMotion.wait(IDWalk,0) # 0 mean no timeout audioout.stop(IDMP3) except RuntimeError,e: exit(1)





Copyright © 2010 Aldebaran-Robotics - All rights reserved